BitVec

Struct BitVec 

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

A simple bit vector that does not support rank and select queries. Bits are stored in little-endian order, i.e. the least significant bit is stored first. The bit vector is stored as a sequence of 64 bit limbs. The last limb may be partially filled.

The bit vector has a wide range of constructors that allow for easy creation from various sources. Among them are constructors for creating an empty vector (BitVec::new), creating one from single bits of various integer types (BitVec::from_bits and variations), creating limbs from u64 values directly (BitVec::from_limbs and variations), or packing a sequence of numerical values into a dense bit sequence (BitVec::pack_sequence_u64 and variations).

The bit vector can be modified after creation (e.g. by appending bits or words, flipping, or setting bits). Bits can be accessed by position, and multiple bits can be accessed at once. Bits can be dropped from the end.

§Example

use vers_vecs::{BitVec, RsVec};

let mut bit_vec = BitVec::new();
bit_vec.append_bit(0u64);
bit_vec.append_bit_u32(1u32);
bit_vec.append_word(0b1010_1010_1010_1010u64); // appends exactly 64 bits

assert_eq!(bit_vec.len(), 66);
assert_eq!(bit_vec.get(0), Some(0u64));
assert_eq!(bit_vec.get(1), Some(1u64));

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. The bit vector will be able to hold at least capacity bits without reallocating. More memory may be allocated according to the underlying allocation strategy.

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 from_ones(len: usize) -> Self

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

Source

pub fn from_bits(bits: &[u8]) -> Self

Construct a bit vector from a set of bits given as distinct u8 values. The constructor will take the least significant bit from each value and append it to a bit vector. All other bits are ignored.

See also: from_bits_u16, from_bits_u32, from_bits_u64, from_bits_iter

§Example
use vers_vecs::BitVec;

let bits: &[u8] = &[1, 0, 1, 1, 1, 1];
let bv = BitVec::from_bits(&bits);

assert_eq!(bv.len(), 6);
assert_eq!(bv.get_bits(0, 6), Some(0b111101u64));
Source

pub fn from_bits_u16(bits: &[u16]) -> Self

Construct a bit vector from a set of bits given as distinct u16 values. The constructor will take the least significant bit from each value and append it to a bit vector. All other bits are ignored.

See also: from_bits, from_bits_u32, from_bits_u64, from_bits_iter

Source

pub fn from_bits_u32(bits: &[u32]) -> Self

Construct a bit vector from a set of bits given as distinct u32 values. The constructor will take the least significant bit from each value and append it to a bit vector. All other bits are ignored.

See also: from_bits, from_bits_u16, from_bits_u64, from_bits_iter

Source

pub fn from_bits_u64(bits: &[u64]) -> Self

Construct a bit vector from a set of bits given as distinct u64 values. The constructor will take the least significant bit from each value and append it to a bit vector. All other bits are ignored.

See also: from_bits, from_bits_u16, from_bits_u32, from_bits_iter

Source

pub fn from_bits_iter<I, E>(iter: I) -> Self
where E: Into<u64>, I: IntoIterator<Item = E>,

Construct a bit vector from an iterator of bits. The constructor will take the least significant bit from each value and append it to a bit vector. All other bits are ignored. The iterator must yield values that can be converted into u64 values.

See also: from_bits, from_bits_u16, from_bits_u32, from_bits_u64

§Example
use vers_vecs::BitVec;

let bits = [true, false, true, true, true, true];
let bv = BitVec::from_bits_iter(bits.iter().copied());

let bits = [0b1u8, 0b0, 0b1, 0b1, 0b1, 0b1];
let bv2 = BitVec::from_bits_iter(bits.iter().copied());

assert_eq!(bv.len(), 6);
assert_eq!(bv.get_bits(0, 6), Some(0b111101u64));
assert_eq!(bv, bv2);
Source

pub fn from_limbs(words: &[u64]) -> Self

Construct a bit vector from a slice of u64 quad words. The quad words are interpreted as limbs of the bit vector (i.e. each quad word contributes 64 bits to the bit vector). Since the data is only cloned without any masking or transformation, this is one of the fastest ways to create a bit vector.

See also: from_vec, from_limbs_iter

§Example
use vers_vecs::BitVec;

