BitIndex
A little-endian zero-indexed bitstring representation.
Internally represented by the primitive unsigned integer types. Use the appropriate BitIndex depending on the number of indices that need to be tracked.
u8->BitIndex8u16->BitIndex16u32->BitIndex32u64->BitIndex64u128->BitIndex128
Usage
A BitIndex is initialized with ones for the requested availables indices. A BitIndex can be unwrapped to return a copy of the internal representation.
let bi_res = new // -> Ok(BitIndex8)
let bi = bi_res.unwrap // -> BitIndex8
assert_eq!;
Bits can be directly set and unset. BitIndex is zero-indexed.
let mut bi = new.unwrap // -> BitIndex8
bi.unset;
assert_eq!;
bi.set;
assert_eq!;
Smallest and largest availables indices can be queried.
let mut bi = new.unwrap // -> BitIndex8
assert_eq!;
bi.unset;
bi.unset;
assert_eq!;
bi.clear;
assert_eq!;
bi.restore;
assert_eq!;
assert_eq!;
bi.unset;
bi.unset;
assert_eq!;
bi.clear;
assert_eq!;
bi.restore;
assert_eq!;
Popping the smallest/largest returns the value, and unsets it
let mut bi = new.unwrap // -> BitIndex8
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
bi.restore;
assert_eq!;
assert_eq!;