Struct toodee::TooDeeView

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

Provides a read-only view (or subset) of a TooDee array.

Implementations§

source§

impl<'a, T> TooDeeView<'a, T>

source

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

Create a new TooDeeViewMut using the provided 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::TooDeeView;
let data = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
let view = TooDeeView::new(4, 3, &data);

Trait Implementations§

source§

impl<'a, T: Clone> Clone for TooDeeView<'a, T>

source§

fn clone(&self) -> TooDeeView<'a, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for TooDeeView<'_, 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<TooDeeView<'_, T>> for TooDee<T>where T: Clone,

source§

fn from(view: TooDeeView<'_, 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 TooDeeView<'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 TooDeeView<'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 TooDeeView<'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> IntoIterator for &'a TooDeeView<'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: PartialEq> PartialEq<TooDeeView<'a, T>> for TooDeeView<'a, T>

source§

fn eq(&self, other: &TooDeeView<'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 TooDeeView<'_, 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 TooDeeView<'a, T>

source§

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

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

fn num_cols(&self) -> usize

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

fn num_rows(&self) -> usize

The number of rows 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: Copy> Copy for TooDeeView<'a, T>

source§

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

source§

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

source§

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

Auto Trait Implementations§

§

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

§

impl<'a, T> Send for TooDeeView<'a, T>where T: Sync,

§

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

§

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

§

impl<'a, T> UnwindSafe for TooDeeView<'a, T>where T: RefUnwindSafe,

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.