pub trait BitVector {
// Required methods
fn get(&self, i: usize) -> bool;
fn set(&mut self, i: usize, x: bool);
fn size(&self) -> usize;
// Provided methods
fn rank(&self, r: Range<usize>) -> usize { ... }
fn select(&self, n: usize, start: usize) -> Option<usize> { ... }
fn get_range(&self, r: Range<usize>) -> u128 { ... }
fn set_range(&mut self, r: Range<usize>, x: u128) { ... }
fn clear_range(&mut self, r: Range<usize>) { ... }
}
Expand description
A basic bitvector trait that we implement for mmap
Required Methods§
Provided Methods§
Sourcefn select(&self, n: usize, start: usize) -> Option<usize>
fn select(&self, n: usize, start: usize) -> Option<usize>
Returns the position of the n-th set bit
Sourcefn get_range(&self, r: Range<usize>) -> u128
fn get_range(&self, r: Range<usize>) -> u128
Return all the bits in the given range as a u128
. The input range r
must span <= 128
,
as the result is bitpacked into a u128
.
For example, an input range of (0, 7)
will set the first 8 bits of the returned u128
to the result of self.get(0, 1, ... 7)
.
Sourcefn set_range(&mut self, r: Range<usize>, x: u128)
fn set_range(&mut self, r: Range<usize>, x: u128)
Sets all the bits in the given range from the given u128
Sourcefn clear_range(&mut self, r: Range<usize>)
fn clear_range(&mut self, r: Range<usize>)
Sets all the bit in the given range to false