Previous: , Up: iqueues   [Index]


47.5 Dynamic arrays as queues

The library (vicare containers iqueues dynamic-arrays) provides a concrete implementation of the <iqueue> type using a dynamic array as storage; dynamic arrays are defined by the library (vicare containers dynamic-arrays), Dynamic arrays. Usage example:

(import (vicare)
  (vicare containers dynamic-arrays)
  (vicare containers iqueues)
  (vicare containers iqueues dynamic-arrays))

(define S
  (make-iqueue-dynamic-array (dynamic-array)))

(iqueue-push! S 0)
(iqueue-push! S 1)
(iqueue-push! S 2)

(iqueue-top  S)         ⇒ 2
(iqueue-pop! S)         ⇒ 2
(iqueue-pop! S)         ⇒ 1

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

Record Type: <iqueue-dynamic-array>

Record type implementing an <iqueue>, of which it is a subtype.

Function: make-iqueue-dynamic-array arry

Build and return a new instance of <iqueue-dynamic-array>. The argument arry must be an instance of type <dynamic-array> as defined by the library (vicare containers dynamic-arrays).

Function: iqueue-dynamic-array? obj

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