collect-your-stuff
    Preparing search index...

    Class Stack<T>

    A last-in-first-out collection: items are added to the top with push and taken from the top with pop. Any value can be stacked (it is stored as it is, whether it is a function, an object or null), and adding and taking are constant time. To stack tasks which are run as they are taken use TaskStack.

    Type Parameters

    • T = any

    Implements

    Index
    • Instantiate the stack, optionally with a list of items to start from.

      Type Parameters

      • T = any

      Parameters

      • stackedList: IsArrayable<any> = null

        The list of linkers to start in this stack (the first is the top)

      • listClass: any = LinkedList

        The type of list to create when no stacked list is given

      • linkerClass: typeof Linker = Linker

        The class used to hold each stacked item

      Returns Stack<T>

    stackedList: IsArrayable<any>

    The list which stores the stacked items, the first is the top of the stack.

    • Iterate over the items from the top of the stack to the bottom, without removing them.

      Returns Iterator<T>

    • Convert an array to a Stack by pushing each value in turn, so the last value is on the top.

      Type Parameters

      • T = any

      Parameters

      • values: T[] = []

        The items to stack

      • listClass: any = LinkedList

        The type of list used to store the items

      • linkerClass: typeof Linker = Linker

        The class used to hold each stacked item

      Returns Stack<T>