Trait bitstring::utils::BigEndianBitString
[−]
[src]
pub trait BigEndianBitString: Sized { fn mask(ndx: usize) -> Self; fn inc(slice: &mut [Self], prefix: usize) -> bool; fn get(slice: &[Self], ndx: usize) -> bool; fn on(slice: &mut [Self], ndx: usize); fn off(slice: &mut [Self], ndx: usize); fn flip(slice: &mut [Self], ndx: usize); fn shared_prefix_len(
slice: &[Self],
other: &[Self],
max_len: usize
) -> usize; fn set_false_from(slice: &mut [Self], ndx: usize); fn is_false_from(slice: &[Self], ndx: usize) -> bool; fn set_true_from(slice: &mut [Self], ndx: usize); fn is_true_from(slice: &[Self], ndx: usize) -> bool; fn contains(slice: &[Self], prefix: usize, other: &[Self]) -> bool; fn elembits() -> usize { ... } fn set(slice: &mut [Self], ndx: usize, bit: bool) { ... } }
Generic helper methods to treat [u*]-slices as big endian bit strings.
Required Methods
fn mask(ndx: usize) -> Self
integer with single bit set. bit 0 is the highest bit (big
endian). Wraps at Self::elembits()
.
fn inc(slice: &mut [Self], prefix: usize) -> bool
increment from right; don't touch first prefix
bits; returns
true on overflow
Panics
Panics if prefix > Self::elembits() * slice.len()
.
fn get(slice: &[Self], ndx: usize) -> bool
fn on(slice: &mut [Self], ndx: usize)
fn off(slice: &mut [Self], ndx: usize)
fn flip(slice: &mut [Self], ndx: usize)
Length of the longest shared prefix of two bit strings.
fn set_false_from(slice: &mut [Self], ndx: usize)
Set all bits from [ndx..] to false
.
Doesn't do anything if ndx >= Self::elembits() * slice.len()
.
fn is_false_from(slice: &[Self], ndx: usize) -> bool
Whether all bits from [ndx..] are false
.
Returns true
if ndx >= Self::elembits() * slice.len()
.
fn set_true_from(slice: &mut [Self], ndx: usize)
Set all bits from [ndx..] to true
.
Doesn't do anything if ndx >= Self::elembits() * slice.len()
.
fn is_true_from(slice: &[Self], ndx: usize) -> bool
Whether all bits from [ndx..] are true
.
Returns true
if ndx >= Self::elembits() * slice.len()
.
fn contains(slice: &[Self], prefix: usize, other: &[Self]) -> bool
check whether another bit string other
shares the first
prefix
bits with self