collect-your-stuff
    Preparing search index...

    Interface IsStack<T>

    Define a last-in-first-out stack: items are added to the top (push) and taken from the top (pop).

    interface IsStack<T = any> {
        empty: () => boolean;
        peek: () => T;
        pop: () => T;
        push: (data: T) => void;
        size: () => number;
    }

    Type Parameters

    • T = any

    Implemented by

    Index
    empty: () => boolean

    Check whether the stack has no items.

    peek: () => T

    Look at the item on the top of the stack, without removing it.

    Type Declaration

      • (): T
      • Returns T

        The item, or null when the stack is empty

    pop: () => T

    Take the item from the top of the stack.

    Type Declaration

      • (): T
      • Returns T

        The item, or null when the stack is empty

    push: (data: T) => void

    Add an item to the top of the stack.

    Type Declaration

      • (data: T): void
      • Parameters

        • data: T

          The item to add

        Returns void

    size: () => number

    Count the items in the stack.