[−][src]Struct toodee::TooDee
Represents a two-dimensional array.
Empty arrays will always have dimensions of zero.
Implementations
impl<T> TooDee<T>
[src]
pub fn new(num_cols: usize, num_rows: usize) -> TooDee<T> where
T: Default + Clone,
[src]
T: Default + Clone,
Create a new TooDee
array of the specified dimensions, and fill it with
the type's default value.
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.
Examples
use toodee::{TooDee,TooDeeOps}; let toodee : TooDee<u32> = TooDee::new(10, 5); assert_eq!(toodee.num_cols(), 10); assert_eq!(toodee.num_rows(), 5); assert_eq!(toodee[0][0], 0);
pub fn init(num_cols: usize, num_rows: usize, init_value: T) -> TooDee<T> where
T: Clone,
[src]
T: Clone,
Create a new TooDee
array of the specified dimensions, and fill it with
an initial value.
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.
Examples
use toodee::{TooDee,TooDeeOps}; let toodee = TooDee::init(10, 5, 42u32); assert_eq!(toodee.num_cols(), 10); assert_eq!(toodee.num_rows(), 5); assert_eq!(toodee[0][0], 42);
pub fn capacity(&self) -> usize
[src]
Returns the element capacity of the underlying Vec
.
Examples
use toodee::TooDee; let v = vec![42u32; 10]; let toodee : TooDee<u32> = TooDee::from_vec(5, 2, v); assert!(toodee.capacity() >= 10);
pub fn with_capacity(capacity: usize) -> TooDee<T>
[src]
Constructs a new, empty TooDee<T>
with the specified element capacity.
Examples
use toodee::TooDee; let toodee : TooDee<u32> = TooDee::with_capacity(50); assert!(toodee.capacity() >= 50);
pub fn reserve_exact(&mut self, capacity: usize)
[src]
Reserves the minimum capacity for at least additional
more elements to be inserted
into the TooDee<T>
.
Examples
use toodee::TooDee; let mut toodee : TooDee<u32> = TooDee::default(); toodee.reserve_exact(50); assert_eq!(toodee.capacity(), 50);
pub fn reserve(&mut self, capacity: usize)
[src]
Reserves capacity for at least additional
more elements to be inserted
in the given TooDee<T>
.
Examples
use toodee::TooDee; let mut toodee : TooDee<u32> = TooDee::default(); toodee.reserve(50); assert!(toodee.capacity() >= 50);
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity of the underlying vector as much as possible.
Examples
use toodee::TooDee; let mut toodee : TooDee<u32> = TooDee::with_capacity(50); toodee.shrink_to_fit(); assert_eq!(toodee.capacity(), 0);
pub fn from_vec(num_cols: usize, num_rows: usize, v: Vec<T>) -> TooDee<T>
[src]
Create a new TooDee
array using the provided vector. The vector's length
must match the dimensions of the array.
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.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 10]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 2, v); assert_eq!(toodee.num_cols(), 5); assert_eq!(toodee.num_rows(), 2); assert_eq!(toodee[0][0], 42);
pub fn from_box(num_cols: usize, num_rows: usize, b: Box<[T]>) -> TooDee<T>
[src]
Create a new TooDee
array using the provided boxed slice. The slice's length
must match the dimensions of the array.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 10]; let mut toodee : TooDee<u32> = TooDee::from_box(5, 2, v.into_boxed_slice()); assert_eq!(toodee.num_cols(), 5); assert_eq!(toodee.num_rows(), 2); assert_eq!(toodee[0][0], 42);
pub fn data(&self) -> &[T]
[src]
Returns a reference to the raw array data
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 10]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 2, v); assert_eq!(toodee.data()[0], 42);
pub fn data_mut(&mut self) -> &mut [T]
[src]
Returns a mutable reference to the raw array data
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 10]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 2, v); assert_eq!(toodee.data_mut()[0], 42);
pub fn clear(&mut self)
[src]
Clears the array, removing all values and zeroing the number of columns and rows.
Note that this method has no effect on the allocated capacity of the array.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 10]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 2, v); toodee.clear(); assert_eq!(toodee.num_cols(), 0); assert_eq!(toodee.num_rows(), 0); assert!(toodee.capacity() >= 10);
pub fn pop_row(&mut self) -> Option<DrainTooDee<T>>
[src]
Removes the last row from the array and returns it as a Drain
, or None
if it is empty.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 15]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 3, v); { let drain = toodee.pop_row().unwrap(); assert_eq!(drain.len(), 5); } assert_eq!(toodee.num_cols(), 5); assert_eq!(toodee.num_rows(), 2);
pub fn push_row<I>(&mut self, data: impl IntoIterator<Item = T, IntoIter = I>) where
I: Iterator<Item = T> + ExactSizeIterator,
[src]
I: Iterator<Item = T> + ExactSizeIterator,
Appends a new row to the array.
Panics
Panics if the data's length doesn't match the length of existing rows (if any).
pub fn insert_row<I>(
&mut self,
index: usize,
data: impl IntoIterator<Item = T, IntoIter = I>
) where
I: Iterator<Item = T> + ExactSizeIterator,
[src]
&mut self,
index: usize,
data: impl IntoIterator<Item = T, IntoIter = I>
) where
I: Iterator<Item = T> + ExactSizeIterator,
Inserts new data
into the array at the specified row
Panics
Panics if the data's length doesn't match the length of existing rows (if any).
pub fn remove_row(&mut self, index: usize) -> DrainTooDee<T>
[src]
Removes the specified row from the array and returns it as a Drain
Panics
Panics if the specified row index is out of bounds.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 15]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 3, v); { let drain = toodee.remove_row(1); assert_eq!(drain.len(), 5); } assert_eq!(toodee.num_cols(), 5); assert_eq!(toodee.num_rows(), 2);
pub fn pop_col(&mut self) -> Option<DrainTooDee<T>>
[src]
Removes the last column from the array and returns it as a Drain
, or None
if it is empty.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 15]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 3, v); { let drain = toodee.pop_col().unwrap(); assert_eq!(drain.len(), 3); } assert_eq!(toodee.num_cols(), 4); assert_eq!(toodee.num_rows(), 3);
pub fn push_col<I>(&mut self, data: impl IntoIterator<Item = T, IntoIter = I>) where
I: Iterator<Item = T> + ExactSizeIterator,
[src]
I: Iterator<Item = T> + ExactSizeIterator,
Appends a new column to the array.
Panics
Panics if the data's length doesn't match the length of existing rows (if any).
pub fn remove_col(&mut self, index: usize) -> DrainTooDee<T>
[src]
Removes the specified column from the array and returns it as a Drain
Panics
Panics if the specified column index is out of bounds.
Examples
use toodee::{TooDee,TooDeeOps}; let v = vec![42u32; 15]; let mut toodee : TooDee<u32> = TooDee::from_vec(5, 3, v); { let drain = toodee.remove_col(1); assert_eq!(drain.len(), 3); } assert_eq!(toodee.num_cols(), 4); assert_eq!(toodee.num_rows(), 3);
pub fn insert_col<I>(
&mut self,
index: usize,
data: impl IntoIterator<Item = T, IntoIter = I>
) where
I: Iterator<Item = T> + ExactSizeIterator,
[src]
&mut self,
index: usize,
data: impl IntoIterator<Item = T, IntoIter = I>
) where
I: Iterator<Item = T> + ExactSizeIterator,
Inserts new data
into the array at the specified col
.
Panics
Panics if the data's length doesn't match the length of existing columns (if any).
Trait Implementations
impl<T> AsMut<[T]> for TooDee<T>
[src]
impl<T> AsRef<[T]> for TooDee<T>
[src]
impl<T: Clone> Clone for TooDee<T>
[src]
fn clone(&self) -> TooDee<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> CopyOps<T> for TooDee<T>
[src]
fn copy_from_slice(&mut self, src: &[T]) where
T: Copy,
[src]
T: Copy,
fn clone_from_slice(&mut self, src: &[T]) where
T: Clone,
[src]
T: Clone,
fn copy_from_toodee(&mut self, src: &impl TooDeeOps<T>) where
T: Copy,
[src]
T: Copy,
fn clone_from_toodee(&mut self, src: &impl TooDeeOps<T>) where
T: Clone,
[src]
T: Clone,
fn copy_within(&mut self, src: (Coordinate, Coordinate), dest: Coordinate) where
T: Copy,
[src]
T: Copy,
impl<T> Debug for TooDee<T> where
T: Debug,
[src]
T: Debug,
impl<T> Default for TooDee<T>
[src]
Custom Default
implementation because T
does not need to implement Default
.
See rust issue #26925
fn default() -> Self
[src]
Examples
use toodee::TooDee; struct Abc { } let toodee : TooDee<Abc> = TooDee::default();
impl<'_, T> From<TooDeeView<'_, T>> for TooDee<T> where
T: Clone,
[src]
T: Clone,
fn from(view: TooDeeView<T>) -> Self
[src]
impl<'_, T> From<TooDeeViewMut<'_, T>> for TooDee<T> where
T: Clone,
[src]
T: Clone,
fn from(view: TooDeeViewMut<T>) -> Self
[src]
impl<T> Index<(usize, usize)> for TooDee<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, coord: Coordinate) -> &Self::Output
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let toodee : TooDee<u32> = TooDee::new(10, 5); assert_eq!(toodee[(1,3)], 0);
impl<T> Index<usize> for TooDee<T>
[src]
type Output = [T]
The returned type after indexing.
fn index(&self, row: usize) -> &Self::Output
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let toodee : TooDee<u32> = TooDee::new(10, 5); let row = &toodee[3]; assert_eq!(row.len(), 10);
impl<T> IndexMut<(usize, usize)> for TooDee<T>
[src]
fn index_mut(&mut self, coord: Coordinate) -> &mut Self::Output
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let toodee : TooDee<u32> = TooDee::new(10, 5); assert_eq!(toodee[(1,3)], 0);
impl<T> IndexMut<usize> for TooDee<T>
[src]
fn index_mut(&mut self, row: usize) -> &mut Self::Output
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); let mut row = &mut toodee[3]; row[0] = 42;
impl<T> Into<Vec<T>> for TooDee<T>
[src]
Support conversion into a Vec
.
impl<T> IntoIterator for TooDee<T>
[src]
Use Vec
's IntoIter
for performance reasons.
TODO: return type that implements TooDeeIterator
type Item = T
The type of the elements being iterated over.
type IntoIter = IntoIterTooDee<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, T> IntoIterator for &'a TooDee<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Cells<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Cells
is the preferred iterator type here, because it implements TooDeeIterator
impl<'a, T> IntoIterator for &'a mut TooDee<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = CellsMut<'a, T>
CellsMut
is the preferred iterator type here, because it implements TooDeeIterator
fn into_iter(self) -> Self::IntoIter
[src]
impl<T> SortOps<T> for TooDee<T>
[src]
fn sort_row_ord<F>(&mut self, row: usize) where
T: Ord,
[src]
T: Ord,
fn sort_unstable_row_ord<F>(&mut self, row: usize) where
T: Ord,
[src]
T: Ord,
fn sort_by_row<F>(&mut self, row: usize, compare: F) where
F: FnMut(&T, &T) -> Ordering,
[src]
F: FnMut(&T, &T) -> Ordering,
fn sort_unstable_by_row<F>(&mut self, row: usize, compare: F) where
F: FnMut(&T, &T) -> Ordering,
[src]
F: FnMut(&T, &T) -> Ordering,
fn sort_by_row_key<B, F>(&mut self, row: usize, f: F) where
B: Ord,
F: FnMut(&T) -> B,
[src]
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,
[src]
B: Ord,
F: FnMut(&T) -> B,
fn sort_col_ord<F>(&mut self, col: usize) where
T: Ord,
[src]
T: Ord,
fn sort_by_col<F>(&mut self, col: usize, compare: F) where
F: FnMut(&T, &T) -> Ordering,
[src]
F: FnMut(&T, &T) -> Ordering,
fn sort_unstable_by_col<F>(&mut self, col: usize, compare: F) where
F: FnMut(&T, &T) -> Ordering,
[src]
F: FnMut(&T, &T) -> Ordering,
fn sort_by_col_key<B, F>(&mut self, col: usize, f: F) where
B: Ord,
F: FnMut(&T) -> B,
[src]
B: Ord,
F: FnMut(&T) -> B,
fn sort_unstable_by_col_key<B, F>(&mut self, col: usize, f: F) where
B: Ord,
F: FnMut(&T) -> B,
[src]
B: Ord,
F: FnMut(&T) -> B,
impl<T> TooDeeOps<T> for TooDee<T>
[src]
fn num_cols(&self) -> usize
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let toodee : TooDee<u32> = TooDee::new(10, 5); assert_eq!(toodee.num_cols(), 10);
fn num_rows(&self) -> usize
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let toodee : TooDee<u32> = TooDee::new(10, 5); assert_eq!(toodee.num_rows(), 5);
fn bounds(&self) -> (Coordinate, Coordinate)
[src]
Examples
use toodee::{TooDee,TooDeeOps}; let toodee : TooDee<u32> = TooDee::new(10, 5); assert_eq!(toodee.bounds(), ((0, 0), (10, 5)));
fn view(&self, start: Coordinate, end: Coordinate) -> TooDeeView<T>
[src]
Examples
use toodee::{TooDee,TooDeeOps}; let toodee : TooDee<u32> = TooDee::new(10, 5); let view = toodee.view((1,2), (8,4)); assert_eq!(view.num_cols(), 7); assert_eq!(view.num_rows(), 2);
fn rows(&self) -> Rows<T>
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); let mut rows = toodee.rows(); assert_eq!(rows.len(), 5); let r0 = rows.next().unwrap(); assert_eq!(r0.len(), 10);
fn col(&self, col: usize) -> Col<T>
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); let mut col = toodee.col(8); assert_eq!(col.len(), 5);
fn size(&self) -> (usize, usize)
[src]
fn is_empty(&self) -> bool
[src]
fn cells(&self) -> Cells<T>
[src]
impl<T> TooDeeOpsMut<T> for TooDee<T>
[src]
fn view_mut(&mut self, start: Coordinate, end: Coordinate) -> TooDeeViewMut<T>
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); let view = toodee.view_mut((1,2), (8,4)); assert_eq!(view.num_cols(), 7); assert_eq!(view.num_rows(), 2);
fn rows_mut(&mut self) -> RowsMut<T>
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); let mut rows = toodee.rows_mut(); assert_eq!(rows.len(), 5); let r0 = rows.next().unwrap(); assert_eq!(r0.len(), 10);
fn col_mut(&mut self, col: usize) -> ColMut<T>
[src]
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); let mut col = toodee.col_mut(8); assert_eq!(col.len(), 5);
fn fill<V>(&mut self, fill: V) where
V: Borrow<T>,
T: Clone,
[src]
V: Borrow<T>,
T: Clone,
Examples
use toodee::{TooDee,TooDeeOps,TooDeeOpsMut}; let mut toodee : TooDee<u32> = TooDee::new(10, 5); toodee.fill(42); assert_eq!(toodee[1][1], 42);
fn cells_mut(&mut self) -> CellsMut<T>
[src]
fn swap_cols(&mut self, c1: usize, c2: usize)
[src]
fn swap_rows(&mut self, r1: usize, r2: usize)
[src]
fn row_pair_mut(&mut self, r1: usize, r2: usize) -> (&mut [T], &mut [T])
[src]
impl<T> TranslateOps<T> for TooDee<T>
[src]
fn translate_with_wrap(&mut self, mid: Coordinate)
[src]
fn flip_rows(&mut self)
[src]
fn flip_cols(&mut self)
[src]
Auto Trait Implementations
impl<T> Send for TooDee<T> where
T: Send,
T: Send,
impl<T> Sync for TooDee<T> where
T: Sync,
T: Sync,
impl<T> Unpin for TooDee<T> where
T: Unpin,
T: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,