Difference between revisions of "Deque"
From OpenEUO
(Created page with "== Calling Pattern == Call local d = sl.deque() Results d is a deque closure == Closure Methods == * deque.back * deque.capacity * deque.clone * [[deque.front...") |
m (→Description) |
||
(One intermediate revision by the same user not shown) | |||
Line 56: | Line 56: | ||
== Description == | == Description == | ||
− | Calling deque returns a closure to a [http://en.wikipedia.org/wiki/Double-ended_queue | + | Calling deque returns a closure to a [http://en.wikipedia.org/wiki/Double-ended_queue double ended queue], a type of generic buffer. A deque can also operate as a first-in, first-out queue or a last-in, first-out queue (stack). Examples of each to be added. See the closure methods for more information. |
== See Also == | == See Also == |
Latest revision as of 16:24, 18 December 2010
Calling Pattern
Call
local d = sl.deque()
Results
d is a deque closure
Closure Methods
- deque.back
- deque.capacity
- deque.clone
- deque.front
- deque.peek
- deque.peekat
- deque.peekback
- deque.peekfront
- deque.pop
- deque.popback
- deque.popfront
- deque.push
- deque.pushback
- deque.pushfront
- deque.size
Example Usage
local a00 = sl.deque() for a01 = 1,10 do a00.pushback(a01,a01) end local a03 = a00.clone() for a02 = 1,20 do print(tostring(a02)..' '..tostring(a00.size())..' '..tostring(a00.pop())) end
--> 1 20 1 2 19 1 3 18 2 4 17 2 5 16 3 6 15 3 7 14 4 8 13 4 9 12 5 10 11 5 11 10 6 12 9 6 13 8 7 14 7 7 15 6 8 16 5 8 17 4 9 18 3 9 19 2 10 20 1 10
Description
Calling deque returns a closure to a double ended queue, a type of generic buffer. A deque can also operate as a first-in, first-out queue or a last-in, first-out queue (stack). Examples of each to be added. See the closure methods for more information.