pub trait RowPrioMatrix<'a, const R: usize, const C: usize, T> {
    // Required methods
    fn insert(&mut self, location: (usize, usize), value: T);
    fn get(&self, location: (usize, usize)) -> &T;
    fn get_mut(&mut self, location: (usize, usize)) -> &mut T;
    fn fill_row(&mut self, row: usize, data: &[T]);
    fn fill_col(&'a mut self, col: usize, data: &[T]);
    fn get_column(&self, col: usize) -> Column<'_, R, C, T>;
    fn get_mut_column(&mut self, col: usize) -> ColumnMut<'_, R, C, T>;
    fn get_row(&self, row: usize) -> &[T];
    fn get_mut_row(&mut self, row: usize) -> &mut [T];
    fn apply_all(&mut self, f: fn(_: &mut T));
    fn pretty_print(&self);
}
Expand description

RowPrioMatrix encapsulates all functionality a matrix has that uses the memory interpretation RowPrio.

Required Methods§

source

fn insert(&mut self, location: (usize, usize), value: T)

Inserts a value at position (x, y) inside the matrix.

Panics

If the location given is out of bounds in x or y the function panics.

Examples
let mut data = vec![1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4];
let mut reftrix = Reftrix::<4, 4, RowPrio, u8>::from_values(&mut data[..]);
reftrix.insert((3, 1), 0);
assert_eq!(data[13], 0);
source

fn get(&self, location: (usize, usize)) -> &T

Get a immutable reference to a value in the matrix at location (x, y)

Panics

If the location given is out of bounds in x or y the function panics.

Examples
let mut data = vec![1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4];
let mut reftrix = Reftrix::<4, 4, RowPrio, u8>::from_values(&mut data[..]);
assert_eq!(reftrix.get((0, 2)), &1);
source

fn get_mut(&mut self, location: (usize, usize)) -> &mut T

Get a mutable reference to a value in the matrix at location (x, y)

Panics

If the location given is out of bounds in x or y the function panics.

source

fn fill_row(&mut self, row: usize, data: &[T])

Fills an entire row with the given data.

Panics

If the row is out of bounds.

If the data is not the size of a row.

Examples
let mut data = vec![1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4];
let mut reftrix = Reftrix::<4, 4, RowPrio, u8>::from_values(&mut data[..]);
reftrix.fill_row(1, &[7,7,7,7]);
assert_eq!(&data[4..8], &[7,7,7,7]);
source

fn fill_col(&'a mut self, col: usize, data: &[T])

Fills an entire collumn with the given data.

Panics

If the collumn is out of bounds.

If the data is not the size of a collumn.

Examples
let mut data = vec![1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4];
let mut reftrix = Reftrix::<4, 4, RowPrio, u8>::from_values(&mut data[..]);
reftrix.fill_col(1, &[7,7,7,7]);
assert_eq!(data[1], 7);
assert_eq!(data[5], 7);
assert_eq!(data[9], 7);
assert_eq!(data[13], 7);
source

fn get_column(&self, col: usize) -> Column<'_, R, C, T>

Retrieves a Column.

Panics

If the Columns is out of bounds.

source

fn get_mut_column(&mut self, col: usize) -> ColumnMut<'_, R, C, T>

Retrieves a ColumnMut.

Panics

If the Columns is out of bounds.

source

fn get_row(&self, row: usize) -> &[T]

Retrieves a immutable slice that represents the row.

Panics

If the row is out of bounds.

source

fn get_mut_row(&mut self, row: usize) -> &mut [T]

Retrieves a mutable slice that represents the row.

Panics

If the row is out of bounds.

source

fn apply_all(&mut self, f: fn(_: &mut T))

Applies a function on all elements of the matrix.

Examples
let mut data = vec![1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4];
let mut reftrix = Reftrix::<4, 4, RowPrio, u8>::from_values(&mut data[..]);
reftrix.apply_all(|el| *el *= 2);
assert_eq!(&data[..], &[2,2,2,2,4,4,4,4,6,6,6,6,8,8,8,8]);
source

fn pretty_print(&self)

Prints out the matrix, this is only usefull for numeric types.

Implementors§

source§

impl<'a, const R: usize, const C: usize, T> RowPrioMatrix<'a, R, C, T> for Reftrix<'a, R, C, RowPrio, T>where Self: 'a, T: Copy + Default + Debug,

source§

impl<'a, const S: usize, const R: usize, const C: usize, T> RowPrioMatrix<'a, R, C, T> for Stacktrix<S, R, C, RowPrio, T>where Self: 'a, T: Copy + Default + Debug,