Difference between revisions of "Deque"

From OpenEUO
Jump to: navigation, search
m (Description)
m (Description)
 
Line 56: Line 56:
 
== Description ==
 
== Description ==
  
Calling deque returns a closure to a [http://en.wikipedia.org/wiki/Double-ended_queue double ended queue]. See the closure methods for more information.
+
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

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.

See Also