[][src]Struct alg_ds::ds::matrix::Matrix

pub struct Matrix<'a, T> where
    T: Default + Clone
{ /* fields omitted */ }

Rectangular table of elements (two-dimensional array).

Methods

impl<'a, T> Matrix<'a, T> where
    T: Default + Clone
[src]

pub fn new(rows: usize, cols: usize) -> Self[src]

Creates new Matrix and fills it with default values.

rows - rows number. cols - columns number. Panic, if memory allocation is not succesfully.

pub fn clear(&mut self)[src]

Fills matrix with a default values.

pub fn fill(&mut self, value: T)[src]

Fills matrix with a value.

pub fn rows(&self) -> usize[src]

Returns rows number.

pub fn cols(&self) -> usize[src]

Returns columns number.

pub fn elements_number(&self) -> usize[src]

Returns number of elements in matrix.

pub fn nth(&self, index: usize) -> &T[src]

Returns the n-th element of the table in line traversal order.

pub fn get(&self, row: usize, col: usize) -> &T[src]

Returns value at [row][col] position.

There are bounds checking. If index out of range, then panic.

pub fn set(&mut self, row: usize, col: usize, value: T)[src]

Sets the value of element at [row][col] position.

There are bounds checking. If index out of range, then panic.

pub fn iter(&self) -> Iter<T>[src]

Iterator over matrix in line traversal order.

pub fn iter_mut(&mut self) -> IterMut<T>[src]

Mutable iterator over matrix in line traversal order.

Trait Implementations

impl<'a, T> Add<Matrix<'a, T>> for Matrix<'a, T> where
    T: Default + Clone + Add<Output = T>, 
[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Self) -> Self[src]

Performs addition of two matrices. Panics, if the sizes of the operands do not match.

impl<'a, T> Clone for Matrix<'a, T> where
    T: Default + Clone
[src]

impl<'a, T> Debug for Matrix<'a, T> where
    T: Default + Clone + Display
[src]

impl<'a, T> Deref for Matrix<'a, T> where
    T: Default + Clone
[src]

type Target = [T]

The resulting type after dereferencing.

impl<'a, T> DerefMut for Matrix<'a, T> where
    T: Default + Clone
[src]

impl<'a, T> Drop for Matrix<'a, T> where
    T: Default + Clone
[src]

impl<'a, T> Index<usize> for Matrix<'a, T> where
    T: Default + Clone
[src]

type Output = [T]

The returned type after indexing.

impl<'a, T> IndexMut<usize> for Matrix<'a, T> where
    T: Default + Clone
[src]

impl<'a, T> Mul<T> for Matrix<'a, T> where
    T: Default + Clone + Mul<Output = T>, 
[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, value: T) -> Self[src]

Performs multiplication the matrix by a number.

impl<'a, T> PartialEq<Matrix<'a, T>> for Matrix<'a, T> where
    T: Default + Clone + PartialEq
[src]

impl<'a, T> Sub<Matrix<'a, T>> for Matrix<'a, T> where
    T: Default + Clone + Sub<Output = T>, 
[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, other: Self) -> Self[src]

Performs subtraction of two matrices. Panics, if the sizes of the operands do not match.

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Matrix<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for Matrix<'a, T> where
    T: Send

impl<'a, T> Sync for Matrix<'a, T> where
    T: Sync

impl<'a, T> Unpin for Matrix<'a, T>

impl<'a, T> !UnwindSafe for Matrix<'a, T>

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.