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:

  • self Stack
  • stack table The initial stack. The end of the table is assumed to be the top of the stack. (default {})
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:

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:

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:

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:

Returns:

    Stack The cloned Stack.
generated by LDoc 1.4.3 Last updated 2016-07-26 17:10:04