pub struct Prunable { /* private fields */ }Expand description
A Bitmap paired with a “pruned-below” watermark.
See the module-level documentation for semantics and granularity.
Implementations§
Source§impl Prunable
impl Prunable
Sourcepub fn len(&self) -> u64
pub fn len(&self) -> u64
Returns the cardinality (number of values currently in the set).
Pruning subtracts from this: dropping a container with N values reduces len() by N.
This differs from super::super::Prunable::len (the dense BitMap<N> wrapper),
which preserves length across pruning because positions are meaningful in a sequential
bit array. Here, only present values are counted.
Sourcepub const fn pruned_below(&self) -> u64
pub const fn pruned_below(&self) -> u64
Returns the current pruning watermark.
Always a multiple of 65536. No value < pruned_below exists in the bitmap.
Sourcepub fn insert(&mut self, value: u64) -> bool
pub fn insert(&mut self, value: u64) -> bool
Inserts a value into the bitmap. Returns true if newly inserted.
§Panics
Panics if value < pruned_below().
Sourcepub fn insert_range(&mut self, range: Range<u64>) -> u64
pub fn insert_range(&mut self, range: Range<u64>) -> u64
Inserts a range of values into the bitmap. Returns the number of values newly inserted.
§Panics
Panics if start < pruned_below().
Sourcepub fn prune(&mut self, threshold: u64) -> u64
pub fn prune(&mut self, threshold: u64) -> u64
Prunes all values strictly less than threshold, rounding down to the nearest
container boundary (multiple of 65536).
Returns the threshold actually applied (the rounded-down value), which is also the
new value of Self::pruned_below.
No-op if the rounded threshold is <= pruned_below().
Sourcepub fn iter(&self) -> impl Iterator<Item = u64> + '_
pub fn iter(&self) -> impl Iterator<Item = u64> + '_
Returns an iterator over the values in sorted order.
Sourcepub fn iter_range(&self, range: Range<u64>) -> impl Iterator<Item = u64> + '_
pub fn iter_range(&self, range: Range<u64>) -> impl Iterator<Item = u64> + '_
Returns an iterator over the values in the range in sorted order.
§Panics
Panics if start < pruned_below().
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all values from the bitmap. Does not reset Self::pruned_below.
Trait Implementations§
Source§impl EncodeSize for Prunable
impl EncodeSize for Prunable
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Source§fn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
BufsMut::push
during Write::write_bufs. Used to size the working buffer for inline
writes. Override alongside Write::write_bufs for types where large
Bytes fields go via push; failing to do so will over-allocate.Source§impl Extend<u64> for Prunable
impl Extend<u64> for Prunable
Source§fn extend<I: IntoIterator<Item = u64>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = u64>>(&mut self, iter: I)
Inserts each value from the iterator. Panics if any value is below
Self::pruned_below, matching Self::insert.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<u64> for Prunable
impl FromIterator<u64> for Prunable
Source§impl Read for Prunable
impl Read for Prunable
Source§impl Write for Prunable
impl Write for Prunable
Source§fn write_bufs(&self, buf: &mut impl BufsMut)
fn write_bufs(&self, buf: &mut impl BufsMut)
BufsMut, allowing existing Bytes chunks to be
appended via BufsMut::push instead of written inline. Must encode
to the same format as Write::write. Defaults to Write::write.