Struct mc_core::util::PackedArray [−][src]
pub struct PackedArray { /* fields omitted */ }Expand description
A packed array is an array of cell (u64) with a fixed length and a varying bits
length (byte size) that allows it to store multiple values in the same cell.
Its content can be modified and queried by using methods of this method, the byte size can also be changed and methods allows to replace its content in-place.
Implementations
Create a new packed array with specific length and byte size (the bit size of each value,
smallest addressable unit), the default value is 0 if None is given.
Get the value at a specific index, None is returned if you are out of range.
Set the value at a specific index.
Panics
If the index is out of bounds or if the given value cannot fit in the current byte size.
Set the value at a specific index and ensure that the given value can fit into it, if not, the packed array is resized to a new byte size and the value is inserted.
pub fn resize_byte_and_replace<F>(&mut self, new_byte_size: u8, replacer: F) where
F: FnMut(usize, u64) -> u64,
Calculate the minimum size in bits to store de given value, the special case is for
value 0 which returns a bits size of 1, this special value is simpler to handle
by the structure’s methods.
