@tsdotnet/linked-list - v1.2.1
    Preparing search index...

    Class default<T>

    A doubly (bidirectional) linked list. Acts as a safe, value focused wrapper for a linked-node-list.

    Type Parameters

    • T

    Hierarchy

    • default<T>
      • default
    Index

    Constructors

    • Type Parameters

      • T

      Parameters

      • OptionalinitialValues: null | Iterable<T, any, any>
      • equalityComparer: EqualityComparison<T> = areEqual

      Returns default<T>

    Accessors

    • get firstValue(): undefined | T

      Returns the first value or undefined if the list is empty.

      Returns undefined | T

    • get lastValue(): undefined | T

      Returns the last value or undefined if the list is empty.

      Returns undefined | T

    • get reversed(): ExtendedIterable<T>

      Iterable for iterating this collection in reverse order.

      Returns ExtendedIterable<T>

    • get version(): number

      The version number used to track changes.

      Returns number

    Methods

    • Parameters

      • item: T

      Returns boolean

    • Returns number

    • Parameters

      • item: T
      • max: number = Infinity

      Returns number

    • Adds to specified item to the beginning of the list.

      Parameters

      • item: T

      Returns this

    • Adds to specified item to the end of the list.

      Parameters

      • item: T

      Returns this

    • Throws if the provided version does not match the current one.

      Parameters

      • version: number

      Returns true

    • Iterates the list returns the the first node that matches the value specified. Returns undefined if not found.

      Parameters

      • item: T

      Returns undefined | LinkedListNode<T>

      The node matching the item or undefined if not found

    • Iterates the list in reverse returns the the first node that matches the value specified. Returns undefined if not found.

      Parameters

      • item: T

      Returns undefined | LinkedListNode<T>

      The node matching the item or undefined if not found

    • Gets the number of nodes in the list.

      Returns number

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

      Parameters

      • index: number

      Returns undefined | LinkedListNode<T>

      The node at the index requested or undefined.

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

      Parameters

      • index: number

      Returns undefined | T

      The value at the index requested or undefined.

    • Increments the collection version. Useful for tracking changes.

      Returns number

      The new version.

    • Removes the node at the specified index.

      Parameters

      • index: number

      Returns boolean

      True if the node was removed. False if the index was out of range.

    • Removes the first node.

      Returns boolean

      True if the node was removed. False if the list is empty.

    • Removes the last node.

      Returns boolean

      True if the node was removed. False if the list is empty.

    • Iterates the list and finds the first node that matches the provided value and removes it.

      Parameters

      • item: T

        The value to remove.

      Returns boolean

      True if found and removes, otherwise false.

    • Removes the first node and returns its value.

      Returns undefined | T

      The value of the first node or undefined if the list is empty.

    • Removes the last node and returns its value.

      Returns undefined | T

      The value of the last node or undefined if the list is empty.