Extensible Vectors
The :std/misc/evector
library implements extensible vectors,
that grow as you add elements to them, in the style of Common Lisp extensible vectors.
In this implementation, the underlying vectors double their size each time they need to grow, guaranteeing constant factor size and time overhead over having known the correct size initially. The current implementation does not support shrinking an extensible vector, but you can extract the non-extensible vector and forget the extensible one when you’re done.
ebytes
and ebits
are variants of evector
specialized for holding
respectively 8-bit bytes and 1-bit bits.
To use the bindings from this module:
(import :std/misc/evector)
evector
make-evector
(make-evector vector fill-pointer) => evector
Create an evector
from initial values for the supporting vector
and the fill-pointer
.
Beware that the vector
and the evector
will share side-effects until the evector
grows;
expected use is that ownership of the vector
is transfered to the new evector
.
Examples:
> (make-evector #(1 2 3 #f) 3)
evector?
(evector? x) => bool
Recognize an evector
.