@tsdotnet/linked-node-list - v1.4.2
    Preparing search index...

    Class LinkedNodeList<TNode>

    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 (View Summary)

    Index

    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 number

    Methods

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

      Parameters

      Returns this

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

      Parameters

      Returns this

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

      Returns number

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

      Returns void

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

      Parameters

      Returns number

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

      Returns void

    • Removes the first node and returns true if successful.

      Returns boolean

    • Removes the last node and returns true if successful.

      Returns boolean

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

      Parameters

      Returns boolean

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

      Returns undefined | TNode

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

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

      Returns undefined | TNode

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