ArrayNd

Struct ArrayNd 

Source
pub struct ArrayNd<const N: usize, T> {
    pub data: Vec<T>,
    pub dims: [usize; N],
    pub dim_strides: [usize; N],
}

Fields§

§data: Vec<T>§dims: [usize; N]§dim_strides: [usize; N]

Implementations§

Source§

impl<'a, const C: usize, T: Copy> ArrayNd<C, T>

Source

pub fn iter(&'a self) -> Iter<'a, T>

Source§

impl<'a, const C: usize, T: Copy> ArrayNd<C, T>

Source

pub fn iter_mut(&'a mut self) -> IterMut<'a, T>

Source§

impl<const C: usize, T: Copy> ArrayNd<C, T>

Source

pub fn new<U: Copy + TryInto<usize>>(dims: [U; C], default: T) -> Self

Source

pub fn from_slice<U: Copy + TryInto<usize>>(dims: [U; C], slice: &[T]) -> Self

Source

pub fn resized( &self, new_dims: [usize; C], default: T, offset: Vector<C, i32>, ) -> Self

Source

pub fn padded(&self, padding: i32, default: T) -> Self

Source§

impl<const N: usize, T: Copy + PartialEq> ArrayNd<N, T>

Source

pub fn replace_all(&mut self, from: &T, to: &T)

Source§

impl<const N: usize, T> ArrayNd<N, T>

Source

pub fn get_linear(&self, index: usize) -> &T

Source

pub fn get_mut_linear(&mut self, index: usize) -> &mut T

Source

pub fn set_linear(&mut self, index: usize, v: T)

Source

pub fn get<I>(&self, p: I) -> Option<&T>
where Self: LinearIndex<I>,

Source

pub fn get_mut<I>(&mut self, p: I) -> Option<&mut T>
where Self: LinearIndex<I>,

Source

pub fn set<I>(&mut self, p: I, v: T) -> bool
where Self: LinearIndex<I>,

Source§

impl<const N: usize, T> ArrayNd<N, T>

Source

pub fn find_item(&self, item: &T) -> Option<Vector<N, i32>>
where T: PartialEq,

Source

pub fn find_last_item(&self, item: &T) -> Option<Vector<N, i32>>
where T: PartialEq,

Source

pub fn find_all<F, I>(&self, predicate: F) -> Vec<I>
where F: Fn(&T) -> bool, T: PartialEq, Self: LinearIndex<I>,

Source

pub fn find_all_items<I>(&self, item: &T) -> Vec<I>
where T: PartialEq, Self: LinearIndex<I>,

Source§

impl<const N: usize, T> ArrayNd<N, T>

Source

pub fn map<F, U>(&self, f: F) -> ArrayNd<N, U>
where F: Fn(&T) -> U,

Source§

impl<const N: usize, T> ArrayNd<N, T>

Source

pub fn line_iter<const B: bool>( &self, p0: Vector<N, i32>, p1: Vector<N, i32>, ) -> LineIterator<B, N>

Source§

impl<const N: usize, T> ArrayNd<N, T>

Source

pub fn iter_values_in_line<const B: bool>( &self, p0: Vector<N, i32>, p1: Vector<N, i32>, ) -> impl Iterator<Item = &T>

Source§

impl<const N: usize, T: Copy> ArrayNd<N, T>

Source

pub fn draw_line<const B: bool>(&mut self, line: Line<Vector<N, i32>>, v: T)

Source§

impl<const N: usize, T: Copy> ArrayNd<N, T>

Source

pub fn draw_block(&mut self, matching: [Option<usize>; N], v: T)

Source§

impl<T> ArrayNd<2, T>

Source

pub fn width(&self) -> usize

Source

pub fn height(&self) -> usize

Source§

impl<T> ArrayNd<3, T>

Source

pub fn width(&self) -> usize

Source

pub fn height(&self) -> usize

Source

pub fn depth(&self) -> usize

Source§

impl ArrayNd<2, char>

Source

pub fn from_buffer<R: Read>( reader: BufReader<R>, ) -> Result<Self, CharArrayParseError>

Source

pub fn from_read<R: Read>(reader: R) -> Result<Self, CharArrayParseError>

Source§

impl<T: Copy> ArrayNd<2, T>

Source

pub fn with_dimensions(width: usize, height: usize, default: T) -> Self

Source

pub fn shift_n_rows_down(&mut self, n: usize, default: T)

Source§

impl<T: Copy> ArrayNd<3, T>

Source

pub fn with_dimensions( width: usize, height: usize, depth: usize, default: T, ) -> Self

Trait Implementations§

Source§

impl<const N: usize, T: Clone> Clone for ArrayNd<N, T>

Source§

fn clone(&self) -> ArrayNd<N, T>

Returns a duplicate 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<const N: usize, T: Debug> Debug for ArrayNd<N, T>

Source§

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

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

impl<'de, const N: usize, T> Deserialize<'de> for ArrayNd<N, T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<const C: usize, T: Display> Display for ArrayNd<C, T>

Source§

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

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

impl<const N: usize, T: Hash> Hash for ArrayNd<N, 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<const C: usize, T: Copy> Index<Vector<C, i32>> for ArrayNd<C, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: Vector<C, i32>) -> &Self::Output

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

impl<const C: usize, T: Copy> Index<usize> for ArrayNd<C, T>

Source§

type Output = T

The returned type after indexing.
Source§

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

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

impl<const C: usize, T: Copy> IndexMut<usize> for ArrayNd<C, T>

Source§

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

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

impl<'a, const C: usize, T: Copy> IntoIterator for &'a ArrayNd<C, T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'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, const C: usize, T: Copy> IntoIterator for &'a mut ArrayNd<C, T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'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<const C: usize, T: Copy> IntoIterator for ArrayNd<C, T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<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<const N: usize, T> LinearIndex<Vector<N, i32>> for ArrayNd<N, T>

Source§

fn index_unchecked(&self, i: Vector<N, i32>) -> Option<usize>

Source§

fn unindex(&self, i: usize) -> Option<Vector<N, i32>>

Source§

unsafe fn cardinality(&self) -> Option<usize>

👎Deprecated
This is unsafe and should not be called as overflows are not checked. Uses Iterator::product Read more
Source§

fn is_in_bounds(&self, i: &Vector<N, i32>) -> bool

Source§

fn index(&self, i: I) -> Option<usize>

Source§

impl<const N: usize, T> LinearIndex<Vector<N, usize>> for ArrayNd<N, T>

Source§

fn index_unchecked(&self, i: Vector<N, usize>) -> Option<usize>

Source§

fn unindex(&self, i: usize) -> Option<Vector<N, usize>>

Source§

unsafe fn cardinality(&self) -> Option<usize>

👎Deprecated
This is unsafe and should not be called as overflows are not checked. Uses Iterator::product Read more
Source§

fn is_in_bounds(&self, i: &Vector<N, usize>) -> bool

Source§

fn index(&self, i: I) -> Option<usize>

Source§

impl<const N: usize, T> LinearIndex<usize> for ArrayNd<N, T>

Source§

fn index_unchecked(&self, i: usize) -> Option<usize>

Source§

fn unindex(&self, i: usize) -> Option<usize>

Source§

unsafe fn cardinality(&self) -> Option<usize>

👎Deprecated
This is unsafe and should not be called as overflows are not checked. Uses Iterator::product Read more
Source§

fn is_in_bounds(&self, i: &usize) -> bool

Source§

fn index(&self, i: I) -> Option<usize>

Source§

impl<const N: usize, T: PartialEq> PartialEq for ArrayNd<N, T>

Source§

fn eq(&self, other: &ArrayNd<N, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize, T> Serialize for ArrayNd<N, T>
where T: Serialize,

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<const N: usize, T: Eq> Eq for ArrayNd<N, T>

Source§

impl<const C: usize, T> IterateNeighboursContext for ArrayNd<C, T>

Source§

impl<const N: usize, T> StructuralPartialEq for ArrayNd<N, T>

Auto Trait Implementations§

§

impl<const N: usize, T> Freeze for ArrayNd<N, T>

§

impl<const N: usize, T> RefUnwindSafe for ArrayNd<N, T>
where T: RefUnwindSafe,

§

impl<const N: usize, T> Send for ArrayNd<N, T>
where T: Send,

§

impl<const N: usize, T> Sync for ArrayNd<N, T>
where T: Sync,

§

impl<const N: usize, T> Unpin for ArrayNd<N, T>
where T: Unpin,

§

impl<const N: usize, T> UnwindSafe for ArrayNd<N, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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<const C: usize, T, U> IterateNeighbours<ArrayNd<C, U>> for T
where T: IterateNeighbours<()> + Copy, ArrayNd<C, U>: LinearIndex<T>,

Source§

fn neighbours(&self, _context: &ArrayNd<C, U>) -> Vec<T>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,