pub trait BitVector: Clone + Eq + Display + From<Vec<bool>> {
Show 13 methods fn empty(len: usize) -> Self;
fn len(&self) -> usize;
fn get(&self, index: usize) -> bool;
fn set(&mut self, index: usize, value: bool);
fn flip(&mut self, index: usize); fn max_length() -> usize { ... }
fn from_ones(len: usize, items: Vec<usize>) -> Self { ... }
fn values(&self) -> Vec<bool>Notable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
    A: Allocator
{ ... }
fn ones(&self) -> Vec<usize>Notable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
    A: Allocator
{ ... }
fn zeros(&self) -> Vec<usize>Notable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
    A: Allocator
{ ... }
fn display(&self, f: &mut Formatter<'_>) -> Result<(), Error> { ... }
fn from_bool_vector(items: Vec<bool>) -> Self { ... }
fn is_empty(&self) -> bool { ... }
}
Expand description

BitVector is a collection of boolean values of a fixed length.

When implementing Display and From<Vec<bool>>, please consult BitVector::display and BitVector::from_bool_vector.

Required methods

Create a new BitVector with the given length. Can panic if this implementation does not support the specified length. Once created, the length cannot be changed.

The number of elements stored in this BitVector.

Get the boolean value at the given index.

Set the boolean value at the given index.

Invert the value at the given index.

Provided methods

If a BitVector implementation cannot handle arbitrary vector lengths, it can use this method to declare the largest bitvector it can handle.

Create a new BitVector which contains items specified in the given vector.

Return a vector of the values in this BitVector.

A vector of the indices of this BitVector which are set.

A vector of the indices of this BitVector which are not set.

A helper method for Display trait implementations for all variants of BitVector. Please use this method (or an equivalent display format) for all Display implementations of BitVectors.

If you wish to provide a custom display format, wrap the BitVector into some domain-specific struct and implement a different Display for this struct. By providing this default implementation, we are ensuring that all BitVector implementations are “visually indistinguishable” to the user.

You are still free to provide your own domain-specific Debug display method though!

A helper method for converting a vector of Booleans into a BitVector. Useful when implementing From<Vec<bool>>.

Implementors