Skip to main content

BitmaskV

Struct BitmaskV 

Source
pub struct BitmaskV {
    pub bitmask: Arc<Bitmask>,
    pub offset: usize,
    /* private fields */
}
Expand description

§BitmaskView

Zero-copy, bounds-checked window over a Bitmask.

§Fields

  • bitmask: backing Bitmask (shared via Arc).
  • offset: start bit position in the parent mask.
  • len: number of bits in the view.

§Behaviour

  • All indexing is relative to the view’s start.
  • All accesses are in-bounds (panics if violated).
  • No allocation or buffer copying occurs when creating or slicing views.

§Example

use minarrow::Bitmask;
use minarrow::BitmaskV;

let mask = Bitmask::from_bools(&[true, false, true, true, false]);
let view = BitmaskV::new(mask, 1, 3); // window: false, true, true

assert_eq!(view.len(), 3);
assert!(!view.get(0));
assert!(view.get(1));
assert!(view.get(2));

Fields§

§bitmask: Arc<Bitmask>

The outer bitmask that this view is derived from - we retain a reference to it. Importantly, this is the full bitmask - not the view, and thus should not be accessed as though it were the view subset.

§offset: usize

The index offset from 0 that for where this view starts from the outer bitmask

Implementations§

Source§

impl BitmaskV

Source

pub fn new(bitmask: Bitmask, offset: usize, len: usize) -> BitmaskV

Construct a view over bitmask[offset..offset+len).

Source

pub fn len(&self) -> usize

Returns the length (number of bits) in the view.

Source

pub fn is_empty(&self) -> bool

Returns true if the view is empty.

Source

pub fn get(&self, i: usize) -> bool

Returns the value at logical index i within the view.

Source

pub fn as_bytes_window(&self) -> (&[u8], usize, usize)

Returns a slice of the bitmask’s bytes Due to the booleans being bitpacked in a u8, the slice retains:
Pos 0: Buffer: The bitpacked u8 buffer.
Pos 1: Offset: Bit offset indicating where it starts in that byte.
Pos 2: Length: Logical length in bits of the slice

Source

pub fn to_bitmask(&self) -> Bitmask

Returns a Bitmask copy of the view.

Source

pub fn iter_set(&self) -> impl Iterator<Item = usize>

Returns an iterator over all set bits (indices relative to the window).

Source

pub fn iter_cleared(&self) -> impl Iterator<Item = usize>

Returns an iterator over all cleared bits (indices relative to the window).

Source

pub fn count_ones(&self) -> usize

Counts number of set bits in the view.

Source

pub fn count_zeros(&self) -> usize

Counts number of cleared bits in the view.

Source

pub fn all_set(&self) -> bool

Returns true if all bits in the view are set.

Source

pub fn all_unset(&self) -> bool

Returns true if all bits in the view are cleared.

Source

pub fn has_cleared(&self) -> bool

Returns true if any bit in the view is cleared.

Source

pub fn any_set(&self) -> bool

Returns true if any bit in the view is set.

Source

pub fn slice(&self, offset: usize, len: usize) -> BitmaskV

Slices the view further by logical offset and len (relative to this window).

Source

pub fn end(&self) -> usize

Returns the exclusive end row index of the window (relative to bitmask).

Source

pub fn as_tuple(&self) -> (&Bitmask, usize, usize)

Returns the underlying window as a tuple: (&Bitmask, offset, len).

Trait Implementations§

Source§

impl Clone for BitmaskV

Source§

fn clone(&self) -> BitmaskV

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Concatenate for BitmaskV

Source§

fn concat(self, other: BitmaskV) -> Result<BitmaskV, MinarrowError>

Concatenates two bitmask views by materialising both to owned bitmasks, concatenating them, and wrapping the result back in a view.

§Notes
  • This operation copies data from both views to create owned bitmasks.
  • The resulting view has offset=0 and length equal to the combined length.
Source§

impl Debug for BitmaskV

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for BitmaskV

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Index<usize> for BitmaskV

Source§

fn index(&self, index: usize) -> &<BitmaskV as Index<usize>>::Output

Returns a reference to a constant true or false value depending on the bit at index.

Note: This does not return a reference into the underlying bitmask storage. The reference points to a compiler-promoted static constant, so its address is unrelated to the internal buffer. Use Self::get if you need the value directly.

Source§

type Output = bool

The returned type after indexing.
Source§

impl PartialEq for BitmaskV

Source§

fn eq(&self, other: &BitmaskV) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Shape for BitmaskV

Source§

fn shape(&self) -> ShapeDim

Returns arbitrary Shape dimension for any data shape
Source§

fn shape_1d(&self) -> usize

Returns the first dimension shape Read more
Source§

fn shape_2d(&self) -> (usize, usize)

Returns the first and second dimension shapes Read more
Source§

fn shape_3d(&self) -> (usize, usize, usize)

Returns the first, second and third dimension shapes Read more
Source§

fn shape_4d(&self) -> (usize, usize, usize, usize)

Returns the first, second, third and fourth dimension shapes Read more
Source§

impl StructuralPartialEq for BitmaskV

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomValue for T
where T: Any + Send + Sync + Clone + PartialEq + Debug,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Downcasts the type as Any
Source§

fn deep_clone(&self) -> Arc<dyn CustomValue>

Returns a deep clone of the object. Read more
Source§

fn eq_box(&self, other: &(dyn CustomValue + 'static)) -> bool

Performs semantic equality on the boxed object. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Print for T
where T: Display,

Source§

fn print(&self)
where Self: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.