|(require data/spvector)||package: spvector|
This package defines semi-persistent vectors. These vectors are persistent, because old versions are maintained. However, performance degrades when old versions are used. Each operation is O(1) if the newest version is used, otherwise each operation is O(n) where n is the number of versions to the current.
n : exact-positive-integer? f : (exact-nonnegative-integer? . -> . any/c)
vec : spvector? i : exact-nonnegative-integer? v : any/c
Semi-persistent vectors are implemented using a weak hash table to log undo information for modifications. These are indexed by uninterned symbols that are stored in the spvector? struct. This means that the garbage collector reclaims space in the log when the old version symbols are no longer reachable. Thus, if you use this structure in a purely linear way, it will behavior exactly like normal vectors asymptotically.