Class DoublyLinkedList<T>

A doubly linked list data structure. Each element has pointers to both the next and previous elements, allowing bidirectional traversal.

Typeparam

T - The type of elements stored in the list

Type Parameters

  • T

Implements

Constructors

Properties

head: DoubleNode<T> = null
tail: DoubleNode<T> = null

Methods

  • Returns the element at the specified index.

    Parameters

    • index: number

      The index of the element to retrieve

    Returns T

    The element at the specified index

    Throws

    Error if the list is empty or index is out of bounds

    Remarks

    TODO: Start at head or tail based on index compared to size for better performance

  • Removes the element at the specified index.

    Parameters

    • index: number

      The index of the element to remove

    Returns void

    Throws

    Error if the list is empty or index is out of bounds

    Remarks

    TODO: Start at head or tail based on index compared to size for better performance

  • Replaces the element at the specified index with a new value.

    Parameters

    • index: number

      The index of the element to replace

    • val: T

      The new value

    Returns T

    The previous value at the specified index

    Throws

    Error if the index is out of bounds

    Remarks

    TODO: Start at head or tail based on index compared to size for better performance