Class ArrayStack
A doubly-linked, last in first out Stack of items.
Implements a Stack as an ArrayList, providing the same performance characteristics as the ArrayList.
ArrayStack implements all optional Stack and Collection methods.
Implements: Stack, Collection, Enumerable
Functions
| ArrayStack.new(collection) | Creates a new ArrayStack. |
Methods
| ArrayStack:Add(item) | Adds an item to the ArrayStack. |
| ArrayStack:AddAll(items) | Adds all provided items to the ArrayStack. |
| ArrayStack:Clear() | Removes everything from the ArrayStack. |
| ArrayStack:Contains(item) | Determines whether the ArrayStack contains an item. |
| ArrayStack:ContainsAll(items) | Determines whether the ArrayStack contains all of the provided items. |
| ArrayStack:ContainsAny(items) | Determines whether the ArrayStack contains any of the provided items. |
| ArrayStack:Count() | Gets the number of items in the ArrayStack. |
| ArrayStack:Empty() | Determines whether the ArrayStack has no elements. |
| ArrayStack:Enumerator() | Creates an enumerator for the ArrayStack. |
| ArrayStack:Last() | Gets the item at the end of the ArrayStack. |
| ArrayStack:Pop() | Gets an item from the end and removes that item from the ArrayStack. |
| ArrayStack:Push(item) | Adds an item to the end of the ArrayStack. |
| ArrayStack:Remove(item) | Removes the specified item from the ArrayStack. |
| ArrayStack:RemoveAll(items) | Removes all provided items from the ArrayStack. |
| ArrayStack:RetainAll(items) | Removes all items except those provided from the ArrayStack. |
| ArrayStack:ToArray() | Creates a new array indexed table of this ArrayStack. |
| ArrayStack:ToTable() | Creates a new table of this ArrayStack. |
Functions
Methods- ArrayStack.new(collection)
-
Creates a new ArrayStack.
Creates a ArrayStack copy of the provided Collection or array-indexed
table if one is provided, otherwise creates an empty ArrayStack.
Parameters:
- collection the Collection or table to copy
Returns:
-
the new ArrayStack
Methods
- ArrayStack:Add(item)
-
Adds an item to the ArrayStack.
Inherited from:
Parameters:
- item the item to add
Returns:
-
true always since the ArrayStack is always changed
- ArrayStack:AddAll(items)
-
Adds all provided items to the ArrayStack.
Adds items provided in another Collection in an arbitrary, deterministic
order. The order is the same as the order of enumeration.
Inherited from:
Parameters:
- items the Collection of items to add to this ArrayStack
Returns:
-
true always since the ArrayStack is always changed
- ArrayStack:Clear()
-
Removes everything from the ArrayStack.
Inherited from:
- ArrayStack:Contains(item)
-
Determines whether the ArrayStack contains an item.
Inherited from:
Parameters:
- item the item to locate in the ArrayStack
Returns:
-
true if the item is in the ArrayStack, false otherwise
- ArrayStack:ContainsAll(items)
-
Determines whether the ArrayStack contains all of the provided items.
Checks for items provided in another Collection in an arbitrary,
deterministic order. The order is the same as the order of enumeration.
Inherited from:
Parameters:
- items the Collection of items to locate in this ArrayStack
Returns:
-
true if all items are in the ArrayStack, false otherwise
- ArrayStack:ContainsAny(items)
-
Determines whether the ArrayStack contains any of the provided items.
Checks for items provided in another Collection in an arbitrary,
deterministic order. The order is the same as the order of enumeration.
Inherited from:
Parameters:
- items the Collection of items to locate in this ArrayStack
Returns:
-
true if any items are in the ArrayStack, false otherwise
- ArrayStack:Count()
-
Gets the number of items in the ArrayStack.
Inherited from:
Returns:
-
the number of items
- ArrayStack:Empty()
-
Determines whether the ArrayStack has no elements.
Inherited from:
Returns:
-
true if the ArrayStack empty, false otherwise
- ArrayStack:Enumerator()
-
Creates an enumerator for the ArrayStack.
The enumerator can be used directly in a generic for loop similar to pairs
or ipairs.
Inherited from:
Returns:
-
the enumerator generator
- ArrayStack:Last()
-
Gets the item at the end of the ArrayStack.
Inherited from:
Returns:
-
the last item in the ArrayStack
Raises:
if the ArrayStack is empty - ArrayStack:Pop()
-
Gets an item from the end and removes that item from the ArrayStack.
Shifts other elements to fill the gap left.
Inherited from:
Returns:
-
the item in the ArrayStack
Raises:
if the ArrayStack is empty - ArrayStack:Push(item)
-
Adds an item to the end of the ArrayStack.
Inherited from:
Parameters:
- item the item to add
Returns:
-
true always since the ArrayStack is always changed
- ArrayStack:Remove(item)
-
Removes the specified item from the ArrayStack.
Removes only a single item. If there are multiple of the same item, it
removes only the first encountered.
When an item is removed any others are shifted to fill the gap left at the index of removal.
Inherited from:
Parameters:
- item the item to remove from the ArrayStack
Returns:
-
true if the ArrayStack changed as a result, false otherwise
- ArrayStack:RemoveAll(items)
-
Removes all provided items from the ArrayStack.
Removes each instance of a provided item only once for each time provided.
If there are multiple of the same item in this Queue, it removes only
the first encountered for each provided.
Inherited from:
Parameters:
- items the Collection of items to remove from this ArrayStack
Returns:
-
true if the ArrayStack changed as a result, false otherwise
- ArrayStack:RetainAll(items)
-
Removes all items except those provided from the ArrayStack.
Retains only the items contained in the specified Collection. If there are
duplicates they are all kept.
Inherited from:
Parameters:
- items the Collection of items to retain in this ArrayStack
Returns:
-
true if the ArrayStack changed as a result, false otherwise
- ArrayStack:ToArray()
-
Creates a new array indexed table of this ArrayStack.
The order of the array is the same as the order of the ArrayStack. The first
element of the Stack will get index 1 and so on.
Inherited from:
Returns:
-
the array indexed table
- ArrayStack:ToTable()
-
Creates a new table of this ArrayStack.
ArrayStacks, being ordered and linear, need no indices that are not array
indices, so this provides a table with all the same array indices as
ToArray.
Inherited from:
Returns:
-
the table