pub struct Packed<'a> { /* private fields */ }Expand description
The bits of a packed vector and what they mean, for a kernel that wants to stay in code space.
Borrowed from the vector rather than owning anything, so getting one costs nothing and a kernel that finds it cannot use them has given up nothing by asking.
Implementations§
Source§impl Packed<'_>
impl Packed<'_>
Sourcepub fn width(&self) -> u32
pub fn width(&self) -> u32
How many bits one code takes, between one and PACKED_WIDTH_MAX.
Sourcepub fn base(&self) -> i128
pub fn base(&self) -> i128
What zero means, so that the value of a row is the base plus its code.
Sourcepub fn ceiling(&self) -> i128
pub fn ceiling(&self) -> i128
The largest value this vector can be holding, whatever it is actually holding.
With Self::base this is the pair a comparison kernel wants first. A literal outside the
two answers every row of the vector the same way, which is a whole chunk decided without a
bit being read, and that is the case a zone map would have caught if there were one here.
Sourcepub fn code(&self, row: usize) -> u64
pub fn code(&self, row: usize) -> u64
The code of row row, which is its value minus Self::base.
Out of range rows read as zero rather than panicking, the way every other accessor in this file answers for a row that is not there.
Sourcepub fn code_of(&self, value: i128) -> Option<u64>
pub fn code_of(&self, value: i128) -> Option<u64>
Which code a value would have, and None for a value this vector cannot be holding.
The translation a comparison does once per vector so that it does not have to unpack once per
row. None is the useful answer rather than a failure: it says the literal is outside the
packed range, so every row compares against it the same way.