dangraph / Exports / utils/danStack / DanStack
utils/danStack.DanStack
DanStack is a simple class implementing Stackable interface
| Name |
|---|
T |
Stackable<T>
• new DanStack<T>(): DanStack<T>
The public class constructor
| Name |
|---|
T |
DanStack<T>
• Private _list: T[]
▸ clear(): void
Clear all stack's elements We use the 'splice' method of the private member '_list'
void
▸ isEmpty(): boolean
Check if the stack is empty We use the 'length' method of the private member '_list' to check the number of elements present: if the number is less than 1, the stack is empty
boolean
true if the stack is empty; it returns false is the stack is not empty
▸ peek(): undefined | T
Get the value from the top of the stack but do not remove it from the stack itself
undefined | T
the element on top of the stack if the stack is not empty; conversely it returns undefined
▸ pop(): undefined | T
Get the value from the top of the stack and remove it from the stack itself We use the 'pop' method of the private member '_list'
undefined | T
the element on top of the stack if the stack is not empty; conversely it returns undefined
▸ push(val): void
Insert a value to the top of the stack We use the 'push' method of the private member '_list'
| Name | Type | Description |
|---|---|---|
val |
T |
the value to be pushed inside the stack |
void