pub struct Bitmap { /* private fields */ }
Expand description
An immutable container whose API is optimized to handle bitmaps. All quantities on this container’s API are measured in bits.
Implementation
Implementations
sourceimpl Bitmap
impl Bitmap
sourcepub fn new_zeroed(length: usize) -> Self
pub fn new_zeroed(length: usize) -> Self
Initializes an new Bitmap
filled with unset values.
sourcepub fn from_u8_vec(vec: Vec<u8>, length: usize) -> Self
pub fn from_u8_vec(vec: Vec<u8>, length: usize) -> Self
sourcepub fn null_count_range(&self, offset: usize, length: usize) -> usize
pub fn null_count_range(&self, offset: usize, length: usize) -> usize
Counts the nulls (unset bits) starting from offset
bits and for length
bits.
sourcepub fn null_count(&self) -> usize
pub fn null_count(&self) -> usize
Returns the number of unset bits on this Bitmap
.
sourcepub fn slice(self, offset: usize, length: usize) -> Self
pub fn slice(self, offset: usize, length: usize) -> Self
Slices self
, offsetting by offset
and truncating up to length
bits.
Panic
Panics iff self.offset + offset + length >= self.bytes.len() * 8
, i.e. if the offset and length
exceeds the allocated capacity of self
.
sourcepub unsafe fn slice_unchecked(self, offset: usize, length: usize) -> Self
pub unsafe fn slice_unchecked(self, offset: usize, length: usize) -> Self
Slices self
, offseting by offset
and truncating up to length
bits.
Safety
The caller must ensure that self.offset + offset + length <= self.len()
sourcepub unsafe fn get_bit_unchecked(&self, i: usize) -> bool
pub unsafe fn get_bit_unchecked(&self, i: usize) -> bool
sourcepub fn into_mut(self) -> Either<Self, MutableBitmap>ⓘNotable traits for Either<L, R>impl<L, R> Iterator for Either<L, R> where
L: Iterator,
R: Iterator<Item = <L as Iterator>::Item>, type Item = <L as Iterator>::Item;impl<L, R> Read for Either<L, R> where
L: Read,
R: Read, impl<L, R> Write for Either<L, R> where
L: Write,
R: Write,
pub fn into_mut(self) -> Either<Self, MutableBitmap>ⓘNotable traits for Either<L, R>impl<L, R> Iterator for Either<L, R> where
L: Iterator,
R: Iterator<Item = <L as Iterator>::Item>, type Item = <L as Iterator>::Item;impl<L, R> Read for Either<L, R> where
L: Read,
R: Read, impl<L, R> Write for Either<L, R> where
L: Write,
R: Write,
L: Iterator,
R: Iterator<Item = <L as Iterator>::Item>, type Item = <L as Iterator>::Item;impl<L, R> Read for Either<L, R> where
L: Read,
R: Read, impl<L, R> Write for Either<L, R> where
L: Write,
R: Write,
Converts this Bitmap
to MutableBitmap
, returning itself if the conversion
is not possible
This operation returns a MutableBitmap
iff:
sourceimpl Bitmap
impl Bitmap
sourcepub unsafe fn from_trusted_len_iter_unchecked<I: Iterator<Item = bool>>(
iterator: I
) -> Self
pub unsafe fn from_trusted_len_iter_unchecked<I: Iterator<Item = bool>>(
iterator: I
) -> Self
sourcepub fn from_trusted_len_iter<I: TrustedLen<Item = bool>>(iterator: I) -> Self
pub fn from_trusted_len_iter<I: TrustedLen<Item = bool>>(iterator: I) -> Self
Creates a new Bitmap
from an iterator of booleans.
sourcepub fn try_from_trusted_len_iter<E, I: TrustedLen<Item = Result<bool, E>>>(
iterator: I
) -> Result<Self, E>
pub fn try_from_trusted_len_iter<E, I: TrustedLen<Item = Result<bool, E>>>(
iterator: I
) -> Result<Self, E>
Creates a new Bitmap
from a fallible iterator of booleans.
sourceimpl Bitmap
impl Bitmap
sourcepub fn as_slice(&self) -> (&[u8], usize, usize)
pub fn as_slice(&self) -> (&[u8], usize, usize)
Returns the byte slice of this Bitmap.
The returned tuple contains:
.1 -> The byte slice, truncated to the start of the first bit. So the start of the slice
is within the first 8 bits.
.2 -> The start offset in bits, given what described above 0 <= offsets < 8
.
.3 -> The length in bits.
sourceimpl<'a> Bitmap
impl<'a> Bitmap
sourcepub fn iter(&'a self) -> BitmapIter<'a>ⓘNotable traits for BitmapIter<'a>impl<'a> Iterator for BitmapIter<'a> type Item = bool;
pub fn iter(&'a self) -> BitmapIter<'a>ⓘNotable traits for BitmapIter<'a>impl<'a> Iterator for BitmapIter<'a> type Item = bool;
constructs a new iterator
Trait Implementations
sourceimpl From<MutableBitmap> for Bitmap
impl From<MutableBitmap> for Bitmap
sourcefn from(buffer: MutableBitmap) -> Self
fn from(buffer: MutableBitmap) -> Self
Performs the conversion.
sourceimpl FromIterator<bool> for Bitmap
impl FromIterator<bool> for Bitmap
sourcefn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = bool>,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = bool>,
Creates a value from an iterator. Read more
sourceimpl<'a> IntoIterator for &'a Bitmap
impl<'a> IntoIterator for &'a Bitmap
Auto Trait Implementations
impl RefUnwindSafe for Bitmap
impl Send for Bitmap
impl Sync for Bitmap
impl Unpin for Bitmap
impl UnwindSafe for Bitmap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more