let words = [0, 256, u64::MAX];
let bv = BitVec::from_limbs(&words);

assert_eq!(bv.len(), 192);
assert_eq!(bv.get_bits(0, 64), Some(0u64));
assert_eq!(bv.get(72), Some(1));
assert_eq!(bv.get_bits(128, 64), Some(u64::MAX));
Source

pub fn from_limbs_iter<I, E>(iter: I) -> Self
where E: Into<u64>, I: IntoIterator<Item = E>,

Construct a bit vector from an iterator of u64 quad words. The quad words are interpreted as limbs of the bit vector (i.e. each quad word contributes 64 bits to the bit vector). Since the data is only cloned without any masking or transformation, this is one of the fastest ways to create a bit vector.

See also: from_limbs, from_vec

§Example
use std::iter::repeat;
use vers_vecs::BitVec;

let zeros = repeat(0xaaaaaaaaaaaaaaaau64).take(10);
let bv = BitVec::from_limbs_iter(zeros);

assert_eq!(bv.len(), 640);
for i in 0..640 {
   assert_eq!(bv.get(i), Some((i % 2 == 1) as u64));
}
Source

pub fn from_vec(data: Vec<u64>) -> Self

Construct a bit vector from a vector of u64 quad words. The quad words are interpreted as limbs of the bit vector (i.e. each quad word contributes 64 bits to the bit vector). Since the data is moved without any masking or transformation, this is one of the fastest ways to create a bit vector.

See also: from_limbs, from_limbs_iter

§Example
use vers_vecs::BitVec;

let words = vec![0, 256, u64::MAX];
let bv = BitVec::from_vec(words);

assert_eq!(bv.len(), 192);
assert_eq!(bv.get_bits(0, 64), Some(0u64));
assert_eq!(bv.get(72), Some(1));
assert_eq!(bv.get_bits(128, 64), Some(u64::MAX));
Source

pub fn pack_sequence_u64(sequence: &[u64], bits_per_element: usize) -> Self

Construct a bit vector by packing a sequence of numerical values into a dense sequence. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The number of bits per element is given by bits_per_element. The sequence is given as a slice of u64 values. If the number of bits per element is smaller than 64, the function takes the least significant bits of each element, and discards the rest. If the number of bits per element is larger than 64, the function will pad the elements with zeros. The function will append the bits of each element to the bit vector in the order they are given in the sequence (i.e. the first element takes bits 0..bits_per_element of the vector).

See also: pack_sequence_u32, pack_sequence_u16, pack_sequence_u8

§Example
use vers_vecs::BitVec;

let sequence = [0b1010u64, 0b1100u64, 0b1111u64];
let bv = BitVec::pack_sequence_u64(&sequence, 4);

assert_eq!(bv.len(), 12);
assert_eq!(bv.get_bits(0, 4), Some(0b1010u64));
assert_eq!(bv.get_bits(4, 4), Some(0b1100u64));
assert_eq!(bv.get_bits(8, 4), Some(0b1111u64));
Source

pub fn pack_sequence_u32(sequence: &[u32], bits_per_element: usize) -> Self

Construct a bit vector by packing a sequence of numerical values into a dense sequence. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The number of bits per element is given by bits_per_element. The sequence is given as a slice of u32 values. If the number of bits per element is smaller than 32, the function takes the least significant bits of each element, and discards the rest. If the number of bits per element is larger than 32, the function will pad the elements with zeros. The function will append the bits of each element to the bit vector in the order they are given in the sequence (i.e. the first element takes bits 0..bits_per_element of the vector).

See also: pack_sequence_u64, pack_sequence_u16, pack_sequence_u8

§Example
use vers_vecs::BitVec;

let sequence = [0b1010u32, 0b1100u32, 0b1111u32];
let bv = BitVec::pack_sequence_u32(&sequence, 4);

assert_eq!(bv.len(), 12);
assert_eq!(bv.get_bits(0, 4), Some(0b1010u64));
assert_eq!(bv.get_bits(4, 4), Some(0b1100u64));
assert_eq!(bv.get_bits(8, 4), Some(0b1111u64));
Source

pub fn pack_sequence_u16(sequence: &[u16], bits_per_element: usize) -> Self

