Amazon Vinyl
    Preparing search index...

    Class LinkedList<T>

    A standard doubly-linked list implementation.

    Type Parameters

    • T

    Implements

    • Iterable<T>
    Index
    • Returns a new iterator, starting at the head.

      Returns IterableIterator<T>

    • Returns the first node matching the given predicate.

      Parameters

      • predicate: (element: T) => boolean

        A function where, when true is returned, returns the current node.

      Returns LinkedNode<T> | null

    • Returns the last node matching the given predicate.

      Parameters

      • predicate: (element: T) => boolean

        A function where, when true is returned, returns the current node.

      Returns LinkedNode<T> | null

    • Iterates over every element, invoking the given callback.

      Parameters

      • callback: (element: T) => void

      Returns void

    • Appends the given node to the tail of this list. If the node is already at the tail, it will no-op. If the node is in this list, it will be removed.

      Parameters

      • node: LinkedNode<T>

        The node to add or move to the tail of this list.

      Returns void

    • Returns a new reversed iterable where the iterator starts at the tail, moving backwards to the head.

      Returns IterableIterator<T>

    • Similar to Array.prototype.some, returns true if at least one element passes the given predicate.

      Parameters

      • predicate: (element: T) => boolean

      Returns boolean

    • Prepends all the given values to the head of this list. The values will maintain their order.

      E.g.

      list.unshiftAll(8, 9, 10)   // 8, 9, 10
      list.unshiftAll(4, 5, 6, 7) // 4, 5, 6, 7, 8, 9, 10
      list.unshiftAll(1, 2, 3) // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

      Parameters

      • ...values: T[]

        The values to box in linked nodes.

      Returns void

    • Prepends the given node to the head of this list.

      • If the node is already at the head, it will no-op.
      • If the node is in this list, it will be removed.

      Parameters

      • node: LinkedNode<T>

        The node to add or move to the head of this list.

      Returns void