Library / Collections / Sequences / Queue
Queue
Defines the Queue[T] class per ENVZN_CONSTITUTION §Queue.
Constructors 2
INIT()default constructor
INIT(int64 presized)
for presized Stack allocation
Methods 5
OVERRIDE METHOD clone() RETURNS Queue[T]reads
Deep copy. Each element is cloned via T->clone(); T must
implement Cloneable when T is a class type.
For T IS Inoperative (opaque only today): returns
an empty Array — Inoperative values are opaque so we can't
preserve them on clone.
MODIFY METHOD enqueue(T value) RETURNS STATUSmodifies
Add value at the back of the queue. Per §10.2 the bare-named
form consumes the source — value is moved through Array's
owning append into the queue's backing.
MODIFY METHOD enqueueCopy(REFERENCE T value) RETURNS STATUSmodifies
Deep-copy form of enqueue. value stays valid for the caller;
the clone is what the backing array stores.
OVERRIDE METHOD peek() RETURNS | REFERENCE Treads
Remove and return the front element. Pipe-XOR: SUCCESS populates
value; FAILURE when the queue is empty. O(n) — depends on Array
providing popFirst() with move-out semantics for class T.
FIFO peek — the FRONT element, which is NOT what Stack.peek()
returns.
Queue EXTENDS Stack, and Stack's peek() is LIFO: it forwards to
peekLast(). Inherited unchanged, a Queue reported its most recently
ENQUEUED element as its front — dequeue() (which uses popFirst) and
peek() disagreed about which end the queue's head is. queueSmoke caught
it as "expected 11, got 22".
OVERRIDE is required here (W7020): this reimplements a CONCRETE inherited method rather than fulfilling an abstract contract.
MODIFY METHOD dequeue() RETURNS | Tmodifies