Skip to content

Std collections stack

std:std.collections.Stack

Class Stack Implements IContainer#

The Stack class provides suport for dynamic arrays.

A stack is an 'array like' container that grows dynamically as necessary.

It is very cheap to add values to the end of a stack, but insertion or removal of values requires higher indexed values to be 'shifted' up or down so is slower.

Stacks implement the IContainer interface so can be used with Eachin loops.

Structs
BackwardsIterator The Stack.BackwardsIterator struct.
Iterator The Stack.Iterator struct.
Constructors
New Creates a new stack.
Properties
Capacity Gets the storage capacity of the stack. (read only)
Data Gets the underlying array used by the stack. (read only)
Empty Checks if the stack is empty. (read only)
Length Gets the number of values in the stack. (read only)
Top Gets the top element of the stack (read only)
Methods
Add Adds a value to the end of the stack.
AddAll Adds the values in an array or container to the end of the stack.
All Gets an iterator for visiting stack values.
Append (Deprecated: Use AddAll.)
Backwards Gets an iterator for visiting stack values in reverse order.
Clear Clears the stack.
Compact Compacts the stack
Contains Checks if the stack contains a value.
Erase Erases an element at an index in the stack.
FindIndex Finds the index of the first matching value in the stack.
FindLastIndex Finds the index of the last matching value in the stack.
Get Gets the value of a stack element.
Insert Inserts a value at an index in the stack.
Join Joins the values in a string stack.
Pop Pops the top element off the stack and returns it.
Push Pushes a value on the stack.
Remove Finds and removes the first matching value from the stack.
RemoveEach Finds and removes each matching value from the stack.
RemoveIf Removes all values int the stack that fulfill a condition.
RemoveLast Finds and removes the last matching value from the stack.
Reserve Reserves stack storage capacity.
Resize Resizes the stack.
Set Sets the value of a stack element.
Slice Returns a range of elements from the stack.
Sort Sorts the stack.
Swap Swaps 2 elements in the stack, or 2 stacks.
ToArray Converts the stack to an array.
Operator [] Gets the value of a stack element.
Operator []= Sets the value of a stack element.