Stack<T>
Last-in-first-out (LIFO) data structure.
Type Constraints: T Constrains None
xxml
Language::CollectionsMethods
| Method | Parameters | Returns | Description |
|---|---|---|---|
| Constructor | — | Stack<T>^ | Create empty stack |
| push | element: T^ | None | Push onto top |
| pop | — | T^ | Remove and return top |
| peek | — | T^ | View top without removing |
| size | — | Integer^ | Element count |
| isEmpty | — | Bool^ | Check if empty |
| clear | — | None | Remove all elements |
Examples
Stack Usage
xxml
Instantiate Collections::Stack<String>^ As <history> = Collections::Stack@String::Constructor();
Run history.push(String::Constructor("page1"));
Run history.push(String::Constructor("page2"));
Instantiate String^ As <current> = history.pop(); // "page2"