Previous: , Up: istacks   [Index]


46.8 Dynamic arrays as stacks

The library (vicare containers istacks dynamic-arrays) provides a concrete implementation of the <istack> 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 istacks)
  (vicare containers istacks dynamic-arrays))

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

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

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

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

Record Type: <istack-dynamic-array>

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

Function: make-istack-dynamic-array arry

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

Function: istack-dynamic-array? obj

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