Skip to main content

BitVector

Trait BitVector 

Source
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§

Source

fn get(&self, i: usize) -> bool

Get the value at bit i

Source

fn set(&mut self, i: usize, x: bool)

Set the value at bit i

Source

fn size(&self) -> usize

Returns the size of the bitvector

Provided Methods§

Source

fn rank(&self, r: Range<usize>) -> usize

Returns the number of bits sets in the given range

Source

fn select(&self, n: usize, start: usize) -> Option<usize>

Returns the position of the n-th set bit

Source

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).

Source

fn set_range(&mut self, r: Range<usize>, x: u128)

Sets all the bits in the given range from the given u128

Source

fn clear_range(&mut self, r: Range<usize>)

Sets all the bit in the given range to false

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl BitVector for &[u8]

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, _: usize, _: bool)

Source§

fn size(&self) -> usize

Source§

impl BitVector for Vec<u8>

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, i: usize, x: bool)

Source§

fn size(&self) -> usize

Source§

impl BitVector for u8

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, i: usize, x: bool)

Source§

fn size(&self) -> usize

Source§

impl BitVector for u16

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, i: usize, x: bool)

Source§

fn size(&self) -> usize

Source§

impl BitVector for u32

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, i: usize, x: bool)

Source§

fn size(&self) -> usize

Source§

impl BitVector for u64

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, i: usize, x: bool)

Source§

fn size(&self) -> usize

Source§

impl BitVector for u128

Source§

fn get(&self, i: usize) -> bool

Source§

fn set(&mut self, i: usize, x: bool)

Source§

fn size(&self) -> usize

Implementors§