Deque

Double-ended queue implemented with two backing arrays.


Deque

Construct with an element schema in front of the module name, for example Int32 Deque.

Fields

Public methods

Internal helper


Order and returned references


Invalid operations


Examples

Runtime example: front, back, and ordinal access

"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

Expected Output

front=20
back=30
at1=10
size=2
front2=10

Runtime example: iteration order

"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

Expected Output

ok0=TRUE
v0=20
ok1=TRUE
v1=10
ok2=TRUE
v2=30
ok3=FALSE

See also