Module Queue
Class for a queue.
This is an open structure, to make it easilly extensible. That is, the queue 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 opposite end. See also Wikipedias page on queue.
Functions
queue.new () | Create a new instance. |
queue:enqueue () | Enqueue an item into the queue. |
queue:dequeue () | Dequeue an item out of the queue. |
queue:isEmpty () | Is the queue empty. |
queue:count () | Count number of entries in queue. |
Functions
- queue.new ()
-
Create a new instance.
Parameters:
- ... vararg arguments to be passed on
Returns:
self - queue:enqueue ()
-
Enqueue an item into the queue.
This method can be called as a function.
Nicknames:
-
unshift
Parameters:
- item any
Returns:
self - queue:dequeue ()
-
Dequeue an item out of the queue.
This method can be called as a function.
Nicknames:
-
shift
Returns:
any - queue:isEmpty ()
-
Is the queue empty.
Checks by counting items whether queue is empty.
This method can be called as a function.
Returns:
boolean - queue:count ()
-
Count number of entries in queue.
This method can be called as a function.
Returns:
number