pub struct BooleanBufferBuilder { /* private fields */ }Expand description
Implementations§
Source§impl BooleanBufferBuilder
impl BooleanBufferBuilder
Sourcepub fn new(capacity: usize) -> BooleanBufferBuilder
pub fn new(capacity: usize) -> BooleanBufferBuilder
Creates a new BooleanBufferBuilder with sufficient space for
capacity bits (not bytes).
The capacity is rounded up to the nearest multiple of 8 for the allocation.
Sourcepub fn new_from_buffer(
buffer: MutableBuffer,
len: usize,
) -> BooleanBufferBuilder
pub fn new_from_buffer( buffer: MutableBuffer, len: usize, ) -> BooleanBufferBuilder
Creates a new BooleanBufferBuilder from MutableBuffer of len
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of the buffer, in bits (not bytes)
Note this
§Example
// empty requires 0 bytes
let b = BooleanBufferBuilder::new(0);
assert_eq!(0, b.capacity());
// Creating space for 1 bit results in 64 bytes (space for 512 bits)
// (64 is the minimum allocation size for 64 bit architectures)
let mut b = BooleanBufferBuilder::new(1);
assert_eq!(512, b.capacity());
// 1000 bits requires 128 bytes (space for 1024 bits)
b.append_n(1000, true);
assert_eq!(1024, b.capacity());Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncates the builder to the given length
If len is greater than the buffer’s current length, this has no effect
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserve space to at least additional new bits.
Capacity will be >= self.len() + additional.
New bytes are uninitialized and reading them is undefined behavior.
Sourcepub fn resize(&mut self, len: usize)
pub fn resize(&mut self, len: usize)
Resizes the buffer, either truncating its contents (with no change in capacity), or
growing it (potentially reallocating it) and writing false in the newly available bits.
Sourcepub fn append_n(&mut self, additional: usize, v: bool)
pub fn append_n(&mut self, additional: usize, v: bool)
Appends n additional bits of value v into the buffer
Sourcepub fn append_slice(&mut self, slice: &[bool])
pub fn append_slice(&mut self, slice: &[bool])
Appends a slice of booleans into the buffer
Sourcepub fn append_packed_range(&mut self, range: Range<usize>, to_set: &[u8])
pub fn append_packed_range(&mut self, range: Range<usize>, to_set: &[u8])
Append range bits from to_set
to_set is a slice of bits packed LSB-first into [u8]
§Panics
Panics if to_set does not contain ceil(range.end / 8) bytes
Sourcepub fn append_buffer(&mut self, buffer: &BooleanBuffer)
pub fn append_buffer(&mut self, buffer: &BooleanBuffer)
Append BooleanBuffer to this BooleanBufferBuilder
Sourcepub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
Returns the packed bits
Sourcepub fn finish(&mut self) -> BooleanBuffer
pub fn finish(&mut self) -> BooleanBuffer
Creates a BooleanBuffer
Sourcepub fn finish_cloned(&self) -> BooleanBuffer
pub fn finish_cloned(&self) -> BooleanBuffer
Builds the BooleanBuffer without resetting the builder.
Trait Implementations§
Source§impl Debug for BooleanBufferBuilder
impl Debug for BooleanBufferBuilder
Source§impl From<BooleanBufferBuilder> for BooleanBuffer
impl From<BooleanBufferBuilder> for BooleanBuffer
Source§fn from(builder: BooleanBufferBuilder) -> BooleanBuffer
fn from(builder: BooleanBufferBuilder) -> BooleanBuffer
Auto Trait Implementations§
impl Freeze for BooleanBufferBuilder
impl RefUnwindSafe for BooleanBufferBuilder
impl Send for BooleanBufferBuilder
impl Sync for BooleanBufferBuilder
impl Unpin for BooleanBufferBuilder
impl UnwindSafe for BooleanBufferBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more