Next: , Up: iqueues   [Index]


47.1 The common queues API

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

Record Type: <iqueue>

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

<iqueue> is an “abstract” type: it must not be instantiated directly, rather a subtype of <iqueue> must be defined implementing the required functions.

Constructor on <iqueue>: make-iqueue empty? top push! pop!

When we derive a type from <iqueue> and we specify a protocol: this is the closure object used as argument for the protocol function.

(define-record-type <iqueue-list>
  (parent <iqueue>)
  (protocol
    (lambda (make-iqueue)
      ---))
  ---)

Its arguments must be functions implementing the methods for the concrete queue:

empty?

A function accepting as single argument the <iqueue> instance itself. It must return #t if the queue is empty; otherwise it must return #f.

top

A function accepting as single argument the <iqueue> instance itself. It must return the top object at the front of the <iqueue>.

push!

A function accepting two arguments: the <iqueue> instance itself and an object. It must push the object on the rear of the <iqueue>; it can return unspecified values.

pop!

A function accepting as single argument the <iqueue> instance itself. It must remove and return the top object on the front of the <iqueue>.

Function: iqueue? obj

Return #t if obj is an instance of <iqueue>; otherwise return #f.

Function: iqueue-empty? iqueue

Return #t if iqueue is empty; otherwise return #f.

Function: iqueue-top iqueue

Return the top object on the front of iqueue.

Function: iqueue-push! iqueue obj

Push obj on the rear of iqueue. Return unspecified values.

Function: iqueue-pop! iqueue

Remove and return the top object on the front of iqueue.


Next: , Up: iqueues   [Index]