pub struct BitVector { /* private fields */ }
Expand description
Implementations§
Source§impl BitVector
impl BitVector
Sourcepub fn new(size: usize, default_value: usize) -> Result<Self>
pub fn new(size: usize, default_value: usize) -> Result<Self>
Construct a new bit vector.
§Arguments
size
- Number of elements.default_value
- Default values for elements initialization.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the size of the occupied bits of the vector.
The capacity of a vector is greater or equal to the
bit_size()
.
Sourcepub fn get_int(&self, index: usize, len: u8) -> usize
pub fn get_int(&self, index: usize, len: u8) -> usize
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);
Sourcepub fn set_int(&mut self, index: usize, value: usize, len: u8)
pub fn set_int(&mut self, index: usize, value: usize, len: u8)
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 ofvalue
.value
- The integer to store in the vector.len
- The length used to storevalue
in the vector.
Trait Implementations§
Source§impl IntoIterator for BitVector
impl IntoIterator for BitVector
Source§impl PartialEq for BitVector
impl PartialEq for BitVector
impl Eq for BitVector
Auto Trait Implementations§
impl Freeze for BitVector
impl RefUnwindSafe for BitVector
impl !Send for BitVector
impl !Sync for BitVector
impl Unpin for BitVector
impl UnwindSafe for BitVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more