Struct vers_vecs::bit_vec::BitVec

source ·
pub struct BitVec { /* private fields */ }
Expand description

A simple bit vector that does not support rank and select queries. It has a constant memory overhead of 32 bytes on the stack.

Implementations§

source§

impl BitVec

source

pub fn new() -> Self

Create a new empty bit vector.

source

pub fn with_capacity(capacity: usize) -> Self

Create a new empty bit vector with the given capacity. The capacity is measured in bits.

source

pub fn from_zeros(len: usize) -> Self

Create a new bit vector with all zeros and the given length. The length is measured in bits.

source

pub fn append(&mut self, bit: bool)

Append a bit to the bit vector.

source

pub fn truncate(&mut self, n: usize)

Drop the last n bits from the bit vector.

source

pub fn append_bit(&mut self, bit: u64)

Append a bit from a quad-word. The least significant bit is appended to the bit vector. All other bits are ignored.

source

pub fn append_word(&mut self, word: u64)

Append a word to the bit vector. The least significant bit is appended first.

source

pub fn append_bits(&mut self, bits: u64, len: usize)

Append multiple bits to the bit vector. The least significant bit is appended first. The number of bits to append is given by len. The bits are taken from the least significant bits of bits. All other bits are ignored.

source

pub fn len(&self) -> usize

Return the length of the bit vector. The length is measured in bits.

source

pub fn is_empty(&self) -> bool

Return whether the bit vector is empty (contains no bits).

source

pub fn flip_bit(&mut self, pos: usize)

Flip the bit at the given position.

source

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

Return the bit at the given position.

source

pub fn get_bits(&self, pos: usize, len: usize) -> u64

Return multiple bits at the given position. The number of bits to return is given by len. At most 64 bits can be returned.

source

pub fn heap_size(&self) -> usize

Returns the number of bytes on the heap for this vector. Does not include allocated memory that isn’t used.

Trait Implementations§

source§

impl Clone for BitVec

source§

fn clone(&self) -> BitVec

Returns a copy 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 BitVec

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for BitVec

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.