2 Growable Vectors
(require data/gvector) |
A growable vector (gvector) is a mutable sequence whose length can change over time. A gvector also acts as a dictionary (dict? from racket/dict), where the keys are zero-based indexes and the values are the elements of the gvector. A gvector can be extended by adding an element to the end, and it can be shrunk by removing any element, although removal can take time linear in the number of elements in the gvector.
Two gvectors are equal? if they contain the same number of elements and if the contain equal elements at each index.
Operations on gvectors are not thread-safe.
procedure
(make-gvector [#:capacity capacity]) → gvector?
capacity : exact-positive-integer? = 10
procedure
(gvector-ref gv index [default]) → any/c
gv : gvector? index : exact-nonnegative-integer? default : any/c = (error ....)
procedure
(gvector-add! gv value ...) → void?
gv : gvector? value : any/c
procedure
(gvector-set! gv index value) → void?
gv : gvector?
index :
(and/c exact-nonnegative-integer? (</c (+ 1 (gvector-count gv)))) value : any/c
procedure
(gvector-remove! gv index) → void?
gv : gvector?
index :
(and/c exact-nonnegative-integer? (</c (gvector-count gv)))
procedure
(gvector-remove-last! gv) → any/c
gv : gvector?
procedure
gv : gvector?
procedure
(gvector->vector gv) → vector?
gv : gvector?
procedure
(gvector->list gv) → list?
gv : gvector?
procedure
(in-gvector gv) → sequence?
gv : gvector?
syntax
(for/gvector (for-clause ...) body ...+)
syntax
(for*/gvector (for-clause ...) body ...+)
Unlike for/list, the body may return zero or multiple values; all returned values are added to the gvector, in order, on each iteration.