2 Growable Vectors
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.
Creates a new empty gvector with an initial capacity of
Creates a new gvector containing each elem in order.
Returns #t if x is a gvector, #f otherwise.
Returns the element at index index
, if index
than (gvector-count gv)
. Otherwise, default
invoked if it is a procedure, returned otherwise.
Adds each value to the end of the gvector gv.
Sets the value at index index
to be value
is (gvector-count gv)
that is, one more than
the greatest used index—
the effect is the same as
(gvector-add! gv value)
Removes the item at index
, shifting items at higher indexes
down. Takes time proportional to (- (gvector-count gv) index)
Returns the number of items in gv.
Returns a vector of length (gvector-count gv)
elements of gv
Returns a sequence whose elements are the elements of
. Mutation of gv
while the sequence is running
changes the elements produced by the sequence. To obtain a sequence
from a snapshot of gv
, use (in-vector (gvector->vector gv))
Unlike for/list, the body may return zero or
multiple values; all returned values are added to the gvector, in
order, on each iteration.