std.collections.Stack.Swap - nitrologic/monkey2 GitHub Wiki

std::std.collections.std.collections.Stack.Swap

Method Swap:Void( index1:monkey:monkey.types.Int,index2:monkey:monkey.types.Int )
Method Swap:Void( stack:std:std.collections.Stack )

Swaps 2 elements in the stack, or 2 stacks.

This method can be used to either swap 2 elements in the stack, or 2 entire stacks.

In debug builds, a runtime error will occur if index1 or index2 is out of range.

Swapping entire stacks simply swaps the storage arrays and lengths of the 2 stacks, and is therefore very fast.

Parameters
index1 index1 The index of the first element.
index2 index2 The index of the second element.
stack stack The stack to swap with.