Struct pathfinding::matrix::Matrix
source · Expand description
Matrix of an arbitrary type. Data are stored consecutively in
memory, by rows. Raw data can be accessed using as_ref()
or as_mut()
.
Fields§
§rows: usize
Rows
columns: usize
Columns
Implementations§
source§impl<C: Clone> Matrix<C>
impl<C: Clone> Matrix<C>
sourcepub fn new(rows: usize, columns: usize, value: C) -> Matrix<C>
pub fn new(rows: usize, columns: usize, value: C) -> Matrix<C>
Create new matrix with an initial value.
sourcepub fn new_square(size: usize, value: C) -> Matrix<C>
pub fn new_square(size: usize, value: C) -> Matrix<C>
Create new square matrix with initial value.
sourcepub fn slice(&self, rows: Range<usize>, columns: Range<usize>) -> Matrix<C>
pub fn slice(&self, rows: Range<usize>, columns: Range<usize>) -> Matrix<C>
Return a copy of a sub-matrix.
sourcepub fn rotated_cw(&self, times: usize) -> Matrix<C>
pub fn rotated_cw(&self, times: usize) -> Matrix<C>
Return a copy of a matrix rotated clock-wise a number of times.
sourcepub fn rotated_ccw(&self, times: usize) -> Matrix<C>
pub fn rotated_ccw(&self, times: usize) -> Matrix<C>
Return a copy of a matrix rotated counter-clock-wise a number of times.
sourcepub fn flipped_lr(&self) -> Matrix<C>
pub fn flipped_lr(&self) -> Matrix<C>
Return a copy of the matrix flipped along the vertical axis.
sourcepub fn flipped_ud(&self) -> Matrix<C>
pub fn flipped_ud(&self) -> Matrix<C>
Return a copy of the matrix flipped along the horizontal axis.
sourcepub fn transposed(&self) -> Matrix<C>
pub fn transposed(&self) -> Matrix<C>
Return a copy of the matrix after transposition.
source§impl<C> Matrix<C>
impl<C> Matrix<C>
sourcepub fn from_vec(rows: usize, columns: usize, values: Vec<C>) -> Matrix<C>
pub fn from_vec(rows: usize, columns: usize, values: Vec<C>) -> Matrix<C>
Create new matrix from vector values. The first value will be assigned to index (0, 0), the second one to index (0, 1), and so on.
Panics
This function will panic if the number of values does not correspond to the announced size.
sourcepub fn square_from_vec(values: Vec<C>) -> Matrix<C>
pub fn square_from_vec(values: Vec<C>) -> Matrix<C>
Create new square matrix from vector values. The first value will be assigned to index (0, 0), the second one to index (0, 1), and so on.
Panics
This function will panic if the number of values is not a square number.
sourcepub fn new_empty(columns: usize) -> Matrix<C>
pub fn new_empty(columns: usize) -> Matrix<C>
Create new empty matrix with a predefined number of rows. This is useful to gradually build the matrix and extend it later using extend and does not require a filler element compared to Matrix::new.
sourcepub fn to_vec(self) -> Vec<C>
pub fn to_vec(self) -> Vec<C>
Retrieve the content of the matrix as a vector. The content starts with the first row, then the second one, and so on.
sourcepub fn rotate_cw(&mut self, times: usize)
pub fn rotate_cw(&mut self, times: usize)
Rotate a square matrix clock-wise a number of times.
Panics
This function panics if the matrix is not square.
sourcepub fn rotate_ccw(&mut self, times: usize)
pub fn rotate_ccw(&mut self, times: usize)
Rotate a square matrix counter-clock-wise a number of times.
Panics
This function panics if the matrix is not square.
Trait Implementations§
source§impl<C: PartialEq> PartialEq<Matrix<C>> for Matrix<C>
impl<C: PartialEq> PartialEq<Matrix<C>> for Matrix<C>
impl<C: Eq> Eq for Matrix<C>
impl<C> StructuralEq for Matrix<C>
impl<C> StructuralPartialEq for Matrix<C>
Auto Trait Implementations§
impl<C> RefUnwindSafe for Matrix<C>where
C: RefUnwindSafe,
impl<C> Send for Matrix<C>where
C: Send,
impl<C> Sync for Matrix<C>where
C: Sync,
impl<C> Unpin for Matrix<C>where
C: Unpin,
impl<C> UnwindSafe for Matrix<C>where
C: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.