Construct a bit vector by packing a sequence of numerical values into a dense sequence. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The number of bits per element is given by bits_per_element. The sequence is given as a slice of u16 values. If the number of bits per element is smaller than 16, the function takes the least significant bits of each element, and discards the rest. If the number of bits per element is larger than 16, the function will pad the elements with zeros. The function will append the bits of each element to the bit vector in the order they are given in the sequence (i.e. the first element takes bits 0..bits_per_element of the vector).

See also: pack_sequence_u64, pack_sequence_u32, pack_sequence_u8

§Example
use vers_vecs::BitVec;

let sequence = [0b1010u16, 0b1100u16, 0b1111u16];
let bv = BitVec::pack_sequence_u16(&sequence, 4);

assert_eq!(bv.len(), 12);
assert_eq!(bv.get_bits(0, 4), Some(0b1010u64));
assert_eq!(bv.get_bits(4, 4), Some(0b1100u64));
assert_eq!(bv.get_bits(8, 4), Some(0b1111u64));
Source

pub fn pack_sequence_u8(sequence: &[u8], bits_per_element: usize) -> Self

Construct a bit vector by packing a sequence of numerical values into a dense sequence. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The number of bits per element is given by bits_per_element. The sequence is given as a slice of u8 values. If the number of bits per element is smaller than 8, the function takes the least significant bits of each element, and discards the rest. If the number of bits per element is larger than 8, the function will pad the elements with zeros. The function will append the bits of each element to the bit vector in the order they are given in the sequence (i.e. the first element takes bits 0..bits_per_element of the vector).

See also: pack_sequence_u64, pack_sequence_u32, pack_sequence_u16

§Example
use vers_vecs::BitVec;

let sequence = [0b1010u8, 0b1100u8, 0b1111u8];
let bv = BitVec::pack_sequence_u8(&sequence, 4);

assert_eq!(bv.len(), 12);
assert_eq!(bv.get_bits(0, 4), Some(0b1010u64));
assert_eq!(bv.get_bits(4, 4), Some(0b1100u64));
assert_eq!(bv.get_bits(8, 4), Some(0b1111u64));
Source

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

Append a bit encoded as a bool to the bit vector, where true means 1 and false means 0.

See also: append_bit, append_bit_u32, append_bit_u16, append_bit_u8, append_word

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::new();
bv.append(true);

assert_eq!(bv.len(), 1);
assert_eq!(bv.get(0), Some(1));
Source

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

Drop the last n bits from the bit vector. If more bits are dropped than the bit vector contains, the bit vector is cleared.

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::from_bits(&[1, 0, 1, 1, 1, 1]);
bv.drop_last(3);

assert_eq!(bv.len(), 3);
assert_eq!(bv.get_bits(0, 3), Some(0b101u64));

bv.drop_last(4);

assert!(bv.is_empty());
Source

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

Append a bit encoded in a u64. The least significant bit is appended to the bit vector. All other bits are ignored.

See also: append, append_bit_u32, append_bit_u16, append_bit_u8, append_word

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::new();

bv.append_bit(1);
bv.append_bit(0);

assert_eq!(bv.len(), 2);
assert_eq!(bv.get(0), Some(1));
assert_eq!(bv.get(1), Some(0));
Source

pub fn append_bit_u32(&mut self, bit: u32)

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

See also: append, append_bit, append_bit_u16, append_bit_u8, append_word

Source

pub fn append_bit_u16(&mut self, bit: u16)

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

See also: append, append_bit, append_bit_u32, append_bit_u8, append_word

Source

pub fn append_bit_u8(&mut self, bit: u8)

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

See also: append, append_bit, append_bit_u32, append_bit_u16, append_word

Source

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

Append a word to the bit vector. The bits are appended in little endian order (i.e. the first bit of the word is appended first).

See also: append, append_bit, append_bit_u32, append_bit_u16, append_bit_u8

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::new();
bv.append_word(0b1010_1010_1010_1010u64);

assert_eq!(bv.len(), 64);
for i in 0..64 {
   assert_eq!(bv.get(i), Some((0b1010_1010_1010_1010u64 >> i) & 1));
}
Source

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

