dastal - v5.0.0 / ArrayStack
An implementation of the Stack interface using an array
Name |
---|
T |
- Stack<T>
• new ArrayStack<T>(elements?
)
Instantiate the stack.
Name |
---|
T |
Name | Type | Description |
---|---|---|
elements? |
Iterable <T> |
A set of elements to initialize the stack with. |
• get
size(): number
The number of elements in the collection.
number
▸ [iterator](): Iterator
<T, any, undefined>
Receive an iterator through the stack.
Note: Unexpected behavior can occur if the collection is modified during iteration.
Iterator
<T, any, undefined>
An iterator through the stack
▸ clear(): void
Removes all elements.
void
▸ peek(): undefined
| T
Retrieves, but does not remove, the top of the stack
undefined
| T
▸ pop(): undefined
| T
Retrieves and removes the top of the stack
undefined
| T
▸ push(element
): number
Inserts an element into the stack
Name | Type |
---|---|
element |
T |
number