This class is useful for managing a list of linked nodes, but it does not protect against modifying individual links. If the consumer modifies a link (sets the previous or next value) it will effectively break the collection.

It is possible to declare a node type of any kind as long as it contains a previous and next value that can reference another node. Although not as safe as a protected LinkedList, this class has less overhead and is more flexible.

The count (or length) of this LinkedNodeList is tracked as .unsafeCount and calling .getCount() will iterate the list.

Type Parameters

Hierarchy

Constructors

Accessors

  • get unsafeCount(): number
  • Returns the tracked number of nodes in the list. Since a LinkedNodeList is unprotected, it is possible to modify the chain and this count could get out of sync. To know the actual number of nodes, call .getCount() to iterate over each node.

    Returns

    Returns number

Methods

  • Inserts a node after the specified 'after' node. If no 'after' node is specified, it appends it as the last node.

    Returns

    Parameters

    • node: TNode
    • Optional after: TNode

    Returns LinkedNodeList<TNode>

  • Inserts a node before the specified 'before' node. If no 'before' node is specified, it inserts it as the first node.

    Returns

    Parameters

    • node: TNode
    • Optional before: TNode

    Returns LinkedNodeList<TNode>

  • Erases the linked node's references to each other and returns the number of nodes.

    Returns

    Returns number

  • Iterates the list to see if a node exists.

    Returns

    Parameters

    • node: TNode

    Returns boolean

  • Clears the list. Provided for use with dispose helpers.

    Returns void

  • Iterates the list returns the node at the index requested. Returns undefined if the index is out of range.

    Returns

    The node at the index requested or undefined.

    Parameters

    • index: number

    Returns undefined | ProtectedLinkedNode<TNode>

  • Iterates the list to find the specified node and returns its index.

    Returns

    Parameters

    • node: TNode

    Returns number

  • Clears the list. Provided for use with object pools.

    Returns void

  • Removes the first node and returns true if successful.

    Returns

    Returns boolean

  • Removes the last node and returns true if successful.

    Returns

    Returns boolean

  • Removes the specified node. Returns true if successful and false if not found (already removed).

    Returns

    Parameters

    • node: TNode

    Returns boolean

  • Removes the first node and returns it if successful. Returns undefined if the collection is empty.

    Returns

    The node that was removed, or undefined if the collection is empty.

    Returns undefined | TNode

  • Removes the last node and returns it if successful. Returns undefined if the collection is empty.

    Returns

    The node that was removed, or undefined if the collection is empty.

    Returns undefined | TNode

Generated using TypeDoc