Append multiple bits to the bit vector. The bits are appended in little-endian order (i.e. 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.

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::new();
bv.append_bits(0b1010_1010_1010_1010u64, 16);

assert_eq!(bv.len(), 16);
assert_eq!(bv.get_bits(0, 16), Some(0b1010_1010_1010_1010u64));
§Panics

Panics if len is larger than 64.

Source

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

Append multiple bits to the bit vector. The bits are appended in little-endian order (i.e. 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.

This function does not check if len is larger than 64.

Furthermore, if the bit-vector has trailing bits that are not zero (i.e. the length is not a multiple of 64, and those bits are partially set), the function will OR the new data with the trailing bits, destroying the appended data. This can happen, if a call append_bits[_unchecked](word, len) appends a word which has set bits beyond the len - 1-th bit, or if bits have been dropped from the bit vector using drop_last.

See append_bits for a checked version of this function.

§Panics

If len is larger than 64, the behavior is platform-dependent, and a processor exception might be triggered.

Source

pub fn extend_bitvec(&mut self, other: &Self)

Append the bits of another bit vector to the end of this vector. If this vector does not contain a multiple of 64 bits, the appended limbs need to be shifted to the left. This function is guaranteed to reallocate the underlying vector at most once.

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.

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::from_bits(&[1, 0, 1, 1, 1, 1]);
bv.flip_bit(1);

assert_eq!(bv.len(), 6);
assert_eq!(bv.get_bits(0, 6), Some(0b111111u64));
§Panics

If the position is larger than the length of the vector, the function panics.

Source

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

Flip the bit at the given position.

See also: flip_bit

§Panics

If the position is larger than the length of the vector, the function will either modify unused memory or panic. This will not corrupt memory.

Source

pub fn get(&self, pos: usize) -> Option<u64>

Return the bit at the given position. The bit is encoded in the least significant bit of a u64 value. If the position is larger than the length of the vector, None is returned.

See also: get_unchecked

§Example
use vers_vecs::BitVec;

let bv = BitVec::from_bits(&[1, 0, 1, 1, 1, 1]);

assert_eq!(bv.get(1), Some(0));
assert_eq!(bv.get(2), Some(1));
Source

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

Return the bit at the given position. The bit is encoded in the least significant bit of a u64 value.

§Panics

If the position is larger than the length of the vector, the function will either return unpredictable data, or panic. Use get to properly handle this case with an Option.

Source

pub fn set(&mut self, pos: usize, value: u64) -> Result<(), &str>

Set the bit at the given position. The bit is encoded in the least significant bit of a u64 value.

See also: set_unchecked

§Example
use vers_vecs::BitVec;

let mut bv = BitVec::from_bits(&[1, 0, 1, 1, 1, 1]);
bv.set(1, 1).unwrap();

assert_eq!(bv.len(), 6);
assert_eq!(bv.get_bits(0, 6), Some(0b111111u64));
§Errors

If the position is out of range, the function will return Err with an error message, otherwise it will return an empty Ok.

Source

pub fn set_unchecked(&mut self, pos: usize, value: u64)

Set the bit at the given position. The bit is encoded in the least significant bit of a u64 value.

§Panics

If the position is larger than the length of the vector, the function will either do nothing, or panic. Use set to properly handle this case with a Result.

Source

pub fn is_bit_set(&self, pos: usize) -> Option<bool>

Return whether the bit at the given position is set. If the position is larger than the length of the vector, None is returned.

See also: is_bit_set_unchecked

§Example
use vers_vecs::BitVec;

let bv = BitVec::from_bits(&[1, 0, 1, 1, 1, 1]);

assert!(!bv.is_bit_set(1).unwrap());
assert!(bv.is_bit_set(2).unwrap());
Source

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

Return whether the bit at the given position is set.

§Panics

If the position is larger than the length of the vector, the function will either return unpredictable data, or panic. Use is_bit_set to properly handle this case with an Option.

Source

pub fn get_bits(&self, pos: usize, len: usize) -> Option<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. If the position at the end of the query is larger than the length of the vector, None is returned (even if the query partially overlaps with the vector). If the length of the query is larger than 64, None is returned.

The first bit at pos is the most significant bit of the return value limited to len bits.

Source

pub fn get_bits_unchecked(&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.

This function is always inlined, because it gains a lot from loop optimization and can utilize the processor pre-fetcher better if it is.

§Errors

If the length of the query is larger than 64, unpredictable data will be returned. Use get_bits to avoid this.

§Panics

If the position or interval is larger than the length of the vector, the function will either return any valid results padded with unpredictable data or panic.

Source

pub fn unpack_element(&self, index: usize, n: usize) -> Option<u64>

Extract a packed element from a bit vector. The element is encoded in the bits at the given index. The number of bits per encoded element is given by n.

This is a convenience method to access elements previously packed using the pack_sequence_* methods, and is equivalent to calling get_bits(index * n, n). It is thus safe to use this method with any index and any size n <= 64.

If the element is out of bounds, None is returned. The element is returned as a u64 value.

§Example
use vers_vecs::BitVec;

let sequence = [10, 100, 124, 45, 223];
let bv = BitVec::pack_sequence_u64(&sequence, 8);

assert_eq!(bv.unpack_element(0, 8), Some(10));
assert_eq!(bv.unpack_element(2, 8), Some(124));
Source

pub fn unpack_element_unchecked(&self, index: usize, n: usize) -> u64

Extract a packed element from a bit vector. The element is encoded in the bits at the given index. The number of bits per encoded element is given by n.

This is a convenience method to access elements previously packed using the pack_sequence_* methods, and is equivalent to calling get_bits_unchecked(index * n, n). It is thus safe to use this method with any index where index * n + n is in-bounds, and any size n <= 64.

§Panics

If the element is out of bounds, the function will either return unpredictable data or panic. Use unpack_element for a checked version of this function.

Source

pub fn count_ones(&self) -> u64

Return the number of ones in the bit vector. Since the bit vector doesn’t store additional metadata, this value is calculated. Use RsVec for constant-time rank operations.

Source

pub fn count_zeros(&self) -> u64

Return the number of zeros in the bit vector. Since the bit vector doesn’t store additional metadata, this value is calculated. Use RsVec for constant-time rank operations. This method calls count_ones.

Source

pub fn mask_or<'s, 'b>( &'s self, mask: &'b BitVec, ) -> Result<BitMask<'s, 'b>, String>

Mask this bit vector with another bitvector using bitwise or. The mask is applied lazily whenever an operation on the resulting vector is performed.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn apply_mask_or(&mut self, mask: &BitVec) -> Result<(), String>

Mask this bit vector with another bitvector using bitwise or. The mask is applied immediately, unlike in mask_or.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn mask_and<'s, 'b>( &'s self, mask: &'b BitVec, ) -> Result<BitMask<'s, 'b>, String>

Mask this bit vector with another bitvector using bitwise and. The mask is applied lazily whenever an operation on the resulting vector is performed.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn apply_mask_and(&mut self, mask: &BitVec) -> Result<(), String>

Mask this bit vector with another bitvector using bitwise and. The mask is applied immediately, unlike in mask_and.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn mask_xor<'s, 'b>( &'s self, mask: &'b BitVec, ) -> Result<BitMask<'s, 'b>, String>

Mask this bit vector with another bitvector using bitwise xor. The mask is applied lazily whenever an operation on the resulting vector is performed.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn apply_mask_xor(&mut self, mask: &BitVec) -> Result<(), String>

Mask this bit vector with another bitvector using bitwise xor. The mask is applied immediately, unlike in mask_xor.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn mask_custom<'s, 'b, F>( &'s self, mask: &'b BitVec, mask_op: F, ) -> Result<MaskedBitVec<'s, 'b, F>, String>
where F: Fn(u64, u64) -> u64,

Mask this bit vector with another bitvector using a custom masking operation. The mask is applied lazily whenever an operation on the resulting vector is performed.

The masking operation takes two 64 bit values which contain blocks of 64 bits each. The last block of a bit vector might contain fewer bits, and will be padded with unpredictable data. Implementations may choose to modify those padding bits without repercussions. Implementations shouldn’t use operations like bit shift, because the bit order within the vector is unspecified.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

Source

pub fn apply_mask_custom( &mut self, mask: &BitVec, mask_op: fn(u64, u64) -> u64, ) -> Result<(), String>

Mask this bit vector with another bitvector using a custom masking operation. The mask is applied immediately, unlike in mask_custom.

The masking operation takes two 64 bit values which contain blocks of 64 bits each. The last block of a bit vector might contain fewer bits, and will be padded with unpredictable data. Implementations may choose to modify those padding bits without repercussions. Implementations shouldn’t use operations like bit shift, because the bit order within the vector is unspecified.

§Errors

Returns an error if the length of the vector doesn’t match the mask length.

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.

Source

pub fn split_at(self, at: usize) -> Result<(Self, Self), Self>

Split the vector in two at the specified index. The left half contains bits 0..at and the right half the remaining bits at... If the split index is larger than the length of the vector, the vector is returned unmodified in an Err variant.

§Errors

If the index is out of bounds, the function will return an error containing the original vector.

See also: split_at_unchecked

Source

pub fn split_at_unchecked(self, at: usize) -> (Self, Self)

Split the vector in two at the specified index. The left half contains bits 0..at and the right half the remaining bits at...

§Panics

If the index is larger than the length of the vector the function will panic or run out of memory. Use split_at to properly handle this case.

Source§

impl BitVec

Source

pub fn iter(&self) -> BitVecRefIter<'_>

Returns an iterator over the elements of BitVec. The iterator returns u64 elements.

Trait Implementations§

Source§

impl Clone for BitVec

Source§

fn clone(&self) -> BitVec

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 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() -> BitVec

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

impl<'de> Deserialize<'de> for BitVec

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'t> Extend<&'t BitVec> for BitVec

Source§

fn extend<T: IntoIterator<Item = &'t BitVec>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<BitVec> for BitVec

Source§

fn extend<T: IntoIterator<Item = BitVec>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&[u64]> for BitVec

Create a new bit vector from a slice of u64 values. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The function will append the bits of each element to the bit vector in the order they are given in the slice (i.e. the first element takes bits 0..64 of the vector).

Source§

fn from(data: &[u64]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a BitVec> for SparseRSVec

Source§

fn from(input: &'a BitVec) -> Self

Converts to this type from the input type.
Source§

impl<const BLOCK_SIZE: usize> From<BitVec> for BpTree<BLOCK_SIZE>

Source§

fn from(bv: BitVec) -> Self

Converts to this type from the input type.
Source§

impl From<BitVec> for RsVec

Source§

fn from(vec: BitVec) -> Self

Build an RsVec from a BitVec. This will consume the BitVec. Since RsVecs are immutable, this is the only way to construct an RsVec.

§Example

See the example for RsVec.

Source§

impl From<BitVec> for SparseRSVec

Source§

fn from(input: BitVec) -> Self

Converts to this type from the input type.
Source§

impl<const BLOCK_SIZE: usize> From<BpTree<BLOCK_SIZE>> for BitVec

Source§

fn from(value: BpTree<BLOCK_SIZE>) -> Self

Converts to this type from the input type.
Source§

impl From<RsVec> for BitVec

Source§

fn from(value: RsVec) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u64>> for BitVec

Create a new bit vector from a slice of u64 values. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The function will append the bits of each element to the bit vector in the order they are given in the slice (i.e. the first element takes bits 0..64 of the vector).

Source§

fn from(data: Vec<u64>) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<u64> for BitVec

Create a new bit vector from u64 values. The bits are appended in little-endian order (i.e. the least significant bit is appended first). The function will append the bits of each element to the bit vector in the order they are given in the iterator (i.e. the first element takes bits 0..64 of the vector).

Source§

fn from_iter<T: IntoIterator<Item = u64>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for BitVec

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a BitVec

Source§

type Item = u64

The type of the elements being iterated over.
Source§

type IntoIter = BitVecRefIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut BitVec

Source§

type Item = u64

The type of the elements being iterated over.
Source§

type IntoIter = BitVecRefIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for BitVec

Source§

type Item = u64

The type of the elements being iterated over.
Source§

type IntoIter = BitVecIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for BitVec

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BitVec

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for BitVec

Auto Trait Implementations§

§

impl Freeze for BitVec

§

impl RefUnwindSafe for BitVec

§

impl Send for BitVec

§

impl Sync for BitVec

§

impl Unpin for BitVec

§

impl UnwindSafe for BitVec

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,