Stacks provide 2 basic operations - push and pop. More...
Extended by: | |
Constructors: | |
Properties: | |
Methods: |
|
Stacks may also be efficiently indexed using an integer index, and elements may be inserted and removed. This allows stacks to also be used as a dynamic array (an array where the length can change), much like a C++ vector.
Returns an object that may be used to iterate backwards through the stack with a For EachIn loop.
Note that this does not actually reverse or modify the stack in any way.
Function
Main
()
Local
stk
:=
New
StringStack
stk.Push
"Hello"
stk.Push
"there"
stk.Push
"this"
stk.Push
"is"
stk.Push
"a"
stk.Push
"test"
Print
"Fowards:"
For
Local
t
$=
EachIn
stk
Print
t
Next
Print
""
Print
"Backwards:"
For
Local
t
$=
Eachin
stk.Backwards
()
Print
t
Next
End
Provides access to the underlying array used to store stack data.
Note: The length of this array may be greater than the actual length of the stack.
This method is used by the Contains and RemoveEach methods to determine element equality.
By default, this method compares lhs and rhs using the '=' operator. Extending classes may override this method to provide their own equality test.
Finds the index of the first element in the statch equal to value. The stack is searched starting at index start.
If not matching element is found, -1 is returned.
Finds the index of the last element in the statch equal to value.
If not matching element is found, -1 is returned.
Finds the index of the last element in the statch equal to value. The stack is searched starting at index start.
If not matching element is found, -1 is returned.
Returns the element at the specified index.
An index of 0 represents the bottom of the stack, and an index of Length-1 represents the top.
See also Set
Inserts value into the stack, shifting existing elements up if necessary.
This will increase the length of the stack by 1.
An index of 0 represents the bottom of the stack, and an index of length-1 represents the top.
Returns an enumerator object suitable for use with For EachIn loops.
Removes the item at the top of the stack and returns it.
This will decrease the length of the stack by 1.
If the stack is empty, the behaviour of Pop is undefined.
Pushes a value on the top of the stack.
This will increase the length of the stack by 1.
Pushes an array of values on the top of the stack starting with element 0.
This will increase the length of the stack by the length of the array.
Removes the value at the specified index from the stack, shifting existing elements down if necessary.
This will decrease the length of the stack by 1.
An index of 0 represents the bottom of the stack, and an index of length-1 represents the top.
Finds and removes all elements in the stack equal to value, shifting existing elements down if necessary.
This will decrease the length of the stack by the number of occurances of value in the stack.
Finds and removes the first element in the stack equal to value.
Finds and removes the last element in the stack equal to value.
Overwrites the existing value at index with value.
An index of 0 represents the bottom of the stack, and an index of stack length-1 represents the top.