Skip to main content

BitVector

Struct BitVector 

Source
pub struct BitVector { /* private fields */ }
Expand description

A cache-oblivious succinct bit vector.

Implementations§

Source§

impl BitVector

Source

pub fn new(bits: &[u64], len: usize) -> Self

Create a new BitVector from a sequence of bits.

Source

pub fn from_parts( storage: Vec<u64>, select1_index: Vec<u32>, select0_index: Vec<u32>, len: usize, ) -> Result<Self>

Reconstruct a BitVector from its internal parts.

This is primarily intended for serialization round-trips.

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialize this bitvector to a stable binary encoding (little-endian).

Format (versioned):

  • magic: 8 bytes (SBITBV01)
  • len: u64
  • storage_len: u64, then storage_len u64 words
  • select1_len: u64, then select1_len u32 words
  • select0_len: u64, then select0_len u32 words
Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Deserialize a BitVector from to_bytes() output.

Source

pub fn len(&self) -> usize

Return the total number of bits in the vector.

Source

pub fn is_empty(&self) -> bool

Return true if the bit-vector has length 0.

Source

pub fn heap_bytes(&self) -> usize

Approximate heap memory usage in bytes.

Source

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

Return true if the bit at index i is set.

Source

pub fn rank1(&self, i: usize) -> usize

Return the number of set bits in the range [0, i).

Source

pub fn rank0(&self, i: usize) -> usize

Return the number of unset bits in the range [0, i).

Source

pub fn select1(&self, k: usize) -> Option<usize>

Return the position of the $k$-th set bit (0-indexed).

Source

pub fn select0(&self, k: usize) -> Option<usize>

Return the position of the $k$-th unset bit (0-indexed).

Trait Implementations§

Source§

impl Clone for BitVector

Source§

fn clone(&self) -> BitVector

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BitVector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.