Struct yabf::SmallYabf [−][src]
pub struct SmallYabf { /* fields omitted */ }
Expand description
Yet another bit field implementation. This is a simple, small and hopefully efficient bit field implementation. It uses SmallVec as an internal container. The first 128 bits will be stored on the stack.
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.
Will create a heap allocation only if n
is larger than the inline capacity of the
internal SmallVec.
let bf = SmallYabf::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 = SmallYabf::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 = SmallYabf::default();
assert!(bf.is_empty());
assert!(!bf.bit(10));
bf.set_bit(10,true);
assert!(bf.bit(10));
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
.
Trait Implementations
bit or assign operation This is a relatively expensive O(size of container) operation.
let mut a = SmallYabf::default();
let mut b = SmallYabf::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
Auto Trait Implementations
impl RefUnwindSafe for SmallYabf
impl UnwindSafe for SmallYabf
Blanket Implementations
Mutably borrows from an owned value. Read more