Type Parameters

  • T extends NodeData

Hierarchy

  • SinglyLinkedList

Implements

  • ISinglyLinkedList<T>

Methods

  • deletes a node at position

    Returns

    self reference to the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.delete(0); // [2, 3];

    Parameters

    • pos: number

    Returns SinglyLinkedList<T>

  • Returns

    Head of the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.getHead(); // 1

    Returns null | ISinglyLinkedListNode<T>

  • Returns

    size of the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.getSize(); // 3

    Returns number

  • Returns

    Tail of the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.getTail(); // 3

    Returns null | ISinglyLinkedListNode<T>

  • insert a new node to SinglyLinkedList.

    Returns

    self reference to the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.insert(1, 0); // [1]
    ssl.insert(2, 0); // [2, 1]
    ssl.insert(3, 1); // [2, 3, 1]

    Parameters

    • data: T

      The data inserted into a new node

    • pos: number

      The position of the new inserted node

    Returns SinglyLinkedList<T>

  • Remove last element of list

    Returns

    self reference to the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.pop(); // [1, 2];

    Returns SinglyLinkedList<T>

  • Insert A node at the end

    Returns

    self reference to the SinglyLinkedList

    Example

        const ssl = new SinglyLinkedList<number>();
    ssl.push(1).push(2).push(3);

    Parameters

    • data: T

      The data inserted into a new node

    Returns SinglyLinkedList<T>

  • Insert A node at the start

    Returns

    self reference to the SinglyLinkedList

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.pushStart(1); // [1]
    ssl.pushStart(2); // [2, 1]
    ssl.pushStart(3); // [3, 2, 1]

    Parameters

    • data: T

      The data inserted into a new node

    Returns SinglyLinkedList<T>

  • Returns

    Array of SinglyLinkedList elements

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.toArray(); // Array([1, 2, 3])

    Returns T[]

  • Log the content of the SinglyLinkedList.

    Example

    const sll = new SinglyLinkedList<number>();

    ssl.push(1).push(2).push(3); // [1, 2, 3]

    ssl.view(); // 1 => 2 => 3 => null

    Returns SinglyLinkedList<T>

Generated using TypeDoc