1 Imperative Queues
(require data/queue) | package: base |
This module provides a simple mutable queue representation, providing first-in/first-out semantics.
Operations on queues mutate it in a thread-unsafe way.
procedure
(make-queue) → queue?
This takes constant time, independent of the number of elements in q.
procedure
(enqueue-front! q v) → void?
q : queue? v : any/c
This takes constant time, independent of the number of elements in q.
procedure
q : non-empty-queue?
This takes constant time, independent of the number of elements in q.
Examples: | ||||||||||||||||||||||||||||||||||
|
This takes time proportional to the number of elements in q (assuming that pred? takes constant time, independent of the number of elements in q). It does not allocate and it calls pred? exactly once for each element of q.
Examples: | ||||||||||||||||||||||
|
procedure
(queue->list queue) → (listof any/c)
queue : queue?
This takes time proportional to the number of elements in q.
Examples: | ||||||||||||||||
|
procedure
(queue-length queue) → exact-nonnegative-integer?
queue : queue?
This takes constant time, independent of the number of elements in q.
Examples: | |||||||||||||||||||
|
procedure
(queue-empty? q) → boolean?
q : queue?
This takes constant time, independent of the number of elements in q.
Examples: | ||||||||||||||||
|
This takes constant time, independent of the size of the argument v.
Examples: | ||||
|
procedure
(non-empty-queue? v) → boolean?
v : any/c
This takes constant time, independent of the size of the argument v.
Examples: | |||||||||
|
value
value