[][src]Struct toodee::TooDee

pub struct TooDee<T> { /* fields omitted */ }

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]

Create a new TooDee array of the specified dimensions, and fill it with the type's default value.

Will panic 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.

pub fn init(num_cols: usize, num_rows: usize, init_value: T) -> TooDee<T> where
    T: Clone
[src]

Create a new TooDee array of the specified dimensions, and fill it with an initial value.

Will panic 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.

pub fn with_capacity(capacity: usize) -> TooDee<T>[src]

Constructs a new, empty TooDee<T> with the specified element capacity.

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>.

pub fn reserve(&mut self, capacity: usize)[src]

Reserves capacity for at least additional more elements to be inserted in the given TooDee<T>.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the underlying vector as much as possible.

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.

Will panic 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.

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.

pub fn data(&self) -> &[T][src]

Returns a reference to the raw array data

pub fn data_mut(&mut self) -> &mut [T][src]

Returns a mutable reference to the raw array data

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.

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.

pub fn push_row<I>(&mut self, data: impl IntoIterator<Item = T, IntoIter = I>) where
    I: Iterator<Item = T> + ExactSizeIterator
[src]

Appends a new row to the array.

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]

Inserts new data into the array at the specified row

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 if the specified row index is out of bounds.

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.

pub fn push_col<I>(&mut self, data: impl IntoIterator<Item = T, IntoIter = I>) where
    I: Iterator<Item = T> + ExactSizeIterator
[src]

Appends a new column to the array.

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 if the specified column index is out of bounds.

pub fn insert_col<I>(
    &mut self,
    index: usize,
    data: impl IntoIterator<Item = T, IntoIter = I>
) where
    I: Iterator<Item = T> + ExactSizeIterator
[src]

Inserts new data into the array at the specified col.

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]

impl<T> CopyOps<T> for TooDee<T>[src]

impl<T> Debug for TooDee<T> where
    T: Debug
[src]

impl<T> Default for TooDee<T>[src]

Custom Default implementation because T does not need to implement Default. See https://github.com/rust-lang/rust/issues/26925

impl<'_, T> From<TooDeeView<'_, T>> for TooDee<T> where
    T: Clone
[src]

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

impl<T> Index<usize> for TooDee<T>[src]

type Output = [T]

The returned type after indexing.

impl<T> IndexMut<usize> for TooDee<T>[src]

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?

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

impl<T> SortOps<T> for TooDee<T>[src]

impl<T> TooDeeOps<T> for TooDee<T>[src]

impl<T> TooDeeOpsMut<T> for TooDee<T>[src]

impl<T> TranslateOps<T> for TooDee<T>[src]

Auto Trait Implementations

impl<T> Send for TooDee<T> where
    T: Send

impl<T> Sync for TooDee<T> where
    T: Sync

impl<T> Unpin for TooDee<T> where
    T: Unpin

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<I> IntoIterator for I where
    I: Iterator
[src]

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?

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.