Next: , Up: ideques   [Index]


48.1 The common deques API

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

Record Type: <ideque>

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

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

Constructor on <ideque>: make-ideque empty? front rear push-front! push-rear! pop-front! pop-rear!

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

(define-record-type <ideque-chain>
  (parent <ideque>)
  (protocol
    (lambda (make-ideque)
      ---))
  ---)

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

empty?

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

front

A function accepting as single argument the <ideque> instance itself. It must return the first object, at the front of the <ideque>.

rear

A function accepting as single argument the <ideque> instance itself. It must return the last object, at the rear of the <ideque>.

push-front!

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

push-rear!

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

pop-front!

A function accepting as single argument the <ideque> instance itself. It must remove and return the first object, from the front of the <ideque>.

pop-rear!

A function accepting as single argument the <ideque> instance itself. It must remove and return the last object, from the rear of the <ideque>.

Function: ideque? obj

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

Function: ideque-empty? ideque

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

Function: ideque-front ideque

Return the first object, on the front of ideque.

Function: ideque-rear ideque

Return the last object, on the rear of ideque.

Function: ideque-push-front! ideque obj

Push obj on the front of ideque. Return unspecified values.

Function: ideque-push-rear! ideque obj

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

Function: ideque-pop-front! ideque

Remove and return the first object, from the front of ideque.

Function: ideque-pop-rear! ideque

Remove and return the last object, from the rear of ideque.


Next: , Up: ideques   [Index]