pub trait BitSet {
// Required methods
fn set_bit(&mut self, position: usize, value: bool);
fn get_bit(&self, position: usize) -> bool;
fn get_weight(&self) -> u32;
fn reset(&mut self);
fn to_string(self) -> String;
}
Expand description
Trait to define the basic functions of a BitSet
Required Methods§
Sourcefn set_bit(&mut self, position: usize, value: bool)
fn set_bit(&mut self, position: usize, value: bool)
Sets the value of the bit at position position
to value
Sourcefn get_weight(&self) -> u32
fn get_weight(&self) -> u32
Returns the bitset’s Hamming weight
Implementors§
impl BitSet for DenseBitSet
This is a compact implementation of the BitSet
trait over a 64-bit word (which is the native
word size for many architectures), allowing for efficient operations and compact memory usage.
Modifiers and accessors are boundary checked to ensure that operations remain within that 64 bit range.
Note: The BitSet
trait must be in scope in order to use methods from this trait.
impl BitSet for DenseBitSetExtended
This is an extended implementation of the BitSet
trait. It dynamically resizes the bitset as necessary
to accomodate growing or shrinking operations (e.g. left shifts) and is only limited by available memory.
In practice however, we (arbitrarily) limited allocation to 64000 bits.
Note: The BitSet
trait must be in scope in order to use methods from this trait.
Note: The Copy
trait cannot be implemented for DenseBitSetExtended
(for the same reasons avec Vec
).