Next: , Previous: , Up: Data Structures   [Contents][Index]


7.1.18 Queues

(require 'queue)

A queue is a list where elements can be added to both the front and rear, and removed from the front (i.e., they are what are often called dequeues). A queue may also be used like a stack.

Function: make-queue

Returns a new, empty queue.

Function: queue? obj

Returns #t if obj is a queue.

Function: queue-empty? q

Returns #t if the queue q is empty.

Procedure: queue-push! q datum

Adds datum to the front of queue q.

Procedure: enqueue! q datum

Adds datum to the rear of queue q.

Procedure: dequeue! q
Procedure: queue-pop! q

Both of these procedures remove and return the datum at the front of the queue. queue-pop! is used to suggest that the queue is being used like a stack.

All of the following functions raise an error if the queue q is empty.

Procedure: dequeue-all! q

Removes and returns (the list) of all contents of queue q.

Function: queue-front q

Returns the datum at the front of the queue q.

Function: queue-rear q

Returns the datum at the rear of the queue q.