Version: 5.3
1 Imperative Queues
(require data/queue) |
This module provides a simple mutable queue representation, first-in/first-out only. Operations on queues mutate it in a thread-unsafe way.
procedure
(make-queue) → queue/c
Produces an empty queue.
Adds an element to the back of a queue.
procedure
q : nonempty-queue/c
Removes an element from the front of a nonempty queue, and returns that
element.
Examples: | ||||||||||||||||||||
|
procedure
(queue->list queue) → (listof any/c)
queue : queue/c
Returns an immutable list containing the elements of the queue
in the order the elements were added.
Examples: | ||||||||||||||||
|
procedure
(queue-length queue) → integer?
queue : queue/c
Returns the number of elements in the queue.
Examples: | |||||||||||||||||||
|
procedure
(queue-empty? q) → boolean?
q : queue/c
Recognizes whether a queue is empty or not.
Examples: | ||||||||||||||||
|
This predicate recognizes queues.
Examples: | ||||
|
Returns a sequence whose elements are the elements of
queue.
value
value
These contracts recognize queues; the latter requires the queue to
contain at least one value.