#
cp.collect.Queue
A "double-ended queue" implementation. This allows pushing and popping values to the left or right side of the queue. This can be used for classic 'stack' and 'queue' uses - for a stack, push and pop from one end, for a queue, push and pop from opposite ends.
#
will always return the size of the queue.
The left-most item in the queue wil always be at index 1
, the right-most
will be at index #
.
You can iterate via ipairs
, but as with all tables, the queue contains any
nil
values, it will stop at that point. To iterate the whole queue, you
need to use the #
operator. Eg:
local q = Queue(1, nil, 3)
for i,v in ipairs(q) do print(v) end -- Outputs "1"
for i = 1, #q do print(v) end -- Outputs "1", "nil", "3"
#
API Overview
Functions - API calls offered directly by the extension
contains len peekLeft peekRight popLeft popRight pushLeft pushRight removeItem removeItem
Constructors - API calls which return an object, typically one that offers API methods
new
Methods - API calls which can only be made on an object returned by a constructor
contains len peekLeft peekRight popLeft popRight pushLeft pushRight