Trait Bitmap
pub trait Bitmap: BitmapSlice {
// Required methods
fn new_all_zeros(len: usize) -> Self;
fn new_all_ones(len: usize) -> Self;
fn set(&mut self, index: usize) -> bool;
fn clear(&mut self, index: usize) -> bool;
fn and_with(&mut self, other: &impl BitmapSlice) -> bool;
fn clear_from(&mut self, other: &impl BitmapSlice) -> bool;
fn or_with(&mut self, other: &impl BitmapSlice) -> bool;
fn xor_with(&mut self, other: &impl BitmapSlice) -> bool;
fn is_all_ones(&self) -> bool;
fn is_superset_of(&self, other: &Self) -> bool;
// Provided methods
fn set_many(&mut self, indices: impl Iterator<Item = usize>) { ... }
fn clear_many(&mut self, indices: impl Iterator<Item = usize>) { ... }
}
Expand description
A writable bitmap.
Required Methods§
fn new_all_zeros(len: usize) -> Self
fn new_all_zeros(len: usize) -> Self
Creates a new bitmap with all bits set to zero.
fn new_all_ones(len: usize) -> Self
fn new_all_ones(len: usize) -> Self
Creates a new bitmap with all bits set to one.
fn and_with(&mut self, other: &impl BitmapSlice) -> bool
fn and_with(&mut self, other: &impl BitmapSlice) -> bool
ANDs the slice with other
. Returns true if anything changed.
fn clear_from(&mut self, other: &impl BitmapSlice) -> bool
fn clear_from(&mut self, other: &impl BitmapSlice) -> bool
Computes self & !other
. Returns true if anything changed.
fn or_with(&mut self, other: &impl BitmapSlice) -> bool
fn or_with(&mut self, other: &impl BitmapSlice) -> bool
ORs the slice with other
. Returns true if anything changed.
fn xor_with(&mut self, other: &impl BitmapSlice) -> bool
fn xor_with(&mut self, other: &impl BitmapSlice) -> bool
XORs the slice with other
. Returns true if anything changed.
fn is_all_ones(&self) -> bool
fn is_all_ones(&self) -> bool
Returns true if the bitmap contains only ones.
fn is_superset_of(&self, other: &Self) -> bool
fn is_superset_of(&self, other: &Self) -> bool
Returns true if the bitmap is a superset of other
.
In other words: for every bit that is set in other
, it should also be set in self
.
Provided Methods§
fn clear_many(&mut self, indices: impl Iterator<Item = usize>)
fn clear_many(&mut self, indices: impl Iterator<Item = usize>)
Sets all bits in indices
to zero.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.