Stack
Defined in: packages/data/src/stack/stack.ts:19
An unbounded LIFO stack.
For a capacity, use BoundedStack (throws when full) or BlockingStack
(waits).
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
The type of elements in the stack.
Implements
Section titled “Implements”IStack<T>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Stack<
T>(iterable?,options?):Stack<T>
Defined in: packages/data/src/stack/stack.ts:22
Parameters
Section titled “Parameters”iterable?
Section titled “iterable?”Iterable<T, any, any>
options?
Section titled “options?”StackOptions<T>
Returns
Section titled “Returns”Stack<T>
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T>
Defined in: packages/data/src/stack/stack.ts:32
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/stack/stack.ts:36
Removes all elements from the collection.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”count()
Section titled “count()”count():
number
Defined in: packages/data/src/stack/stack.ts:40
The number of elements in the collection.
A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”pop():
T|undefined
Defined in: packages/data/src/stack/stack.ts:52
Removes and returns the item at the top of the stack.
Returns
Section titled “Returns”T | undefined
The item at the top of the stack, or undefined if the stack is
empty.
Implementation of
Section titled “Implementation of”push()
Section titled “push()”push(
item):void
Defined in: packages/data/src/stack/stack.ts:44
Adds an item to the top of the stack.
Parameters
Section titled “Parameters”T
The item to add to the stack.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”pushAll()
Section titled “pushAll()”pushAll(
items):void
Defined in: packages/data/src/stack/stack.ts:48
Adds every item to the top of the stack, in array order, so the last one is the first to be popped.
Parameters
Section titled “Parameters”readonly T[]
The items to add to the stack.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”top():
T|undefined
Defined in: packages/data/src/stack/stack.ts:56
Returns the item at the top of the stack without removing it.
Returns
Section titled “Returns”T | undefined
The item at the top of the stack, or undefined if the stack is
empty.