Class Stack
A standard Stack data structure.
Info:
- License: MIT
- Author: Richard Voelker
Methods
Stack.new (self[, stack={}]) | Create a new Stack. |
Stack.Push (self, el) | Push an element onto the top of the Stack. |
Stack.Pop (self) | Remove an element from the top of the Stack. |
Stack.Peek (self) | Returns the top element from the Stack without removing it. |
Stack.IsEmpty (self) | Returns whether or not the Stack is empty (length of the Stack is 0). |
Stack.Clone (self) | Performs a shallow clone (new Stack is created, but individual elements of the Stack are the same) of this Stack. |
Methods
- Stack.new (self[, stack={}])
-
Create a new Stack.
Parameters:
- Stack.Push (self, el)
-
Push an element onto the top of the Stack.
Parameters:
- self Stack
- el The element to add.
- Stack.Pop (self)
-
Remove an element from the top of the Stack.
Parameters:
- self Stack
Returns:
The top element of the Stack, or nil if the Stack is
empty.
- Stack.Peek (self)
-
Returns the top element from the Stack without removing it.
Parameters:
- self Stack
Returns:
The top element of the Stack, or nil if the Stack is
empty.
- Stack.IsEmpty (self)
-
Returns whether or not the Stack is empty (length of the
Stack is 0).
Parameters:
- self Stack
Returns:
-
bool
True if the Stack is empty, false otherwise.
- Stack.Clone (self)
-
Performs a shallow clone (new Stack is created, but
individual elements of the Stack are the same) of this Stack.
Parameters:
- self Stack
Returns:
-
Stack
The cloned Stack.