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


46.7 Chains as stacks

The library (vicare containers istacks chains) provides a concrete implementation of the <istack> type using a chain as storage; chains are defined by the library (vicare containers chains), Chains of objects. Usage example:

(import (vicare)
  (vicare containers chains)
  (vicare containers istacks)
  (vicare containers istacks chains))

(define S
  (make-istack-chain (chain)))

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

Record Type: <istack-chain>

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

Function: make-istack-chain chain

Build and return a new instance of <istack-chain>. The argument chain must be null or an instance of type <chain-link> as defined by the library (vicare containers chains).

Function: istack-chain? obj

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

Function: istack-chain-first-pair istack

Return null or the first link of the chain used as storage in the <istack-chain> instance istack.