Skip to content

BoundedStack

Defined in: packages/data/src/stack/bounded-stack.ts:21

A LIFO stack that holds at most capacity items and throws once full.

T extends DefinedValue

The type of elements in the stack.

new BoundedStack<T>(iterable, options): BoundedStack<T>

Defined in: packages/data/src/stack/bounded-stack.ts:27

Iterable<T, any, any> | undefined

BoundedStackOptions<T>

BoundedStack<T>

readonly capacity: number

Defined in: packages/data/src/stack/bounded-stack.ts:25

The maximum number of elements the collection can hold.

Note: Infinity is not a legal value here — an unbounded type omits this mixin.

IBounded.capacity

[iterator](): Iterator<T>

Defined in: packages/data/src/stack/bounded-stack.ts:37

Iterator<T>

IStack.[iterator]


clear(): void

Defined in: packages/data/src/stack/bounded-stack.ts:41

Removes all elements from the collection.

void

IStack.clear


count(): number

Defined in: packages/data/src/stack/bounded-stack.ts:45

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/bounded-stack.ts:76

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/bounded-stack.ts:56

Same as IStack.push, but throws once the stack is full.

T

void

If the operation would exceed the stack’s capacity.

IStack.push

IStack.push


pushAll(items): void

Defined in: packages/data/src/stack/bounded-stack.ts:70

Same as IStack.pushAll, but throws once the stack is full. Nothing is added when it throws — the check is made against the whole batch.

readonly T[]

void

If the operation would exceed the stack’s capacity.

IStack.pushAll

IStack.pushAll


top(): T | undefined

Defined in: packages/data/src/stack/bounded-stack.ts:80

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