Class DoubleLinkedList

Represents a doubly linked list.

Hierarchy

  • DoubleLinkedList

Constructors

Properties

head: undefined | DoubleLinkedListNode

The head node of the doubly linked list.

tail: undefined | DoubleLinkedListNode

The tail node of the doubly linked list.

Methods

  • Clears the doubly linked list by setting the head and tail nodes to undefined. TimeComplexity = O(1)

    Returns void

  • Returns the data of the first node in the doubly linked list. TimeComplexity = O(1)

    Returns unknown

    The data of the first node.

  • Initializes the doubly linked list with nodes created from the elements of the specified array. TimeComplexity = O(n)

    Parameters

    • data: unknown[]

      An array containing the data for the nodes.

    Returns void

  • Returns the data of the last node in the doubly linked list. TimeComplexity = O(1)

    Returns unknown

    The data of the last node.

  • Removes and returns the data of the last node in the doubly linked list. TimeComplexity = O(1)

    Returns unknown

    The data of the last node.

  • Inserts a new node with the specified data at the end of the doubly linked list. TimeComplexity = O(1)

    Parameters

    • data: unknown

      The data for the new node.

    Returns void

  • Removes and returns the data of the first node in the doubly linked list. TimeComplexity = O(1)

    Returns any

    The data of the first node.

  • Converts the doubly linked list to an array. TimeComplexity = O(n)

    Returns unknown[]

    An array containing the data of all the nodes.

  • Inserts a new node with the specified data at the beginning of the doubly linked list. TimeComplexity = O(1)

    Parameters

    • data: unknown

      The data for the new node.

    Returns void

Generated using TypeDoc