stencil-vector-utils
(require stencil-vector-utils) | |
package: stencil-vector-utils |
Functions to make it more convenient to use the stencil vectors added in Racket 8.6.
Some terminology: index refers to the virtual index used by "stencil-vector-ref" etc. 0 corresponds to the first set bit, 1 to the second, etc. no matter where in the bitmask they are. slot refers to the element associated wtih a given bit position. 0 corresponds to the first bit #b1, 1 to the second bit #b10, and so on, regardless of how many bits are set before it in the mask.
1 Stencil Vector contracts and predicates
value
stencil-vector-slot? : contract?
= (integer-in 0 (sub1 (stencil-vector-mask-width)))
value
stencil-vector-bitmask? : contract?
= (integer-in 0 (sub1 (expt 2 (stencil-vector-mask-width))))
procedure
(stencil-vector-slot-has-slot? sv slot) → boolean?
sv : stencil-vector? slot : stencil-vector-slot?
procedure
(stencil-vector-empty? sv) → boolean?
sv : stencil-vector?
2 Stencil Vector Operations
procedure
(make-stencil-vector bitmask v) → stencil-vector?
bitmask : stencil-vector-bitmask? v : any/c
procedure
(build-stencil-vector bitmask proc) → stencil-vector?
bitmask : stencil-vector-bitmask? proc : (-> exact-nonnegative-integer? any/c)
procedure
(stencil-vector-copy sv #:bitmask stencil-vector-bitmask?) → stencil-vector? sv : stencil-vector? stencil-vector-bitmask? : (stencil-vector-mask sv)
procedure
(stencil-vector-insert sv slot val) → stencil-vector?
sv : stencil-vector? slot : stencil-vector-slot? val : any/c
procedure
(stencil-vector-remove sv slot) → stencil-vector?
sv : stencil-vector? slot : stencil-vector-slot?
procedure
(stencil-vector-slot->index sv slot)
→ (or/c exact-nonnegative-integer? #f) sv : stencil-vector? slot : stencil-vector-slot?
procedure
sv : stencil-vector? n : exact-nonnegative-integer?
procedure
(stencil-vector-slot-ref sv slot [default]) → any
sv : stencil-vector? slot : stencil-vector-slot? default : any/c = (lambda () (error "Index not present: " i))
procedure
(stencil-vector->list sv) → list?
sv : stencil-vector?
procedure
(stencil-vector->vector sv) → vector?
sv : stencil-vector?
3 Stencil Vector Iteration
procedure
(in-stencil-vector sv) → sequence?
sv : stencil-vector?
procedure
(stencil-vector-for-each proc sv) → void?
proc : (-> any/c any/c) sv : stencil-vector?
procedure
(stencil-vector-map! proc sv) → void?
proc : (-> any/c any/c) sv : stencil-vector?
procedure
(stencil-vector-map proc sv [ #:bitmask bitmask]) → stencil-vector? proc : (-> any/c any/c) sv : stencil-vector? bitmask : stencil-vector-bitmask? = (stencil-vector-mask sv)
procedure
(stencil-vector-fold kons knil sv) → any/c
kons : (-> any/c any/c any/c) knil : any/c sv : stencil-vector?