dastal - v5.0.0 / Stack
An ordered collection of elements in LIFO (last-in-first-out) order.
Typically LIFO refers to the insertion order of elements. However, it can refer to other types of ordering via a different implementation or a given comparator. FIFO stacks (e.g. queues) order elements in first-in-first-out order.
Regardless, a call to pop() should return the last element relative to its order. Every implementation should specify its ordering properties. Otherwise, insertion order should be used.
Name |
---|
T |
-
Collection<T>
↳ Stack
• Readonly
size: number
The number of elements in the collection.
src/collection/collection.ts:5
▸ [iterator](): Iterator
<T, any, undefined>
Iterator
<T, any, undefined>
node_modules/typescript/lib/lib.es2015.iterable.d.ts:51
▸ clear(): void
Removes all elements.
void
▸ peek(): undefined
| T
Retrieves, but does not remove, the top of the stack
undefined
| T
The element at the top of the stack or undefined
if empty.
▸ pop(): undefined
| T
Retrieves and removes the top of the stack
undefined
| T
The element at the top of the stack or undefined
if empty.
▸ push(element
): number
Inserts an element into the stack
Name | Type | Description |
---|---|---|
element |
T |
The element to be inserted |
number
The new size of the stack