Module Stack

Class for a stack.

This is an open structure, to make it easilly extensible. That is, the stack can be abused by manipulating it as an ordinary table. Items can be added to one end of a queue, and later removed from the same end. See also Wikipedias page on stack.

Functions

stack.new () Create a new instance.
stack:push () Push an item on the stack.
stack:pop () Pop an item off the stack.
stack:isEmpty () Is the stack empty.
stack:count () Count number of entries in stack.


Functions

stack.new ()
Create a new instance.

Parameters:

  • ... vararg arguments to be passed on

Returns:

self
stack:push ()
Push an item on the stack. This method can be called as a function.

Parameters:

  • item any

Returns:

self
stack:pop ()
Pop an item off the stack. This method can be called as a function.

Nicknames:

    drop

Returns:

any
stack:isEmpty ()
Is the stack empty. Checks by counting items whether stack is empty. This method can be called as a function.

Returns:

boolean
stack:count ()
Count number of entries in stack. This method can be called as a function.

Returns:

number
generated by LDoc TESTING