sliced
Two structs are provided: SlicedVec and SlicedSlab. SlicedVec stores a
collection of uniformly sized slices in a single vector. The segment length is determined at run-time
during initialization. Methods are available for constant-time, non-order-preserving insertion and deletion.
The erase-remove idiom is supported for for segments containing multiple values.
SlicedSlab is built on SlicedVec and returns stable keys to allocated sequences of values. Methods are
provided for re-keying and compacting the slab if it becomes too sparse. Open slots are stored in a BTreeSet
so that new insert occur as close to the beginning of the storage as possible thereby reducing fragmentation.
Example
use ;
use StandardNormal;
use ;
let mut rng = from_entropy;
let mut genseq =
.take.;
let mut sample_range = ;
// Constant time, no-alloc insertion and deletion
let vals = genseq;
let mut svec = from_vec;
for _ in 0..100
// Fast, no-alloc key-based access
let mut slab = with_capacity;
let mut keys = Vecnew;
svec.iter.for_each;
for _ in 0..50
keys.iter_mut.for_each;
slab.compact;
for _ in 0..50
let sum = keys.iter.map.;
// 4-point Laplace operator on grid
let rows = 256;
let cols = 128;
let mut rast = from_vec;
for row in 1..