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

    Interface IDeque<T>

    Interface representing a double-ended queue (deque) data type.

    A deque is a generalized version of a queue that allows insertion and removal of items from both ends.

    interface IDeque<T = unknown> {
        capacity: number;
        "[asyncIterator]"(): AsyncIterator<T, any, any>;
        "[iterator]"(): Iterator<Promisable<T>, any, any>;
        back(): Promisable<T | undefined>;
        clear(): Promisable<void>;
        concat(...items: T[]): MaybeAsyncIterableIterator<T>;
        count(): Promisable<number>;
        front(): Promisable<T | undefined>;
        pop(): Promisable<T | undefined>;
        push(...items: T[]): Promisable<void>;
        remove(
            condition: Predicate<[T]>,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        removeFirst(condition: Predicate<[T]>): Promisable<boolean>;
        replace(
            condition: Predicate<[T]>,
            newItemFactory: Callable<[T], T>,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        replaceFirst(condition: Predicate<[T]>, newItem: T): Promisable<boolean>;
        shift(): Promisable<T | undefined>;
        unshift(...items: T[]): Promisable<void>;
        waitPush(
            items: Iterable<T>,
            signal?: AbortSignal | null,
        ): PromiseLike<void>;
        waitUnshift(
            items: Iterable<T>,
            signal?: AbortSignal | null,
        ): PromiseLike<void>;
    }

    Type Parameters

    • T = unknown

      The type of elements in the deque.

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    capacity: number

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

    Methods

    • Returns AsyncIterator<T, any, any>

    • Returns Iterator<Promisable<T>, any, any>

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

      Returns Promisable<T | undefined>

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

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

      Returns Promisable<T | undefined>

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

    • Removes and returns the item at the back of the deque.

      Returns Promisable<T | undefined>

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

    • 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 Promisable<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 Promisable<boolean>

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

    • Removes and returns the item at the front of the deque.

      Returns Promisable<T | undefined>

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

    • 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 Promisable<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 PromiseLike<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 PromiseLike<void>

      IDeque.unshift