Next: dynamic arrays inspection, Up: dynamic arrays [Index]
Dynamic arrays are implemented as built–in vector objects of which only a subrange of slots is used:
left span used slots right span |...........|...................|...........| |---|---|---|+++|+++|+++|+++|+++|---|---|---| vector 0 1 2 3 4
when a new object is inserted: if there is room at the beginning or end of the vector, that room is consumed. Indexing in dynamic arrays is zero–based, with index ‘0’ referencing the first used slot.
The following syntactic bindings are exported by the library
(vicare containers dynamic-arrays)
.
Record type representing a dynamic-arrays object. The
<dynamic-array>
type is non–generative and available for
subtyping. In this documentation <dynamic-array>
objects used
as arguments to functions are indicated as arry.
Build and return a new <dynamic-array>
object.
The optional argument full-length must be a non–negative fixnum representing the number of slots in the internal vector object; when not used, it defaults to ‘15’. The optional argument left-span must be a non–negative fixnum representing the number of slots to initially leave unused at the left; when not used, it defaults to ‘7’.
Return #t
if obj is a record of type
<dynamic-array>
; otherwise return #f
.
Build and return a <dynamic-array>
object holding the given
objects, which are pushed on the dynamic-array left to right from the
rear side. The size of the internal vector is set to the default.
(define D (dynamic-array 0 1 2)) (dynamic-array-front D) ⇒ 0 (dynamic-array-rear D) ⇒ 2
Add a new property key to the property list of arry; key must be a symbol. If key is already set: the old entry is mutated to reference the new value.
Return the value of the property key in the property list of
arry; if key is not set: return #f
. key must
be a symbol.
Remove the property key from the property list of arry; if key is not set: nothing happens. key must be a symbol.
Return a new association list representing the property list of arry. The order of the entries is the same as the property creation order.
Return an exact integer to be used as hashtable key for arry.
Hashtables having a <dynamic-array>
as key can be instantiated
as follows:
(make-hashtable dynamic-array-hash eq?)
Next: dynamic arrays inspection, Up: dynamic arrays [Index]