Class Deque<E>

Type Parameters

  • E = any

Hierarchy

Constructors

Accessors

Methods

  • The delete function removes a node from a doubly linked list based on either the node itself or its value.

    Parameters

    • valOrNode: E

      The valOrNode parameter can accept either a value of type E or a DoublyLinkedListNode<E> object.

    Returns boolean

    The delete method returns a boolean value. It returns true if the value or node was successfully deleted from the doubly linked list, and false if the value or node was not found in the list.

  • The delete function removes a node from a doubly linked list based on either the node itself or its value.

    Parameters

    • valOrNode: DoublyLinkedListNode<E>

      The valOrNode parameter can accept either a value of type E or a DoublyLinkedListNode<E> object.

    Returns boolean

    The delete method returns a boolean value. It returns true if the value or node was successfully deleted from the doubly linked list, and false if the value or node was not found in the list.

  • The deleteAt function removes an element at a specified index from a linked list and returns the removed element.

    Parameters

    • index: number

      The index parameter represents the position of the element that needs to be deleted in the data structure. It is of type number.

    Returns undefined | E

    The method deleteAt returns the value of the node that was deleted, or null if the index is out of bounds.

  • The filter function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the elements that satisfy the given callback function.

    Parameters

    • callback: ((val) => boolean)

      The callback parameter is a function that takes a value of type E and returns a boolean value. It is used to determine whether a value should be included in the filtered list or not.

        • (val): boolean
        • Parameters

          • val: E

          Returns boolean

    Returns DoublyLinkedList<E>

    The filtered list, which is an instance of the DoublyLinkedList class.

  • The find function iterates through a linked list and returns the first element that satisfies a given condition.

    Parameters

    • callback: ((val) => boolean)

      A function that takes a value of type E as its parameter and returns a boolean value. This function is used to determine whether a particular value in the linked list satisfies a certain condition.

        • (val): boolean
        • Parameters

          • val: E

          Returns boolean

    Returns null | E

    The method find returns the first element in the linked list that satisfies the condition specified by the callback function. If no element satisfies the condition, it returns null.

  • The findLast function iterates through a linked list from the last node to the first node and returns the last value that satisfies the given callback function, or null if no value satisfies the callback.

    Parameters

    • callback: ((val) => boolean)

      A function that takes a value of type E as its parameter and returns a boolean value. This function is used to determine whether a given value satisfies a certain condition.

        • (val): boolean
        • Parameters

          • val: E

          Returns boolean

    Returns null | E

    The method findLast returns the last value in the linked list that satisfies the condition specified by the callback function. If no value satisfies the condition, it returns null.

  • The function findNodeByValue searches for a node with a specific value in a doubly linked list and returns the node if found, otherwise it returns null.

    Parameters

    • val: E

      The val parameter is the value that we want to search for in the doubly linked list.

    Returns null | DoublyLinkedListNode<E>

    The function findNodeByValue returns a DoublyLinkedListNode<E> if a node with the specified value val is found in the linked list. If no such node is found, it returns null.

  • The forEach function iterates over each element in a linked list and applies a callback function to each element.

    Parameters

    • callback: ((val, index) => void)

      The callback parameter is a function that takes two arguments: val and index. The val argument represents the value of the current node in the linked list, and the index argument represents the index of the current node in the linked list.

        • (val, index): void
        • Parameters

          • val: E
          • index: number

          Returns void

    Returns void

  • The getAt function returns the value at a specified index in a linked list, or null if the index is out of bounds.

    Parameters

    • index: number

      The index parameter is a number that represents the position of the element we want to retrieve from the list.

    Returns undefined | E

    The method is returning the value at the specified index in the linked list. If the index is out of bounds or the linked list is empty, it will return null.

  • The function getNodeAt returns the node at a given index in a doubly linked list, or null if the index is out of range.

    Parameters

    • index: number

      The index parameter is a number that represents the position of the node we want to retrieve from the doubly linked list. It indicates the zero-based index of the node we want to access.

    Returns null | DoublyLinkedListNode<E>

    The method getNodeAt(index: number) returns a DoublyLinkedListNode<E> object if the index is within the valid range of the linked list, otherwise it returns null.

  • The function returns the index of the first occurrence of a given value in a linked list.

    Parameters

    • val: E

      The parameter val is of type E, which means it can be any data type. It represents the value that we are searching for in the linked list.

    Returns number

    The method indexOf returns the index of the first occurrence of the specified value val in the linked list. If the value is not found, it returns -1.

  • The insertAfter function inserts a new node with a given value after an existing node in a doubly linked list.

    Parameters

    • existingValueOrNode: E

      The existing value or node in the doubly linked list after which the new value will be inserted. It can be either the value of the existing node or the existing node itself.

    • newValue: E

      The value that you want to insert into the doubly linked list.

    Returns boolean

    The method returns a boolean value. It returns true if the insertion is successful, and false if the existing value or node is not found in the doubly linked list.

  • The insertAfter function inserts a new node with a given value after an existing node in a doubly linked list.

    Parameters

    • existingValueOrNode: DoublyLinkedListNode<E>

      The existing value or node in the doubly linked list after which the new value will be inserted. It can be either the value of the existing node or the existing node itself.

    • newValue: E

      The value that you want to insert into the doubly linked list.

    Returns boolean

    The method returns a boolean value. It returns true if the insertion is successful, and false if the existing value or node is not found in the doubly linked list.

  • The insert function inserts a value at a specified index in a doubly linked list.

    Parameters

    • index: number

      The index parameter represents the position at which the new value should be inserted in the DoublyLinkedList. It is of type number.

    • val: E

      The val parameter represents the value that you want to insert into the Doubly Linked List at the specified index.

    Returns boolean

    The insert method returns a boolean value. It returns true if the insertion is successful, and false if the index is out of bounds.

  • The insertBefore function inserts a new value before an existing value or node in a doubly linked list.

    Parameters

    • existingValueOrNode: E

      The existing value or node in the doubly linked list before which the new value will be inserted. It can be either the value of the existing node or the existing node itself.

    • newValue: E

      The newValue parameter represents the value that you want to insert into the doubly linked list.

    Returns boolean

    The method returns a boolean value. It returns true if the insertion is successful, and false if the insertion fails.

  • The insertBefore function inserts a new value before an existing value or node in a doubly linked list.

    Parameters

    • existingValueOrNode: DoublyLinkedListNode<E>

      The existing value or node in the doubly linked list before which the new value will be inserted. It can be either the value of the existing node or the existing node itself.

    • newValue: E

      The newValue parameter represents the value that you want to insert into the doubly linked list.

    Returns boolean

    The method returns a boolean value. It returns true if the insertion is successful, and false if the insertion fails.

  • The map function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new DoublyLinkedList with the transformed values.

    Type Parameters

    • U

    Parameters

    • callback: ((val) => U)

      The callback parameter is a function that takes a value of type E (the type of values stored in the original DoublyLinkedList) and returns a value of type U (the type of values that will be stored in the mapped DoublyLinkedList).

        • (val): U
        • Parameters

          • val: E

          Returns U

    Returns DoublyLinkedList<U>

    The map function is returning a new instance of DoublyLinkedList<U> that contains the mapped values.

  • The reduce function iterates over a linked list and applies a callback function to each element, accumulating a single value.

    Type Parameters

    • U

    Parameters

    • callback: ((accumulator, val) => U)

      The callback parameter is a function that takes two arguments: accumulator and val. It is used to perform a specific operation on each element of the linked list.

        • (accumulator, val): U
        • Parameters

          • accumulator: U
          • val: E

          Returns U

    • initialValue: U

      The initialValue parameter is the initial value of the accumulator. It is the starting point for the reduction operation.

    Returns U

    The reduce method is returning the final value of the accumulator after iterating through all the elements in the linked list.

Generated using TypeDoc