@ac-essentials/misc-util
    Preparing search index...

    Class Deque<T>

    A double-ended queue (deque) implementation.

    Type Parameters

    • T

      The type of elements in the deque.

    Hierarchy

    • LinkedListCollection<T>
      • Deque

    Implements

    Index

    Constructors

    Properties

    capacity: number = Infinity

    The maximum number of elements the collection can hold. If the collection is unbounded, this will be Infinity.

    data: LinkedList<T>

    Methods

    • Returns the item at the back of the deque without removing it.

      Returns T | undefined

      The item at the back of the deque, or undefined if the deque is empty.

    • Concatenates the given items to the end of the collection and returns an iterator over the merged items.

      This method does not mutate the original collection.

      Parameters

      • ...items: T[]

        The items to merge.

      Returns IterableIterator<T>

      An iterator of the merged items.

    • Adds one or more items to the back of the deque.

      The items are added in the order they are provided, with the last item in the argument list becoming the new back of the deque.

      Parameters

      • ...items: T[]

        The items to add to the back of the deque.

      Returns void

      If the operation would exceed the deque's capacity.

    • Replaces the first occurence of the item matching the given predicate in the collection with a new item.

      Parameters

      • condition: Predicate<[T]>

        A predicate function to identify the item to replace.

      • newItem: T

        The new item to insert.

      Returns boolean

      true if the item was found and replaced, false otherwise.

    • Adds one or more items to the front of the deque.

      The items are added in the order they are provided, with the last item in the argument list becoming the new front of the deque.

      Parameters

      • ...items: T[]

        The items to add to the front of the deque.

      Returns void

      If the operation would exceed the deque's capacity.

    • Same as push, but waits for capacity if the operation would exceed it.

      Parameters

      • items: Iterable<T>
      • Optionalsignal: AbortSignal | null

        Optional abort signal to cancel the operation.

      Returns Promise<void>

      IDeque.push

    • Same as unshift, but waits for capacity if the operation would exceed it.

      Parameters

      • items: Iterable<T>
      • Optionalsignal: AbortSignal | null

        Optional abort signal to cancel the operation.

      Returns Promise<void>

      IDeque.unshift