Trait bitstring::FixedBitString
[−]
[src]
pub trait FixedBitString { fn inc(&mut self, prefix: usize) -> bool; fn len() -> usize; fn get(&self, ndx: usize) -> bool; fn set(&mut self, ndx: usize, bit: bool); fn set_false_from(&mut self, ndx: usize); fn is_false_from(&self, ndx: usize) -> bool; fn set_true_from(&mut self, ndx: usize); fn is_true_from(&self, ndx: usize) -> bool; fn new_all_false() -> Self; fn new_all_true() -> Self; fn contains(&self, prefix: usize, other: &Self) -> bool; fn iter(&self, prefix: usize) -> Iter<Self>
where
Self: Sized + Clone, { ... } fn on(&mut self, ndx: usize) { ... } fn off(&mut self, ndx: usize) { ... } fn flip(&mut self, ndx: usize) { ... } fn shared_prefix_len(&self, other: &Self, max_len: usize) -> usize { ... } }
A bit string with fixed length.
All bits must me mutable, and there must be no dependencies between bits (i.e. setting one bit must not change any other bit).
Required Methods
fn inc(&mut self, prefix: usize) -> bool
Treat bit string as integer, where bit 0 is the most significant bit.
Increment by one, i.e. start by incrementing the bit with the highest index.
Don't touch first prefix
bits; return true on overflow.
Panics
Should panic if prefix > self.len()
.
fn len() -> usize
Length of the bit string in bits.
fn get(&self, ndx: usize) -> bool
fn set(&mut self, ndx: usize, bit: bool)
fn set_false_from(&mut self, ndx: usize)
Set all bits in [ndx..] to false
.
Doesn't do anything if ndx >= self.len()
.
fn is_false_from(&self, ndx: usize) -> bool
Whether all bits in [ndx..] are false
.
Returns true
if ndx >= self.len()
.
fn set_true_from(&mut self, ndx: usize)
Set all bits in [ndx..] to true
.
Doesn't do anything if ndx >= self.len()
.
fn is_true_from(&self, ndx: usize) -> bool
Whether all bits in [ndx..] are true
.
Returns true
if ndx >= self.len()
.
fn new_all_false() -> Self
New bit string with all bits set to false
.
fn new_all_true() -> Self
New bit string with all bits set to true
.
fn contains(&self, prefix: usize, other: &Self) -> bool
check whether another bit string other
shares the first
prefix
bits with self
Provided Methods
fn iter(&self, prefix: usize) -> Iter<Self> where
Self: Sized + Clone,
Self: Sized + Clone,
Iterate through all bit strings until inc
overflows.
All generated values will share the first prefix
bits. If you
want to iterate over all values make sure to call
self.set_false_from(prefix)
before.
Panics
Should panic if prefix > self.len()
.
fn on(&mut self, ndx: usize)
fn off(&mut self, ndx: usize)
fn flip(&mut self, ndx: usize)
Length of the longest shared prefix of two bit strings.