Next: , Previous: , Up: istacks   [Index]

46.6 Deques as stacks

The library (vicare containers istacks deques) provides a concrete implementation of the <istack> type using a deque as storage; deques are defined by the library (vicare containers deques), Double–ended queues of objects. Usage example:

(import (vicare)
  (vicare containers deques)
  (vicare containers istacks)
  (vicare containers istacks deques))

(define S
  (make-istack-deque (deque)))

(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 deques).

Record Type: <istack-deque>

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

Function: make-istack-deque deque

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

Function: istack-deque? obj

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