Struct toodee::TooDeeViewMut

source ·
pub struct TooDeeViewMut<'a, T> { /* private fields */ }
Expand description

Provides a mutable view (or subset), of a TooDee array.

Implementations§

source§

impl<'a, T> TooDeeViewMut<'a, T>

source

pub fn new( num_cols: usize, num_rows: usize, data: &'a mut [T] ) -> TooDeeViewMut<'a, T>

Create a new TooDeeViewMut using the provided mutable slice reference.

Panics

Panics if one of the dimensions is zero but the other is non-zero. This is to enforce the rule that empty arrays have no dimensions.

Panics if the slice’s length is not sufficient to represent the desired array dimensions.

Panics if num_cols * num_rows overflows.

Examples
use toodee::TooDeeViewMut;
let mut data = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
let view_mut = TooDeeViewMut::new(4, 3, &mut data);

Trait Implementations§

source§

impl<T> Debug for TooDeeViewMut<'_, T>where T: Debug,

source§

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

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

impl<T> From<TooDeeViewMut<'_, T>> for TooDee<T>where T: Clone,

source§

fn from(view: TooDeeViewMut<'_, T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T> From<TooDeeViewMut<'a, T>> for TooDeeView<'a, T>

source§

fn from(v: TooDeeViewMut<'a, T>) -> TooDeeView<'a, T>

Converts to this type from the input type.
source§

impl<'a, T: Hash> Hash for TooDeeViewMut<'a, T>

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<'a, T> Index<(usize, usize)> for TooDeeViewMut<'a, T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, coord: Coordinate) -> &Self::Output

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

impl<'a, T> Index<usize> for TooDeeViewMut<'a, T>

§

type Output = [T]

The returned type after indexing.
source§

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

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

impl<'a, T> IndexMut<(usize, usize)> for TooDeeViewMut<'a, T>

source§

fn index_mut(&mut self, coord: Coordinate) -> &mut Self::Output

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

impl<'a, T> IndexMut<usize> for TooDeeViewMut<'a, T>

source§

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

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

impl<'a, T> IntoIterator for &'a TooDeeViewMut<'a, T>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = FlattenExact<Rows<'a, T>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T> IntoIterator for &'a mut TooDeeViewMut<'a, T>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

type IntoIter = FlattenExact<RowsMut<'a, T>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T: PartialEq> PartialEq<TooDeeViewMut<'a, T>> for TooDeeViewMut<'a, T>

source§

fn eq(&self, other: &TooDeeViewMut<'a, T>) -> 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 Serialize for TooDeeViewMut<'_, u32>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a, T> TooDeeOps<T> for TooDeeViewMut<'a, T>

source§

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

Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
unsafe {
    let mut toodee : TooDee<u32> = TooDee::new(10, 5);
    let mut view = toodee.view_mut((0,0), (10,5));
    let row = view.get_unchecked_row(3);
    assert_eq!(row.len(), 10);
}
source§

unsafe fn get_unchecked(&self, coord: Coordinate) -> &T

Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
let mut view = toodee.view_mut((0,0), (10,5));
unsafe {
    assert_eq!(*view.get_unchecked((1,3)), 0);
}
source§

fn num_rows(&self) -> usize

The number of rows in the area represented by this object.
source§

fn num_cols(&self) -> usize

The number of columns in the area represented by this object.
source§

fn view(&self, start: Coordinate, end: Coordinate) -> TooDeeView<'_, T>

Returns a view (or subset) of the current area based on the coordinates provided. Read more
source§

fn rows(&self) -> Rows<'_, T>

Returns an iterator of slices, where each slice represents an entire row. Read more
source§

fn col(&self, col: usize) -> Col<'_, T>

Returns an iterator over a single column. Note that the Col iterator is indexable. Read more
source§

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

Returns the size/dimensions of the current object.
source§

fn is_empty(&self) -> bool

Returns true if the array contains no elements.
source§

fn cells(&self) -> Cells<'_, T>

Returns an iterator that traverses all cells within the area. Read more
source§

impl<'a, T> TooDeeOpsMut<T> for TooDeeViewMut<'a, T>

source§

fn swap_rows(&mut self, r1: usize, r2: usize)

Swap/exchange the data between two rows.

Panics

Panics if either row index is out of bounds.

Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let mut toodee : TooDee<u32> = TooDee::init(10, 5, 42u32);
toodee[0].iter_mut().for_each(|v| *v = 1);
assert_eq!(toodee[(0, 2)], 42);
toodee.swap_rows(0, 2);
assert_eq!(toodee[(0, 2)], 1);
source§

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

Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
unsafe {
    let mut toodee : TooDee<u32> = TooDee::new(10, 5);
    let mut view = toodee.view_mut((0,0), (10,5));
    let row = view.get_unchecked_row_mut(3);
    assert_eq!(row.len(), 10);
}
source§

unsafe fn get_unchecked_mut(&mut self, coord: Coordinate) -> &mut T

Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut};
let mut toodee : TooDee<u32> = TooDee::new(10, 5);
let mut view = toodee.view_mut((0,0), (10,5));
unsafe {
    assert_eq!(*view.get_unchecked_mut((1,3)), 0);
}
source§

fn view_mut( &mut self, start: Coordinate, end: Coordinate ) -> TooDeeViewMut<'_, T>

Returns a mutable view (or subset) of the current area based on the coordinates provided. Read more
source§

fn rows_mut(&mut self) -> RowsMut<'_, T>

Returns a mutable iterator of slices, where each slice represents an entire row. Read more
source§

fn col_mut(&mut self, col: usize) -> ColMut<'_, T>

Returns a mutable iterator over a single column. Note that the ColMut iterator is indexable. Read more
source§

fn cells_mut(&mut self) -> CellsMut<'_, T>

Returns an iterator that traverses all cells within the area. Read more
source§

fn swap_cols(&mut self, c1: usize, c2: usize)

Swap/exchange the data between two columns. Read more
source§

fn swap(&mut self, cell1: Coordinate, cell2: Coordinate)

Swap/exchange two cells in the array. Read more
source§

fn row_pair_mut(&mut self, r1: usize, r2: usize) -> (&mut [T], &mut [T])

Return the specified rows as mutable slices. Read more
source§

impl<T> CopyOps<T> for TooDeeViewMut<'_, T>

source§

impl<'a, T: Eq> Eq for TooDeeViewMut<'a, T>

source§

impl<'a, T> StructuralEq for TooDeeViewMut<'a, T>

source§

impl<'a, T> StructuralPartialEq for TooDeeViewMut<'a, T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, O> SortOps<T> for Owhere O: TooDeeOpsMut<T>,

source§

fn sort_row_ord<F>(&mut self, row: usize)where T: Ord,

Sort the entire two-dimensional array by comparing elements on a specific row, using the natural ordering. This sort is stable.
source§

fn sort_unstable_row_ord<F>(&mut self, row: usize)where T: Ord,

Sort the entire two-dimensional array by comparing elements on a specific row, using the natural ordering. This sort is unstable.
source§

fn sort_by_row<F>(&mut self, row: usize, compare: F)where F: FnMut(&T, &T) -> Ordering,

Sort the entire two-dimensional array by comparing elements on a specific row using the provided compare function. This sort is stable.
source§

fn sort_unstable_by_row<F>(&mut self, row: usize, compare: F)where F: FnMut(&T, &T) -> Ordering,

Sort the entire two-dimensional array by comparing elements on a specific row using the provided compare function. This sort is unstable.
source§

fn sort_by_row_key<B, F>(&mut self, row: usize, f: F)where B: Ord, F: FnMut(&T) -> B,

Sort the entire two-dimensional array by comparing elements on a specific row using a key extraction function. This sort is stable.
source§

fn sort_unstable_by_row_key<B, F>(&mut self, row: usize, f: F)where B: Ord, F: FnMut(&T) -> B,

Sort the entire two-dimensional array by comparing elements on a specific row using a key extraction function. This sort is unstable.
source§

fn sort_col_ord<F>(&mut self, col: usize)where T: Ord,

Sort the entire two-dimensional array by comparing elements on a specific column using the natural ordering. This sort is stable.
source§

fn sort_by_col<F>(&mut self, col: usize, compare: F)where F: FnMut(&T, &T) -> Ordering,

Sort the entire two-dimensional array by comparing elements on in a specific column. This sort is stable.
source§

fn sort_unstable_by_col<F>(&mut self, col: usize, compare: F)where F: FnMut(&T, &T) -> Ordering,

Sort the entire two-dimensional array by comparing elements on in a specific column. This sort is unstable.
source§

fn sort_by_col_key<B, F>(&mut self, col: usize, f: F)where B: Ord, F: FnMut(&T) -> B,

Sort the entire two-dimensional array by comparing elements on a specific column using a key extraction function. This sort is stable.
source§

fn sort_unstable_by_col_key<B, F>(&mut self, col: usize, f: F)where B: Ord, F: FnMut(&T) -> B,

Sort the entire two-dimensional array by comparing elements on a specific column using a key extraction function. This sort is unstable.
source§

impl<T, O> TranslateOps<T> for Owhere O: TooDeeOpsMut<T>,

source§

fn translate_with_wrap(&mut self, mid: Coordinate)

Translate (or scroll) the entire area. The mid coordinate will be moved to (0, 0), and all other elements will be moved in the same fashion. All the original data is preserved by wrapping at the array edges. Read more
source§

fn flip_rows(&mut self)

Flips (or mirrors) the rows. Read more
source§

fn flip_cols(&mut self)

Flips (or mirrors) the columns. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.