[][src]Struct k2_tree::matrix::BitMatrix

pub struct BitMatrix {
    pub width: usize,
    pub height: usize,
    // some fields omitted
}

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]

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]

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]

impl PartialEq<BitMatrix> for BitMatrix[src]

impl StructuralEq for BitMatrix[src]

impl StructuralPartialEq for BitMatrix[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.