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

A bit vector where each element is 1 bit.

Example

let bv = sdsl::bit_vectors::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

Construct a new bit vector.

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

Load vector from file.

Arguments
  • path - File path.

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

Resize the vector in terms of elements.

Arguments
  • size - Target number of elements.

The number of elements in the vector.

Maximum size of the vector.

The number of bits in the vector.

Returns the size of the occupied bits of the vector.

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

Constant pointer to the raw data of the vector.

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

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.

Get the i-th element of the vector.

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

Set the i-th element of the vector.

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

Flip all bits.

Returns an iterator over the vector values.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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.

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.