RefQ.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Swinehart, October 22, 1985 3:22:50 pm PDT
Polle Zellweger (PTZ) December 10, 1985 6:00:49 pm PST
RefQ: CEDAR DEFINITIONS = {
Routines for manipulating a simple one-way Queue of REF's (simulates tail-pointer, since queues are expected to be short).
Monitors must be provided by clients. Clients can read the queue as a LIST OF REF, which it is.
Queue: TYPE = LIST OF REF;
Enqueue:
PROC [queue: Queue, value:
REF]
RETURNS [qPlusValue: Queue];
Adds the element to the tail of the queue.
EnqueueQ:
PROC [queue: Queue, newQ:
LIST
OF
REF]
RETURNS [longerQ: Queue];
Appends the list to the tail of the queue.
DequeueMode: TYPE = { remove, truncate };
Dequeue:
PROC [queue: Queue, subqueue: Queue←
NIL, mode: DequeueMode←remove]
RETURNS [shorterQ: Queue];
Removes one or more elements. subqueue.first is the element to be removed.
mode:
remove — remove subqueue.first from the queue.
truncate, removes all values from the head of the queue to and including the indicated element.
MapType: TYPE = PROC[subqueue: Queue] RETURNS[quit: BOOL←FALSE];
Map:
PROC[queue: Queue, p: MapType]
RETURNS[quit:
BOOL];
Applies p to each sublist of queue. Client is also allowed to do this directly. Returns TRUE iff some call to p returns TRUE
}.
Polle Zellweger (PTZ) December 10, 1985 6:00:49 pm PST
changes to: MapType