sliced
The sliced
crate is a thin wrapper around Vec
that returns slices over internal storage rather
than individual elements. It is useful in cases where you need to store and repeatedly manipulate a
large collection of relatively short runs of numbers with the run lengths determined at run-time rather
than during compilation. Using Vec<Vec<T>>
means that each insert and remove will allocate and deallocate heap
storage for the inner Vec
, whereas sliced storage will use a single growable buffer.
For variable length slices, VarSlicedVec
stores the sequences in a single Vec
along with their extents using
a compressed sparse layout.
use *;
let mut vv = new;
vv.push;
vv.push;
vv.push;
assert_eq!;
assert_eq!;
assert_eq!;
For strings of equal length set at run-time, SlicedVec
allows for constant-time insertion and
removal without extra allocation if there is sufficient spare storage capacity.
use *;
let mut sv = new;
sv.push;
sv.push;
sv.push;
assert_eq!;
assert_eq!;
assert_eq!;
SlicedSlab
is also provided for accessing segments using a key.
use *;
let mut ss = from_vec;
assert_eq!;
assert_eq!;
ss.release;
assert_eq!;
assert_eq!;
License: MIT