Next: , Up: stacks   [Index]


36.1 Stack objects

Stacks are implemented as doubly–linked lists of vector objects; each vector acts as buffer for contained objects; all the vectors have the same length.

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

R6RS Record Type: <stack>

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

Function: make-stack
Function: make-stack buffer-length

Build and return a new <stack> object. The optional argument buffer-length must be a non–negative fixnum representing the number of slots in the internal object buffers; when not given, it defaults to 15.

Function: stack? obj

Return #t if obj is a record of type <stack>; otherwise return #f.

Function: stack obj

Build and return a <stack> object holding the given objects, which are pushed on the stack right–to–left from the bottom side. The size of the internal buffers is set to the default.

(define D
  (stack 0 1 2))

(stack-top D)         ⇒ 0

Object properties

Function: stack-putprop stack key value
Function: $stack-putprop stack key value

Add a new property key to the property list of stack; key must be a symbol. If key is already set: the old entry is mutated to reference the new value.

Function: stack-getprop stack key
Function: $stack-getprop stack key

Return the value of the property key in the property list of stack; if key is not set: return #f. key must be a symbol.

Function: stack-remprop stack key
Function: $stack-remprop stack key

Remove the property key from the property list of stack; if key is not set: nothing happens. key must be a symbol.

Function: stack-property-list stack
Function: $stack-property-list stack

Return a new association list representing the property list of stack. The order of the entries is the same as the property creation order.

Other operations

Function: stack-hash stack
Function: $stack-hash stack

Return an exact integer to be used as hashtable key for stack. Hashtables having a <stack> as key can be instantiated as follows:

(make-hashtable stack-hash eq?)

Next: , Up: stacks   [Index]