Get:
PUBLIC PROC [fifo:
FIFO]
RETURNS [data:
REF] = {
IF fifo.head=NIL THEN RETURN [NIL];
data ← fifo.head.data;
fifo.head ← fifo.head.next;
fifo.size ← fifo.size-1;
IF fifo.head=NIL THEN fifo.tail ← NIL
};
Put:
PUBLIC PROC [fifo:
FIFO, data:
REF] = {
fifoEl: FIFOElement ← NEW [FIFOElementRec];
fifoEl.data ← data;
IF fifo.tail=
NIL
THEN {fifo.head ← fifo.tail ← fifoEl; fifo.size ← 1}
ELSE {fifo.tail.next ← fifoEl; fifo.tail ← fifoEl; fifo.size ← fifo.size+1}
};