LinkedList Class

    Package: @esfx/collections-linkedlist

    A collection representing a [doubly-linked list](https://en.wikipedia.org/wiki/Doubly_linked_list).

    Declaration
    export declare class LinkedList<T> implements Collection<T> 

    Constructors

    constructor(equaler)

    Constructs a new instance of the LinkedList class

    Declaration
    constructor(equaler?: EqualityComparison<T> | Equaler<T>);
    Parameters
    equaler
    EqualityComparison<T> | Equaler<T>

    constructor(iterable, equaler)

    Constructs a new instance of the LinkedList class

    Declaration
    constructor(iterable?: Iterable<T>, equaler?: EqualityComparison<T> | Equaler<T>);
    Parameters
    iterable
    Iterable<T>

    equaler
    EqualityComparison<T> | Equaler<T>

    Properties

    [ReadonlyCollection.size]

    Declaration
    get [ReadonlyCollection.size](): number;
    Property Value
    number

    [Symbol.toStringTag]

    Declaration
    [Symbol.toStringTag]: string;
    Property Value
    string

    equaler

    Gets the Equaler<T> used for equality comparisons in this list.

    Declaration
    get equaler(): Equaler<T>;
    Property Value
    Equaler<T>

    first

    Gets the first node in the list. If the list is empty, this returns undefined.

    Declaration
    get first(): LinkedListNode<T> | undefined;
    Property Value
    LinkedListNode<T> | undefined

    last

    Gets the last node in the list. If the list is empty, this returns undefined.

    Declaration
    get last(): LinkedListNode<T> | undefined;
    Property Value
    LinkedListNode<T> | undefined

    size

    Gets the number of elements in the list.

    Declaration
    get size(): number;
    Property Value
    number

    Methods

    [Collection.add](value)

    Declaration
    [Collection.add](value: T): void;
    Parameters
    value
    T

    Returns
    void

    [Collection.clear]()

    Declaration
    [Collection.clear](): void;
    Returns
    void

    [Collection.delete](value)

    Declaration
    [Collection.delete](value: T): boolean;
    Parameters
    value
    T

    Returns
    boolean

    [ReadonlyCollection.has](value)

    Declaration
    [ReadonlyCollection.has](value: T): boolean;
    Parameters
    value
    T

    Returns
    boolean

    [Symbol.iterator]()

    Declaration
    [Symbol.iterator](): IterableIterator<T>;
    Returns
    IterableIterator<T>

    clear()

    Removes all nodes from the list.

    Declaration
    clear(): void;
    Returns
    void

    delete(value)

    Finds the first node in the list containing value, removes it from the list, and returns it. If a node containing value could not be found, undefined is returned instead.

    Declaration
    delete(value: T): LinkedListNode<T> | undefined;
    Parameters
    value
    T

    Returns
    LinkedListNode<T> | undefined

    deleteAll(predicate, thisArg)

    Removes all nodes from the list matching the supplied predicate.

    Declaration
    deleteAll(predicate: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): number;
    Parameters
    predicate
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    A callback function used to test each value and node in the list.

    thisArg
    any

    The this value to use when executing predicate.

    Returns
    number

    deleteNode(node)

    Removes the provided node from the list.

    Declaration
    deleteNode(node: LinkedListNode<T> | null | undefined): boolean;
    Parameters
    node
    LinkedListNode<T> | null | undefined

    Returns
    boolean

    true if the node was successfully removed from the list; otherwise, false.

    drain()

    Returns an iterator that removes each node from the list before yielding the node's value.

    Declaration
    drain(): IterableIterator<T>;
    Returns
    IterableIterator<T>

    every(callback, thisArg)

    Declaration
    every(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): boolean;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    thisArg
    any

    Returns
    boolean

    filter(callback, thisArg)

    Returns the elements of a the list that meet the condition specified in the provided callback function.

    Declaration
    filter<S extends T>(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S, thisArg?: any): LinkedList<S>;
    Type Parameters
    S

    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S

    The callback to call for each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedList<S>

    filter(callback, thisArg)

    Returns the elements of a the list that meet the condition specified in the provided callback function.

    Declaration
    filter(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): LinkedList<T>;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    The callback to call for each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedList<T>

    find(callback, thisArg)

    Finds the first value in the list that matches the provided callback.

    Declaration
    find<S extends T>(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S, thisArg?: any): S | undefined;
    Type Parameters
    S

    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    S | undefined

    find(callback, thisArg)

    Finds the first value in the list that matches the provided callback.

    Declaration
    find(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): T | undefined;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    T | undefined

    findLast(callback, thisArg)

    Finds the last value in the list that matches the provided callback, starting from the end of the list.

    Declaration
    findLast<S extends T>(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S, thisArg?: any): S | undefined;
    Type Parameters
    S

    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    S | undefined

    findLast(callback, thisArg)

    Finds the last value in the list that matches the provided callback, starting from the end of the list.

    Declaration
    findLast(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): T | undefined;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    T | undefined

    findLastNode(callback, thisArg)

    Finds the last LinkedListNode in the list that matches the provided callback, starting from the end of the list.

    Declaration
    findLastNode<S extends T>(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S, thisArg?: any): LinkedListNode<S> | undefined;
    Type Parameters
    S

    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedListNode<S> | undefined

    findLastNode(callback, thisArg)

    Finds the last LinkedListNode in the list that matches the provided callback, starting from the end of the list.

    Declaration
    findLastNode(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): LinkedListNode<T> | undefined;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedListNode<T> | undefined

    findNode(callback, thisArg)

    Finds the first LinkedListNode in the list that matches the provided callback.

    Declaration
    findNode<S extends T>(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S, thisArg?: any): LinkedListNode<S> | undefined;
    Type Parameters
    S

    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => value is S

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedListNode<S> | undefined

    findNode(callback, thisArg)

    Finds the first LinkedListNode in the list that matches the provided callback.

    Declaration
    findNode(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): LinkedListNode<T> | undefined;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    The callback used to test each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedListNode<T> | undefined

    forEach(callback, thisArg)

    Declaration
    forEach(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => void, thisArg?: any): void;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => void

    thisArg
    any

    Returns
    void

    has(value)

    Returns a value indicating whether value exists within the list.

    Declaration
    has(value: T): boolean;
    Parameters
    value
    T

    Returns
    boolean

    insertAfter(node, value)

    Inserts a new LinkedListNode containing value into the list after the provided node. If node is either null or undefined, the new node is inserted at the end of the list.

    Declaration
    insertAfter(node: LinkedListNode<T> | null | undefined, value: T): LinkedListNode<T>;
    Parameters
    node
    LinkedListNode<T> | null | undefined

    The node after which value will be inserted.

    value
    T

    The value to insert.

    Returns
    LinkedListNode<T>

    The new LinkedListNode for value.

    insertBefore(node, value)

    Inserts a new LinkedListNode containing value into the list before the provided node. If node is either null or undefined, the new node is inserted at the beginning of the list.

    Declaration
    insertBefore(node: LinkedListNode<T> | null | undefined, value: T): LinkedListNode<T>;
    Parameters
    node
    LinkedListNode<T> | null | undefined

    The node before which value will be inserted.

    value
    T

    The value to insert.

    Returns
    LinkedListNode<T>

    The new LinkedListNode for value.

    insertNodeAfter(node, newNode)

    Inserts newNode into the list after the provided node. If node is either null or undefined, newNode is inserted at the end of the list.

    Declaration
    insertNodeAfter(node: LinkedListNode<T> | null | undefined, newNode: LinkedListNode<T>): void;
    Parameters
    node
    LinkedListNode<T> | null | undefined

    The node after which newNode will be inserted.

    newNode
    LinkedListNode<T>

    The new node to insert.

    Returns
    void

    insertNodeBefore(node, newNode)

    Inserts newNode into the list before the provided node. If node is either null or undefined, newNode is inserted at the beginning of the list.

    Declaration
    insertNodeBefore(node: LinkedListNode<T> | null | undefined, newNode: LinkedListNode<T>): void;
    Parameters
    node
    LinkedListNode<T> | null | undefined

    The node before which newNode will be inserted.

    newNode
    LinkedListNode<T>

    The new node to insert.

    Returns
    void

    lastNodeOf(value, fromNode)

    Finds the last node in the list with the provided value, starting from the end of the list.

    Declaration
    lastNodeOf(value: T, fromNode?: LinkedListNode<T> | null): LinkedListNode<T> | undefined;
    Parameters
    value
    T

    The value to find.

    fromNode
    LinkedListNode<T> | null

    When provided, starts looking for value starting at this node and working backwards towards the front of the list.

    Returns
    LinkedListNode<T> | undefined

    map(callback, thisArg)

    Calls the provided callback function on each element of the list, and returns a new LinkedList that contains the results.

    Declaration
    map<U>(callback: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => U, thisArg?: any): LinkedList<U>;
    Type Parameters
    U

    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => U

    The callback to call for each value and node.

    thisArg
    any

    The this value to use when executing callback.

    Returns
    LinkedList<U>

    nodeOf(value, fromNode)

    Finds the first node in the list with the provided value.

    Declaration
    nodeOf(value: T, fromNode?: LinkedListNode<T> | null): LinkedListNode<T> | undefined;
    Parameters
    value
    T

    The value to find.

    fromNode
    LinkedListNode<T> | null

    When provided, starts looking for value starting at this node.

    Returns
    LinkedListNode<T> | undefined

    nodes()

    Declaration
    nodes(): IterableIterator<LinkedListNode<T>>;
    Returns
    IterableIterator<LinkedListNode<T>>

    pop()

    Removes the last node from the list and returns its value. If the list is empty, undefined is returned instead.

    Declaration
    pop(): T | undefined;
    Returns
    T | undefined

    popNode()

    Removes the last node from the list and returns it. If the lsit is empty, undefined is returned instead.

    Declaration
    popNode(): LinkedListNode<T> | undefined;
    Returns
    LinkedListNode<T> | undefined

    push(value)

    Inserts a new LinkedListNode containing value at the end of the list.

    Declaration
    push(value: T): LinkedListNode<T>;
    Parameters
    value
    T

    The value to insert.

    Returns
    LinkedListNode<T>

    The new LinkedListNode for value.

    pushNode(newNode)

    Inserts newNode at the end of the list.

    Declaration
    pushNode(newNode: LinkedListNode<T>): void;
    Parameters
    newNode
    LinkedListNode<T>

    The node to insert.

    Returns
    void

    reduce(callback)

    Calls the specified callback function for all the nodes in the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Declaration
    reduce(callback: (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T): T;
    Parameters
    callback
    (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T

    A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the list.

    Returns
    T

    reduce(callback, initialValue)

    Calls the specified callback function for all the nodes in the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Declaration
    reduce(callback: (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T, initialValue: T): T;
    Parameters
    callback
    (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T

    A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the list.

    initialValue
    T

    If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.

    Returns
    T

    reduce(callback, initialValue)

    Calls the specified callback function for all the nodes in the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Declaration
    reduce<U>(callback: (previousValue: U, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => U, initialValue: U): U;
    Type Parameters
    U

    Parameters
    callback
    (previousValue: U, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => U

    A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the list.

    initialValue
    U

    If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.

    Returns
    U

    reduceRight(callback)

    Calls the specified callback function for all the nodes in the list, in reverse. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Declaration
    reduceRight(callback: (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T): T;
    Parameters
    callback
    (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T

    A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the list.

    Returns
    T

    reduceRight(callback, initialValue)

    Calls the specified callback function for all the nodes in the list, in reverse. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Declaration
    reduceRight(callback: (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T, initialValue: T): T;
    Parameters
    callback
    (previousValue: T, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => T

    A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the list.

    initialValue
    T

    If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.

    Returns
    T

    reduceRight(callback, initialValue)

    Calls the specified callback function for all the nodes in the list, in reverse. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Declaration
    reduceRight<U>(callback: (previousValue: U, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => U, initialValue: U): U;
    Type Parameters
    U

    Parameters
    callback
    (previousValue: U, value: T, node: LinkedListNode<T>, list: LinkedList<T>) => U

    A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the list.

    initialValue
    U

    If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.

    Returns
    U

    shift()

    Removes the first node from the list and returns its value. If the list is empty, undefined is returned instead.

    Declaration
    shift(): T | undefined;
    Returns
    T | undefined

    shiftNode()

    Removes the first node from the list and returns it. If the list is empty, undefined is returned instead.

    Declaration
    shiftNode(): LinkedListNode<T> | undefined;
    Returns
    LinkedListNode<T> | undefined

    some(callback, thisArg)

    Declaration
    some(callback?: (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean, thisArg?: any): boolean;
    Parameters
    callback
    (value: T, node: LinkedListNode<T>, list: LinkedList<T>) => boolean

    thisArg
    any

    Returns
    boolean

    unshift(value)

    Inserts a new LinkedListNode containing value at the beginning of the list.

    Declaration
    unshift(value: T): LinkedListNode<T>;
    Parameters
    value
    T

    The value to insert.

    Returns
    LinkedListNode<T>

    The new LinkedListNode for value.

    unshiftNode(newNode)

    Inserts newNode at the beginning of the list.

    Declaration
    unshiftNode(newNode: LinkedListNode<T>): void;
    Parameters
    newNode
    LinkedListNode<T>

    The node to insert.

    Returns
    void

    values()

    Declaration
    values(): IterableIterator<T>;
    Returns
    IterableIterator<T>

    Generated by DocFX