Double-ended queue implemented with two backing arrays.
Construct with an element schema in front of the module name, for example Int32 Deque.
CONTAINER: container marker field.DEQUE: deque marker field.elementType: Ref to the element schema.head: front-side backing array.tail: back-side backing array.iter (-- iter): iterates stored items in logical deque order.size (-- count): returns the current item count.pushBack (item --): appends one item at the back.pushFront (item --): prepends one item at the front.popBack (--): removes the last item.popFront (--): removes the first item.back (-- ref): returns Ref to the last item.front (-- ref): returns Ref to the first item.at (ordinal -- ref): returns Ref to the item at the zero-based ordinal.clear (--): removes all items while preserving the backing-array capacities.release (--): releases both backing arrays.swapBuffers (from to --): moves half-buffer contents during internal rebalancing when one side becomes empty.head; the logical back is formed by the end of tail.at 0 returns the same item as front.at (size 1 -) returns the same item as back.iter traverses items in logical deque order, not in the physical order of head or tail.front, back, and at return references into the current backing arrays.front, back, popFront, and popBack require one non-empty deque.at requires one ordinal in the range 0 .. size 1 -."Deque" use
"String" use
"control" use
{} Int32 {} [
d: Int32 Deque;
10 @d.pushBack
20 @d.pushFront
30 @d.pushBack
("front=" @d.front new LF
"back=" @d.back new LF
"at1=" 1 @d.at new LF) printList
@d.popFront
("size=" d.size LF
"front2=" @d.front new LF) printList
0
] "main" exportFunction
front=20
back=30
at1=10
size=2
front2=10
"Deque" use
"String" use
"control" use
{} Int32 {} [
d: Int32 Deque;
10 @d.pushBack
20 @d.pushFront
30 @d.pushBack
it: @d.iter;
item0: ok0: @it.next;;
item1: ok1: @it.next;;
item2: ok2: @it.next;;
item3: ok3: @it.next;;
("ok0=" ok0 LF
"v0=" item0 new LF
"ok1=" ok1 LF
"v1=" item1 new LF
"ok2=" ok2 LF
"v2=" item2 new LF
"ok3=" ok3 LF) printList
0
] "main" exportFunction
ok0=TRUE
v0=20
ok1=TRUE
v1=10
ok2=TRUE
v2=30
ok3=FALSE