Stack<T>

Last-in-first-out (LIFO) data structure.

Type Constraints: T Constrains None

xxml
Language::Collections

Methods

MethodParametersReturnsDescription
ConstructorStack<T>^Create empty stack
pushelement: T^NonePush onto top
popT^Remove and return top
peekT^View top without removing
sizeInteger^Element count
isEmptyBool^Check if empty
clearNoneRemove 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"

See Also