Struct yabf::Yabf[][src]

pub struct Yabf { /* fields omitted */ }
Expand description

Yet another bit field implementation. This is a simple, small and hopefully efficient bit field implementation.

It is intended for cases where a program iterates over list or other usize indexed containers and simple bit based bookkeeping is required.

Implementations

Construct an empty bit field with enough capacity pre-allocated to store at least n bits.


let bf = Yabf::with_capacity(100);

assert!(bf.is_empty());
assert!(bf.capacity() >= 100);

Returns the value of the ‘n’:th bit in the bit field.


let mut bf = Yabf::default();

assert!(bf.is_empty());
assert!(!bf.bit(10));
bf.set_bit(10,true);
assert!(bf.bit(10));

Sets the ‘n’:th bit in the bit field. If the bit field capacity is not large enough more space will be allocated.


let mut bf = Yabf::default();

assert!(bf.is_empty());
assert!(!bf.bit(10));
bf.set_bit(10,true);
assert!(bf.bit(10));

Returns true if all bits are set to false

The number of bits the bit field can hold without reallocating

The len() of the internal vector

Reserve capacity for additional_bits more bits to be inserted.

May reserve more space to avoid frequent re-allocations.

Panics if the capacity computation overflows usize.

Remove all elements from the vector. This method simply delegates clear() to the underlying vector std::vec::Vec or smallvec::SmallVec. So what actually happen depends on the feature set.

Trait Implementations

bit or assign operation. This is a relatively expensive O(size of container) operation.


let mut a = Yabf::default();
let mut b = Yabf::default();
a.set_bit(45,true);
b.set_bit(12345,true);
assert!(!a.bit(12345));
assert!(a.bit(45));
a |= &b;
assert!(a.bit(12345));
assert!(a.bit(45));

Performs the |= operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.