Type Parameters

  • T extends NodeData

Hierarchy

  • DoublyLinkedList

Implements

  • IDoublyLinkedList<T>

Methods

  • deletes a node from the list

    Returns

    self reference

    Example

    const list = new DoublyLinkedList<number>([1,2,3,4,5]);
    list.delete(3) // [1,2,3,5]

    Parameters

    • pos: number

    Returns DoublyLinkedList<T>

  • Returns

    head node

    Example

    const list = new DoublyLinkedList<number>([1,2,3,4,5]);
    list.getHead() // 1

    Returns null | DoublyLinkedListNode<T>

  • Returns

    head node

    Example

    const list = new DoublyLinkedList<number>([1,2,3,4,5]);
    list.getSize() // 5

    Returns number

  • Returns

    tail node

    Example

    const list = new DoublyLinkedList<number>([1,2,3,4,5]);
    list.getTail() // 5

    Returns null | DoublyLinkedListNode<T>

  • Inserts a new node to a specific index in the list if no index is provided it adds the node to the end of the list

    Returns

    self reference

    Example

    const list = new DoublyLinkedList<string>(['john', 'sami']);
    list.insert('joe', 0).insert('gaafar', 1) // ['joe', 'gaafar', 'john', 'sami']

    Parameters

    • data: T
    • Optional pos: number

    Returns DoublyLinkedList<T>

  • deletes the first node from the list

    Returns

    self reference

    Example

    const list = new DoublyLinkedList<number>([1,2,3,4,5]);
    list.popStart().popStart() // [3,4,5]

    Returns DoublyLinkedList<T>

  • Inserts a new node to the end of the list

    Returns

    self reference

    Example

    const list = new DoublyLinkedList<string>(['john', 'sami']);
    list.push('joe') // ['john', 'sami', 'joe']

    Parameters

    • data: T

    Returns DoublyLinkedList<T>

  • Inserts a new node to the beggining of the list

    Returns

    self reference

    Example

    const list = new DoublyLinkedList<string>(['john', 'sami']);
    list.pushStart('joe'); // ['joe,', 'john', 'sami']

    Parameters

    • data: T

    Returns DoublyLinkedList<T>

  • returns an array of all the nodes' data

    Returns

    array

    Example

    const list = new DoublyLinkedList<number>([1,2,3,4,5]);
    list.toArray() // [1,2,3,4,5]

    Returns T[]

Generated using TypeDoc