Stack
A stack is a data structure that follows the Last-In-First-Out (LIFO) principle, representing a collection of elements.
typescript
// Create a stack of type Number
let stack = new Stack<Number>();成员变量
Stack.items : T[] |
| All elements in the stack. |
Stack.count : number |
| The number of elements in the stack. |
成员方法
Stack.get ( index : number ) : T|undefined |
| Get the value of an element based on the index value (index starts from 0). |
Stack.Push ( item : T ) : void |
| Pushes an element onto the stack. |
Stack.Pop ( ) : T|undefined |
| Pops an element from the stack. |
Stack.Peek ( ) : T|undefined |
| Get the element at the top of the stack without removing it. |
Stack.Clear ( ) : void |
| Clears all elements from the stack. |
Stack.Swap ( rhs : Stack<T> ) : void |
| Swaps the elements of the current stack with the elements of the target stack. |
Stack.toString ( ) : string |
| Returns the string representation of the current Stack object. |
Stack.forEach ( callback : Callback ) : void |
| Traverse the stack. |
