/* To push a node onto the end of the queue. */ push: procedure (tail); declare tail handle (node), t handle (node); t = new(:node:); get (t => value); if tail ^= bind(:null, node:) then tail => link = t; /* If the queue was non-empty, points the tail of the queue */ /* to the new node. */ tail = t; /* Point "tail" at the end of the queue. */ tail => link = bind(:node, null:); end push; /* To pop a node from the head of the queue. */ pop: procedure (head, val); declare head handle (node), val fixed binary; if head = bind(:node, null:) then signal error; val = head => value; head = head => pointer; /* pops the top node. */ if head = bind(:node, null:) then tail = head; /* (If the queue is now empty, make tail null also.) */ end pop; /* Queue status: the EMPTY function, returns true for empty queue. */ empty: procedure (h) returns (bit(1)); declare h handle (Node); return (h = bind(:Node, null:) ); end empty;