pub struct BitMatrix(/* private fields */);
Expand description
A bitset with fixed-size rows.
Note that only the total size is tracked in BitMatrix
and you must provide
the width
value when calling methods on BitMatrix
.
Implementations§
source§impl BitMatrix
impl BitMatrix
sourcepub fn height(&self, width: usize) -> usize
pub fn height(&self, width: usize) -> usize
The height this matrix would have if it had given width
.
Note that this might be greater than the height
given to Self::new_with_size
due to BitMatrix
discarding information about actual size.
Panics
If Self
is not empty and width
equals 0
(division by zero)
sourcepub fn active_rows_in_column(&self, width: usize, x: usize) -> Column<'_> ⓘ
pub fn active_rows_in_column(&self, width: usize, x: usize) -> Column<'_> ⓘ
Iterate over active bits in given column
.
Panics
When width = 0
(this would otherwise mean there is an infinite
amount of columns)
sourcepub fn row(&self, width: usize, y: usize) -> impl Iterator<Item = usize> + '_
pub fn row(&self, width: usize, y: usize) -> impl Iterator<Item = usize> + '_
Iterate over the enabled bits of a single row at y
of this Bitmatrix
.
Assuming the Bitmatrix
has the provided width
.
sourcepub fn enable_bit(&mut self, width: usize, x: usize, y: usize) -> Option<()>
pub fn enable_bit(&mut self, width: usize, x: usize, y: usize) -> Option<()>
Enables bit at position bit
.
Returns None
and does nothing if bit
is out of range.
When [Bitset::bit(bit)
] will be called next, it will be true
if this returned Some
.
sourcepub fn new_with_size(width: usize, height: usize) -> Self
pub fn new_with_size(width: usize, height: usize) -> Self
Create a BitMatrix
with given proportions.
Note that the total size is the lowest multiple of 32 higher or equal to width * height
.
sourcepub fn bit(&self, width: usize, x: usize, y: usize) -> bool
pub fn bit(&self, width: usize, x: usize, y: usize) -> bool
true
if bit at position x, y
in matrix is enabled.
false
otherwise, included if x, y
is outside of the matrix.
sourcepub const fn sextant_display(
&self,
width: usize,
height: usize
) -> SextantDisplay<'_>
pub const fn sextant_display( &self, width: usize, height: usize ) -> SextantDisplay<'_>
Return a struct that, when printed with fmt::Display
or fmt::Debug
,
displays the matrix using unicode sextant characters(pdf).