Struct bit_matrix::matrix::BitMatrix

source ·
pub struct BitMatrix { /* private fields */ }
Expand description

A matrix of bits.

Implementations§

source§

impl BitMatrix

source

pub fn new(rows: usize, row_bits: usize) -> Self

Create a new BitMatrix with specific numbers of bits in columns and rows.

source

pub fn size(&self) -> (usize, usize)

Returns the matrix’s size as (rows, columns).

source

pub fn set(&mut self, row: usize, col: usize, enabled: bool)

Sets the value of a bit.

§Panics

Panics if (row, col) is out of bounds.

source

pub fn set_all(&mut self, enabled: bool)

Sets the value of all bits.

source

pub fn grow(&mut self, num_rows: usize, value: bool)

Grows the matrix in-place, adding num_rows rows filled with value.

source

pub fn truncate(&mut self, num_rows: usize)

Truncates the matrix.

source

pub fn sub_matrix(&self, range: Range<usize>) -> BitSubMatrix<'_>

Returns a slice of the matrix’s rows.

source

pub fn split_at(&self, row: usize) -> (BitSubMatrix<'_>, BitSubMatrix<'_>)

Given a row’s index, returns a slice of all rows above that row, a reference to said row, and a slice of all rows below.

Functionally equivalent to (self.sub_matrix(0..row), &self[row], self.sub_matrix(row..self.num_rows())).

source

pub fn split_at_mut( &mut self, row: usize ) -> (BitSubMatrixMut<'_>, BitSubMatrixMut<'_>)

Given a row’s index, returns a slice of all rows above that row, a reference to said row, and a slice of all rows below.

source

pub fn iter_row(&self, row: usize) -> Iter<'_>

Iterate over bits in the specified row.

source

pub fn transitive_closure(&mut self)

Computes the transitive closure of the binary relation represented by the matrix.

Uses the Warshall’s algorithm.

source

pub fn reflexive_closure(&mut self)

Computes the reflexive closure of the binary relation represented by the matrix.

Trait Implementations§

source§

impl Clone for BitMatrix

source§

fn clone(&self) -> BitMatrix

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for BitMatrix

source§

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

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

impl Default for BitMatrix

source§

fn default() -> BitMatrix

Returns the “default value” for a type. Read more
source§

impl Hash for BitMatrix

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<(usize, usize)> for BitMatrix

Returns true if a bit is enabled in the matrix, or false otherwise.

§

type Output = bool

The returned type after indexing.
source§

fn index(&self, (row, col): (usize, usize)) -> &bool

Performs the indexing (container[index]) operation. Read more
source§

impl Index<usize> for BitMatrix

Returns the matrix’s row in the form of an immutable slice.

§

type Output = BitSlice

The returned type after indexing.
source§

fn index(&self, row: usize) -> &BitSlice

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for BitMatrix

Returns the matrix’s row in the form of a mutable slice.

source§

fn index_mut(&mut self, row: usize) -> &mut BitSlice

Performs the mutable indexing (container[index]) operation. Read more
source§

impl Ord for BitMatrix

source§

fn cmp(&self, other: &BitMatrix) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for BitMatrix

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for BitMatrix

source§

fn partial_cmp(&self, other: &BitMatrix) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for BitMatrix

source§

impl StructuralPartialEq for BitMatrix

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> 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> ToOwned for T
where T: Clone,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.