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>
impl<'a, T> TooDeeViewMut<'a, T>
sourcepub fn new(
num_cols: usize,
num_rows: usize,
data: &'a mut [T]
) -> TooDeeViewMut<'a, T>
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,
impl<T> Debug for TooDeeViewMut<'_, T>where T: Debug,
source§impl<T> From<TooDeeViewMut<'_, T>> for TooDee<T>where
T: Clone,
impl<T> From<TooDeeViewMut<'_, T>> for TooDee<T>where T: Clone,
source§fn from(view: TooDeeViewMut<'_, T>) -> Self
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>
impl<'a, T> From<TooDeeViewMut<'a, T>> for TooDeeView<'a, T>
source§fn from(v: TooDeeViewMut<'a, T>) -> TooDeeView<'a, T>
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>
impl<'a, T: Hash> Hash for TooDeeViewMut<'a, T>
source§impl<'a, T> Index<usize> for TooDeeViewMut<'a, T>
impl<'a, T> Index<usize> for TooDeeViewMut<'a, T>
source§impl<'a, T> IndexMut<usize> for TooDeeViewMut<'a, T>
impl<'a, T> IndexMut<usize> for TooDeeViewMut<'a, T>
source§impl<'a, T> IntoIterator for &'a TooDeeViewMut<'a, T>
impl<'a, T> IntoIterator for &'a TooDeeViewMut<'a, T>
source§impl<'a, T> IntoIterator for &'a mut TooDeeViewMut<'a, T>
impl<'a, T> IntoIterator for &'a mut TooDeeViewMut<'a, T>
source§impl<'a, T: PartialEq> PartialEq<TooDeeViewMut<'a, T>> for TooDeeViewMut<'a, T>
impl<'a, T: PartialEq> PartialEq<TooDeeViewMut<'a, T>> for TooDeeViewMut<'a, T>
source§fn eq(&self, other: &TooDeeViewMut<'a, T>) -> bool
fn eq(&self, other: &TooDeeViewMut<'a, T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for TooDeeViewMut<'_, u32>
impl Serialize for TooDeeViewMut<'_, u32>
source§impl<'a, T> TooDeeOps<T> for TooDeeViewMut<'a, T>
impl<'a, T> TooDeeOps<T> for TooDeeViewMut<'a, T>
source§unsafe fn get_unchecked_row(&self, row: usize) -> &[T]
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
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 view(&self, start: Coordinate, end: Coordinate) -> TooDeeView<'_, T>
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> ⓘ
fn rows(&self) -> Rows<'_, T> ⓘ
Returns an iterator of slices, where each slice represents an entire row. Read more
source§impl<'a, T> TooDeeOpsMut<T> for TooDeeViewMut<'a, T>
impl<'a, T> TooDeeOpsMut<T> for TooDeeViewMut<'a, T>
source§fn swap_rows(&mut self, r1: usize, r2: usize)
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]
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
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>
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> ⓘ
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> ⓘ
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 moresource§fn cells_mut(&mut self) -> CellsMut<'_, T>
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)
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)
fn swap(&mut self, cell1: Coordinate, cell2: Coordinate)
Swap/exchange two cells in the array. Read more
impl<T> CopyOps<T> for TooDeeViewMut<'_, T>
impl<'a, T: Eq> Eq for TooDeeViewMut<'a, T>
impl<'a, T> StructuralEq for TooDeeViewMut<'a, T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T, O> SortOps<T> for Owhere
O: TooDeeOpsMut<T>,
impl<T, O> SortOps<T> for Owhere O: TooDeeOpsMut<T>,
source§fn sort_row_ord<F>(&mut self, row: usize)where
T: Ord,
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,
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,
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,
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,
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,
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,
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,
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,
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§impl<T, O> TranslateOps<T> for Owhere
O: TooDeeOpsMut<T>,
impl<T, O> TranslateOps<T> for Owhere O: TooDeeOpsMut<T>,
source§fn translate_with_wrap(&mut self, mid: Coordinate)
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