[−][src]Struct k2_tree::matrix::BitMatrix
A 2-d bit-matrix.
Fields
width: usize
Width of the matrix.
height: usize
Height of the matrix.
Implementations
impl BitMatrix
[src]
pub fn new() -> Self
[src]
Creates an empty BitMatrix with zero width or height.
pub fn with_dimensions(width: usize, height: usize) -> Self
[src]
Creates an empty BitMatrix with predefined dimensions.
pub fn from_bits(
width: usize,
height: usize,
data: impl IntoIterator<Item = bool>
) -> Self
[src]
width: usize,
height: usize,
data: impl IntoIterator<Item = bool>
) -> Self
Builds a BitMatrix instance from another collection of bits.
If the data passed in contains more bits than will fit a matrix of the specified height and width, excess data is discarded. If not enough bits are passed in, 0s will be appended until the right size is reached.
pub fn get(&self, x: usize, y: usize) -> Result<bool, BitMatrixError>
[src]
Returns the state of a bit at a specific coordinate.
pub fn get_column(&self, x: usize) -> Result<Vec<bool>, BitMatrixError>
[src]
Returns the state of all the bits at a specific x-coordinate.
Bits are ordered by row, starting at y-coordinate 0.
pub fn get_row(&self, y: usize) -> Result<Vec<bool>, BitMatrixError>
[src]
Returns the state of all the bits at a specific y-coordinate.
Bits are ordered by column, starting at x-coordinate 0.
pub fn set(
&mut self,
x: usize,
y: usize,
state: bool
) -> Result<(), BitMatrixError>
[src]
&mut self,
x: usize,
y: usize,
state: bool
) -> Result<(), BitMatrixError>
Changes the state of a bit at a specififc coordinate.
pub fn resize_width(&mut self, len: usize)
[src]
Changes the width of the matrix.
If len is greater than matrix's width, each row is extended with 0s. Otherwise, each row is concatenated.
pub fn resize_height(&mut self, len: usize)
[src]
Changes the hieght of the matrix.
If len is greater than matrix's height, it is extended with blank rows. Otherwise, the number of rows is suitably concatenated.
pub fn to_bits(&self) -> Vec<bool>
[src]
Produces the contents of the matrix as a flat vec of bits.
Vec contains each row one after another.
pub fn into_bits(self) -> Vec<bool>
[src]
Consumes the BitMatrix to produce its contents as a flat vec of bits.
Vec contains each row one after another.
pub fn to_columns(&self) -> Vec<Vec<bool>>
[src]
Produces the contents of the matrix as a vec of its columns.
pub fn into_columns(self) -> Vec<Vec<bool>>
[src]
Consumes the BitMatrix to produce its contents as a vec of its columns.
pub fn to_rows(&self) -> Vec<Vec<bool>>
[src]
Produces the contents of the matrix as a vec of its rows.
pub fn into_rows(self) -> Vec<Vec<bool>>
[src]
Consumes the BitMatrix to produce its contents as a vec of its rows.
pub fn shrink_to_fit(&mut self)
[src]
Reduces the width and height such that there are no empty columns or rows on the edges.
Trait Implementations
impl Clone for BitMatrix
[src]
impl Debug for BitMatrix
[src]
impl Default for BitMatrix
[src]
impl Eq for BitMatrix
[src]
impl Hash for BitMatrix
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<BitMatrix> for BitMatrix
[src]
impl StructuralEq for BitMatrix
[src]
impl StructuralPartialEq for BitMatrix
[src]
Auto Trait Implementations
impl RefUnwindSafe for BitMatrix
[src]
impl Send for BitMatrix
[src]
impl Sync for BitMatrix
[src]
impl Unpin for BitMatrix
[src]
impl UnwindSafe for BitMatrix
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,