[−][src]Struct pathfinding::matrix::Matrix
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
Methods
impl<C: Clone> Matrix<C>[src]
impl<C: Clone> Matrix<C>pub fn new(rows: usize, columns: usize, value: C) -> Matrix<C>[src]
pub fn new(rows: usize, columns: usize, value: C) -> Matrix<C>Create new matrix with an initial value.
pub fn new_square(size: usize, value: C) -> Matrix<C>[src]
pub fn new_square(size: usize, value: C) -> Matrix<C>Create new square matrix with initial value.
pub fn fill(&mut self, value: C)[src]
pub fn fill(&mut self, value: C)Fill with a known value.
pub fn slice(&self, rows: Range<usize>, columns: Range<usize>) -> Matrix<C>[src]
pub fn slice(&self, rows: Range<usize>, columns: Range<usize>) -> Matrix<C>Return a copy of a sub-matrix.
pub fn rotated_cw(&self, times: usize) -> Matrix<C>[src]
pub fn rotated_cw(&self, times: usize) -> Matrix<C>Return a copy of a matrix rotated clock-wise a number of times.
pub fn rotated_ccw(&self, times: usize) -> Matrix<C>[src]
pub fn rotated_ccw(&self, times: usize) -> Matrix<C>Return a copy of a matrix rotated counter-clock-wise a number of times.
pub fn flipped_lr(&self) -> Matrix<C>[src]
pub fn flipped_lr(&self) -> Matrix<C>Return a copy of the matrix flipped along the vertical axis.
pub fn flipped_ud(&self) -> Matrix<C>[src]
pub fn flipped_ud(&self) -> Matrix<C>Return a copy of the matrix flipped along the horizontal axis.
pub fn transposed(&self) -> Matrix<C>[src]
pub fn transposed(&self) -> Matrix<C>Return a copy of the matrix after transposition.
pub fn extend(&mut self, row: &[C])[src]
pub fn extend(&mut self, row: &[C])Extend the matrix in place by adding one full row.
Panics
This function panics if the row does not have the expected number of elements.
impl<C: Copy> Matrix<C>[src]
impl<C: Copy> Matrix<C>pub fn set_slice(&mut self, pos: &(usize, usize), slice: &Matrix<C>)[src]
pub fn set_slice(&mut self, pos: &(usize, usize), slice: &Matrix<C>)Replace a slice of the current matrix with the content of another one.
impl<C> Matrix<C>[src]
impl<C> Matrix<C>pub fn from_vec(rows: usize, columns: usize, values: Vec<C>) -> Matrix<C>[src]
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.
pub fn square_from_vec(values: Vec<C>) -> Matrix<C>[src]
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.
pub fn new_empty(columns: usize) -> Matrix<C>[src]
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.
pub fn is_square(&self) -> bool[src]
pub fn is_square(&self) -> boolCheck if a matrix is a square one.
pub fn idx(&self, i: &(usize, usize)) -> usize[src]
pub fn idx(&self, i: &(usize, usize)) -> usizeIndex in raw data of a given position.
pub fn flip_lr(&mut self)[src]
pub fn flip_lr(&mut self)Flip the matrix around the vertical axis.
pub fn flip_ud(&mut self)[src]
pub fn flip_ud(&mut self)Flip the matrix around the horizontal axis.
pub fn rotate_cw(&mut self, times: usize)[src]
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.
pub fn rotate_ccw(&mut self, times: usize)[src]
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
impl<C: Copy> Weights<C> for Matrix<C>[src]
impl<C: Copy> Weights<C> for Matrix<C>fn rows(&self) -> usize[src]
fn rows(&self) -> usizeReturn the number of rows.
fn columns(&self) -> usize[src]
fn columns(&self) -> usizeReturn the number of columns.
fn at(&self, row: usize, col: usize) -> C[src]
fn at(&self, row: usize, col: usize) -> CReturn the element at position.
fn neg(&self) -> Self where
C: Signed, [src]
fn neg(&self) -> Self where
C: Signed, Return the negated weights.
impl<C> AsMut<[C]> for Matrix<C>[src]
impl<C> AsMut<[C]> for Matrix<C>impl<C: PartialEq> PartialEq<Matrix<C>> for Matrix<C>[src]
impl<C: PartialEq> PartialEq<Matrix<C>> for Matrix<C>fn eq(&self, other: &Matrix<C>) -> bool[src]
fn eq(&self, other: &Matrix<C>) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Matrix<C>) -> bool[src]
fn ne(&self, other: &Matrix<C>) -> boolThis method tests for !=.
impl<C> AsRef<[C]> for Matrix<C>[src]
impl<C> AsRef<[C]> for Matrix<C>impl<C: Clone> Clone for Matrix<C>[src]
impl<C: Clone> Clone for Matrix<C>fn clone(&self) -> Matrix<C>[src]
fn clone(&self) -> Matrix<C>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<C: Eq> Eq for Matrix<C>[src]
impl<C: Eq> Eq for Matrix<C>impl<C: Debug> Debug for Matrix<C>[src]
impl<C: Debug> Debug for Matrix<C>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<C: Clone + Signed> Neg for Matrix<C>[src]
impl<C: Clone + Signed> Neg for Matrix<C>type Output = Matrix<C>
The resulting type after applying the - operator.
fn neg(self) -> Matrix<C>[src]
fn neg(self) -> Matrix<C>Performs the unary - operation.
impl<'a, C> Index<&'a (usize, usize)> for Matrix<C>[src]
impl<'a, C> Index<&'a (usize, usize)> for Matrix<C>type Output = C
The returned type after indexing.
fn index(&self, index: &'a (usize, usize)) -> &C[src]
fn index(&self, index: &'a (usize, usize)) -> &CPerforms the indexing (container[index]) operation.
impl<'a, C> IndexMut<&'a (usize, usize)> for Matrix<C>[src]
impl<'a, C> IndexMut<&'a (usize, usize)> for Matrix<C>fn index_mut(&mut self, index: &'a (usize, usize)) -> &mut C[src]
fn index_mut(&mut self, index: &'a (usize, usize)) -> &mut CPerforms the mutable indexing (container[index]) operation.
impl<C: Hash> Hash for Matrix<C>[src]
impl<C: Hash> Hash for Matrix<C>Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, [src]
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, fn equivalent(&self, key: &K) -> bool[src]
fn equivalent(&self, key: &K) -> boolCompare self to key and return true if they are equal.