pub struct BitBufferMut { /* private fields */ }Expand description
A mutable bitset buffer that allows random access to individual bits for set and get.
§Example
use vortex_buffer::BitBufferMut;
let mut bools = BitBufferMut::new_unset(10);
bools.set_to(9, true);
for i in 0..9 {
assert!(!bools.value(i));
}
assert!(bools.value(9));
// Freeze into a new bools vector.
let bools = bools.freeze();See also: BitBuffer.
Implementations§
Source§impl BitBufferMut
impl BitBufferMut
Sourcepub fn from_buffer(buffer: ByteBufferMut, offset: usize, len: usize) -> Self
pub fn from_buffer(buffer: ByteBufferMut, offset: usize, len: usize) -> Self
Create new bit buffer from given byte buffer and logical bit length
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new empty mutable bit buffer with requested capacity (in bits).
Sourcepub fn new_set(len: usize) -> Self
pub fn new_set(len: usize) -> Self
Create a new mutable buffer with requested len and all bits set to true.
Sourcepub fn new_unset(len: usize) -> Self
pub fn new_unset(len: usize) -> Self
Create a new mutable buffer with requested len and all bits set to false.
Sourcepub fn full(value: bool, len: usize) -> Self
pub fn full(value: bool, len: usize) -> Self
Create a new mutable buffer with requested len and all bits set to value.
Sourcepub unsafe fn value_unchecked(&self, index: usize) -> bool
pub unsafe fn value_unchecked(&self, index: usize) -> bool
Get the value at the requested index without bounds checking.
§Safety
The caller must ensure that index is less than the length of the buffer.
Sourcepub fn set_to(&mut self, index: usize, value: bool)
pub fn set_to(&mut self, index: usize, value: bool)
Set the bit at index to the given boolean value.
This operation is checked so if index exceeds the buffer length, this will panic.
Sourcepub unsafe fn set_to_unchecked(&mut self, index: usize, value: bool)
pub unsafe fn set_to_unchecked(&mut self, index: usize, value: bool)
Set the bit at index to the given boolean value without checking bounds.
§Safety
The caller must ensure that index does not exceed the largest bit index in the backing buffer.
Sourcepub fn set(&mut self, index: usize)
pub fn set(&mut self, index: usize)
Set a position to true.
This operation is checked so if index exceeds the buffer length, this will panic.
Sourcepub fn unset(&mut self, index: usize)
pub fn unset(&mut self, index: usize)
Set a position to false.
This operation is checked so if index exceeds the buffer length, this will panic.
Sourcepub unsafe fn set_unchecked(&mut self, index: usize)
pub unsafe fn set_unchecked(&mut self, index: usize)
Set the bit at index to true without checking bounds.
§Safety
The caller must ensure that index does not exceed the largest bit index in the backing buffer.
Sourcepub unsafe fn unset_unchecked(&mut self, index: usize)
pub unsafe fn unset_unchecked(&mut self, index: usize)
Unset the bit at index without checking bounds.
§Safety
The caller must ensure that index does not exceed the largest bit index in the backing buffer.
Sourcepub fn append(&mut self, value: bool)
pub fn append(&mut self, value: bool)
Append a new boolean into the bit buffer, incrementing the length.
Sourcepub fn append_true(&mut self)
pub fn append_true(&mut self)
Append a new true value to the buffer.
Sourcepub fn append_false(&mut self)
pub fn append_false(&mut self)
Append a new false value to the buffer.
Sourcepub fn append_n(&mut self, value: bool, n: usize)
pub fn append_n(&mut self, value: bool, n: usize)
Append several boolean values into the bit buffer. After this operation,
the length will be incremented by n.
Panics if the buffer does not have n slots left.
Sourcepub fn append_buffer(&mut self, buffer: &BitBuffer)
pub fn append_buffer(&mut self, buffer: &BitBuffer)
Append a BitBuffer to this BitBufferMut
This efficiently copies all bits from the source buffer to the end of this buffer.
Sourcepub fn freeze(self) -> BitBuffer
pub fn freeze(self) -> BitBuffer
Freeze the buffer in its current state into an immutable BoolBuffer.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Get the underlying bytes as a mutable slice
Trait Implementations§
Source§impl Default for BitBufferMut
impl Default for BitBufferMut
Source§impl From<&[bool]> for BitBufferMut
impl From<&[bool]> for BitBufferMut
Source§impl FromIterator<bool> for BitBufferMut
impl FromIterator<bool> for BitBufferMut
Auto Trait Implementations§
impl Freeze for BitBufferMut
impl RefUnwindSafe for BitBufferMut
impl Send for BitBufferMut
impl Sync for BitBufferMut
impl Unpin for BitBufferMut
impl UnwindSafe for BitBufferMut
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.