Next: , Previous: , Up: queues   [Index]


37.8 Converting queues to other objects

The following syntactic bindings are exported by the library (vicare containers queues). The syntactic bindings whose name is prefixed with $ are unsafe operations: they do not validate their arguments before accessing them.

Function: queue->list queue
Function: $queue->list queue
Function: list->queue list
Function: $list->queue list

Convert to and from a queue and a proper list. Objects from the list are pushed on the queue left–to–right from the rear side.

(define D
  (list->queue '(0 1 2)))

(queue-front D)         ⇒ 0
(queue-rear  D)         ⇒ 2
(queue->list D)         ⇒ (0 1 2)
Function: queue->vector queue
Function: $queue->vector queue
Function: vector->queue vector
Function: $vector->queue vector

Convert to and from a queue and a vector. Objects from the vector are pushed on the queue left–to–right from the rear side.

(define D
  (vector->queue '#(0 1 2)))

(queue-front   D)       ⇒ 0
(queue-rear    D)       ⇒ 2
(queue->vector D)       ⇒ #(0 1 2)