Struct sdsl::BitVector[][src]

pub struct BitVector { /* fields omitted */ }
Expand description

A bit vector where each element is 1 bit.

Example

let bv = sdsl::BitVector::new(5, 1)?;
let result: Vec<_> = bv.iter().collect();
let expected = vec![1, 1, 1, 1, 1];
assert_eq!(result, expected);

For further examples see here.

Implementations

impl BitVector[src]

pub fn new(size: usize, default_value: usize) -> Result<Self>[src]

Construct a new bit vector.

Arguments

  • size - Number of elements.
  • default_value - Default values for elements initialization.

pub fn from_file(path: &PathBuf) -> Result<Self>[src]

Load vector from file.

Arguments

  • path - File path.

pub fn is_empty(&self) -> bool[src]

Returns true if the vector is empty, otherwise returns false.

pub fn resize(&mut self, size: usize)[src]

Resize the vector in terms of elements.

Arguments

  • size - Target number of elements.

pub fn len(&self) -> usize[src]

The number of elements in the vector.

pub fn max_size(&self) -> usize[src]

Maximum size of the vector.

pub fn bit_size(&self) -> usize[src]

The number of bits in the vector.

pub fn capacity(&self) -> usize[src]

Returns the size of the occupied bits of the vector.

The capacity of a vector is greater or equal to the bit_size().

pub fn data(&self) -> *const c_void[src]

Constant pointer to the raw data of the vector.

pub fn get_int(&self, index: usize, len: u8) -> usize[src]

Get the integer value of the binary string of length len starting at position index in the vector.

Arguments

  • index - Starting index of the binary representation of the integer.
  • len - Length of the binary representation of the integer.

Example

//                          1, 2, 4, 8, 16
let bv = sdsl::bit_vector! {1, 1, 0, 0, 1};
let result = bv.get_int(0, 5);
let expected = 19; // = 1 + 2 + 16
assert_eq!(result, expected);

pub fn set_int(&mut self, index: usize, value: usize, len: u8)[src]

Set the bits from position index to index+len-1 to the binary representation of integer value.

The bit at position index represents the least significant bit (lsb), and the bit at position index+len-1 the most significant bit (msb) of value.

Arguments

  • index - Starting index of the binary representation of value.
  • value - The integer to store in the vector.
  • len - The length used to store value in the vector.

pub fn get(&self, index: usize) -> usize[src]

Get the i-th element of the vector.

Arguments

  • index - An index in range $ [0, \mathrm{len}()) $.

pub fn set(&mut self, index: usize, value: usize)[src]

Set the i-th element of the vector.

Arguments

  • index - An index in range $ [0, \mathrm{len}()) $.
  • value - New element value.

pub fn flip(&mut self)[src]

Flip all bits.

pub fn iter(&self) -> VectorIterator<'_, Self>[src]

Returns an iterator over the vector values.

Trait Implementations

impl Clone for BitVector[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for BitVector[src]

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

Formats the value using the given formatter. Read more

impl Drop for BitVector[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl IO for BitVector[src]

fn io(&self) -> &Interface[src]

impl IntoIterator for BitVector[src]

type Item = usize

The type of the elements being iterated over.

type IntoIter = VectorIntoIterator<BitVector>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl PartialEq<BitVector> for BitVector[src]

fn eq(&self, other: &Self) -> bool[src]

Equality operator for two vectors.

Two int_vectors are equal if

  • capacities and sizes are equal and
  • width are equal and
  • the bits in the range [0..bit_size()-1] are equal.

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Util for BitVector[src]

fn util(&self) -> &Interface[src]

impl Eq for BitVector[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.