std:std.collections.Stack<T>.Swap

Method Swap:Void( index1:Int,index2:Int )
Method Swap:Void( stack:Stack<T> )

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.