Skip to content

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).

T extends DefinedValue

The type of elements in the stack.

new Stack<T>(iterable?, options?): Stack<T>

Defined in: packages/data/src/stack/stack.ts:22

Iterable<T, any, any>

StackOptions<T>

Stack<T>

[iterator](): Iterator<T>

Defined in: packages/data/src/stack/stack.ts:32

Iterator<T>

IStack.[iterator]


clear(): void

Defined in: packages/data/src/stack/stack.ts:36

Removes all elements from the collection.

void

IStack.clear


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.

number

IStack.count


pop(): T | undefined

Defined in: packages/data/src/stack/stack.ts:52

Removes and returns the item at the top of the stack.

T | undefined

The item at the top of the stack, or undefined if the stack is empty.

IStack.pop


push(item): void

Defined in: packages/data/src/stack/stack.ts:44

Adds an item to the top of the stack.

T

The item to add to the stack.

void

IStack.push


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.

readonly T[]

The items to add to the stack.

void

IStack.pushAll


top(): T | undefined

Defined in: packages/data/src/stack/stack.ts:56

Returns the item at the top of the stack without removing it.

T | undefined

The item at the top of the stack, or undefined if the stack is empty.

IStack.top