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

    Interface IStack<T>

    Interface representing a stack data type

    A stack is a collection that follows the Last In First Out (LIFO) principle, where the last item added to the stack is the first one to be removed.

    interface IStack<T = unknown> {
        capacity: number;
        "[asyncIterator]"(): AsyncIterator<T, any, any>;
        "[iterator]"(): Iterator<Promisable<T>, any, any>;
        clear(): Promisable<void>;
        concat(...items: T[]): MaybeAsyncIterableIterator<T>;
        count(): Promisable<number>;
        pop(): Promisable<undefined | T>;
        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>;
        top(): Promisable<undefined | T>;
        waitPush(
            items: Iterable<T>,
            signal?: null | AbortSignal,
        ): PromiseLike<void>;
    }

    Type Parameters

    • T = unknown

      The type of elements in the stack.

    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>

    • Adds one or more items to the top of the stack.

      The items are added in the order they are provided. The last item in the argument list will be the first one to be popped.

      Parameters

      • ...items: T[]

        The items to add to the stack.

      Returns Promisable<void>

      If the operation would exceed the stack's capacity.

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

      Parameters

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

        Optional abort signal to cancel the operation.

      Returns PromiseLike<void>

      IStack.push