Struct bitvec_rs::BitVec
[−]
[src]
pub struct BitVec { /* fields omitted */ }
Bit vector with guaranteed [u8]
representation and safe mutable access to this slice.
Slices into the bit vector are guaranteed to have the unused bits on the last set to 0.
Methods
impl BitVec
[src]
fn new() -> BitVec
Constructs an empty BitVec
.
fn from_bytes(bytes: &[u8]) -> BitVec
Constructs a BitVec
from bytes.
fn from_elem(len: usize, value: bool) -> BitVec
Constructs a BitVec
from a repeating bit value.
fn as_bytes(&self) -> &[u8]
Returns a byte slice view of the data.
fn with_bytes_mut<U, F: FnOnce(&mut [u8]) -> U>(&mut self, f: F) -> U
Invokes the given function on a mut byte slice view of the data. After f
completes, the
trailing unused bits of the last byte are automatically set to 0.
fn into_vec(self) -> Vec<u8>
Consumes the self
and returns the underlying Vec<u8>
of length ceil(self.len()/8)
.
The values of the bits in the last byte of Vec<u8>
beyond the length of the BitVec
are
unspecified.
fn len(&self) -> usize
Returns the length of the bit vector.
fn get(&self, index: usize) -> Option<bool>
Gets the bit at the given index
.
fn set(&mut self, index: usize, value: bool)
Sets the bit at the given index
. Panics if index
exceeds length.
fn swap(&mut self, i: usize, j: usize)
Swaps two elements in the BitVec
.
unsafe fn get_unchecked(&self, index: usize) -> bool
Gets the bit at the given index
without bounds checking.
unsafe fn set_unchecked(&mut self, index: usize, value: bool)
Sets the bit at the given index
without bounds checking.
fn push(&mut self, value: bool)
Pushes a boolean to the end of the BitVec
.
fn pop(&mut self) -> Option<bool>
Pops a boolean from the end of the BitVec
.
fn clear(&mut self)
Clears the BitVec
, removing all values.
fn capacity(&mut self) -> usize
Returns the number of booleans that the bitvec can hold without reallocating.
fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more booleans to be inserted in the given
BitVec
. The collection may reserve more space to avoid frequent reallocations.
fn truncate(&mut self, len: usize)
Shorten a vector, dropping excess elements.
If len
is greater than the vector's current length, this has no effect.
fn resize(&mut self, new_len: usize, value: bool)
Reserves capacity for at least additional more booleans to be inserted in the given
BitVec
. The collection may reserve more space to avoid frequent reallocations.
fn iter(&self) -> Iter
Returns an iterator for the booleans in the array.
Trait Implementations
impl Clone for BitVec
[src]
fn clone(&self) -> BitVec
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Eq for BitVec
[src]
impl PartialEq<BitVec> for BitVec
[src]
fn eq(&self, other: &BitVec) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Debug for BitVec
[src]
impl Display for BitVec
[src]
impl Extend<bool> for BitVec
[src]
fn extend<T>(&mut self, iterable: T) where
T: IntoIterator<Item = bool>,
T: IntoIterator<Item = bool>,
Extends a collection with the contents of an iterator. Read more
impl<'a> Extend<&'a bool> for BitVec
[src]
fn extend<T>(&mut self, iterable: T) where
T: IntoIterator<Item = &'a bool>,
T: IntoIterator<Item = &'a bool>,
Extends a collection with the contents of an iterator. Read more