Struct smallbitvec::SmallBitVec
[−]
[src]
pub struct SmallBitVec { /* fields omitted */ }A resizable bit vector, optimized for size and inline storage.
SmallBitVec is exactly one word wide. Depending on the required capacity, this word
either stores the bits inline, or it stores a pointer to a separate buffer on the heap.
Methods
impl SmallBitVec[src]
pub fn new() -> SmallBitVec[src]
Create an empty vector.
pub fn from_elem(len: u32, val: bool) -> SmallBitVec[src]
Create a vector containing len bits, each set to val.
pub fn with_capacity(cap: u32) -> SmallBitVec[src]
Create an empty vector with enough storage pre-allocated to store at least cap bits
without resizing.
pub fn len(&self) -> u32[src]
The number of bits stored in this bit vector.
pub fn is_empty(&self) -> bool[src]
Returns true if this vector contains no bits.
pub fn capacity(&self) -> u32[src]
The number of bits that can be stored in this bit vector without re-allocating.
pub fn get(&self, n: u32) -> bool[src]
Get the nth bit in this bit vector. Panics if the index is out of bounds.
pub unsafe fn get_unchecked(&self, n: u32) -> bool[src]
Get the nth bit in this bit vector, without bounds checks.
pub fn set(&mut self, n: u32, val: bool)[src]
Set the nth bit in this bit vector to val. Panics if the index is out of bounds.
pub unsafe fn set_unchecked(&mut self, n: u32, val: bool)[src]
Set the nth bit in this bit vector to val, without bounds checks.
pub fn push(&mut self, val: bool)[src]
Append a bit to the end of the vector.
use smallbitvec::SmallBitVec; let mut v = SmallBitVec::new(); v.push(true); assert_eq!(v.len(), 1); assert_eq!(v.get(0), true);
pub fn pop(&mut self) -> Option<bool>[src]
Remove the last bit from the vector and return it, if there is one.
use smallbitvec::SmallBitVec; let mut v = SmallBitVec::new(); v.push(false); assert_eq!(v.pop(), Some(false)); assert_eq!(v.len(), 0); assert_eq!(v.pop(), None);
pub fn remove(&mut self, idx: u32)[src]
Remove the bit at index idx, shifting all later bits toward the front.
Panics if the index is out of bounds.
pub fn clear(&mut self)[src]
Remove all elements from the vector, without deallocating its buffer.
pub fn reserve(&mut self, additional: u32)[src]
Reserve capacity for at least additional more elements to be inserted.
May reserve more space than requested, to avoid frequent reallocations.
Panics if the new capacity overflows u32.
Re-allocates only if self.capacity() < self.len() + additional.
ⓘImportant traits for Iter<'a>pub fn iter(&self) -> Iter[src]
Returns an iterator that yields the bits of the vector in order, as bool values.
pub fn all_false(&self) -> bool[src]
Returns true if all the bits in the vec are set to zero/false.
pub fn all_true(&self) -> bool[src]
Returns true if all the bits in the vec are set to one/true.
pub fn heap_ptr(&self) -> Option<*const u32>[src]
If the vector owns a heap allocation, returns a pointer to the start of the allocation.
The layout of the data at this allocation is a private implementation detail.
Trait Implementations
impl Debug for SmallBitVec[src]
fn fmt(&self, fmt: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl PartialEq for SmallBitVec[src]
fn eq(&self, other: &Self) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl Eq for SmallBitVec[src]
impl Drop for SmallBitVec[src]
impl Clone for SmallBitVec[src]
fn clone(&self) -> Self[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Hash for SmallBitVec[src]
fn hash<H: Hasher>(&self, state: &mut H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl Extend<bool> for SmallBitVec[src]
fn extend<I: IntoIterator<Item = bool>>(&mut self, iter: I)[src]
Extends a collection with the contents of an iterator. Read more
impl FromIterator<bool> for SmallBitVec[src]
fn from_iter<I: IntoIterator<Item = bool>>(iter: I) -> Self[src]
Creates a value from an iterator. Read more
impl IntoIterator for SmallBitVec[src]
type Item = bool
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
ⓘImportant traits for IntoIterfn into_iter(self) -> IntoIter[src]
Creates an iterator from a value. Read more