Next: , Up: queues   [Index]


37.1 Queue objects

Queues are implemented as doubly–linked lists of vector objects; each vector acts as buffer for contained objects; all the vectors have the same length.

The following syntactic bindings are exported by the library (vicare containers queues).

R6RS Record Type: <queue>

Record type representing a queue object. The <queue> type is non–generative and available for subtyping. In this documentation <queue> object arguments to functions are indicated as queue.

Function: make-queue
Function: make-queue buffer-length

Build and return a new <queue> object. The optional argument buffer-length must be a non–negative fixnum representing the number of slots in the internal object buffers; when not given, it defaults to 15.

Function: queue? obj

Return #t if obj is a record of type <queue>; otherwise return #f.

Function: queue obj

Build and return a <queue> object holding the given objects, which are pushed on the queue left to right from the rear side. The size of the internal buffers is set to the default.

(define D
  (queue 0 1 2))

(queue-front D)         ⇒ 0
(queue-rear  D)         ⇒ 2

Object properties

Function: queue-putprop queue key value
Function: $queue-putprop queue key value

Add a new property key to the property list of queue; key must be a symbol. If key is already set: the old entry is mutated to reference the new value.

Function: queue-getprop queue key
Function: $queue-getprop queue key

Return the value of the property key in the property list of queue; if key is not set: return #f. key must be a symbol.

Function: queue-remprop queue key
Function: $queue-remprop queue key

Remove the property key from the property list of queue; if key is not set: nothing happens. key must be a symbol.

Function: queue-property-list queue
Function: $queue-property-list queue

Return a new association list representing the property list of queue. The order of the entries is the same as the property creation order.

Other operations

Function: queue-hash queue
Function: $queue-hash queue

Return an exact integer to be used as hashtable key for queue. Hashtables having a <queue> as key can be instantiated as follows:

(make-hashtable queue-hash eq?)

Next: , Up: queues   [Index]