Expand description
This crate provides types to deal with multi-dimensional data.
It basically tries to generalize over Box<[T]>
, &[T]
and
&mut [T]
to multiple dimensions. As a side effect, it also
supports one-dimensional arrays that have a stride other than one.
§Examples
Here’s an example of a 3D array. One 2D view and one 1D view into part of the data is created.
use multiarray::*;
let mut voxels = Array3D::new([3,4,5], 0); // 3x4x5 ints
voxels[[0,0,0]] = 1;
voxels[[1,2,3]] = 23;
voxels[[2,3,4]] = 42;
assert!(voxels[[1,2,3]] == 23);
let slice = voxels.eliminated_dim(1, 2); // 2D slice
assert!(slice[[1,3]] == 23);
let lane = slice.eliminated_dim(1, 3); // 1D lane
assert!(lane[1] == 23);
Please note that [usize; N]
is used as index. For convenience
the one-dimensional case also supports usize
as index in
addition to [usize; 1]
, the one-dimensional views are convertible
from borrowed slices (&[T]
and &mut[T]
) via
std::convert::{ From, Into }
and also implement the iterator traits
Iterator
, ExactSizeIterator
and DoubleEndedIterator
.
Structs§
- Dim1
- Dim2
- Dim3
- Dim4
- Dim5
- Dim6
- Multi
Array - Type for multi-dimensional arrays that are organized linearly in memory much like a C array but with dynamically determined sizes.
- Multi
Array Ref - Shared view of a multi-dimensional array
- Multi
Array RefMut - Mutable view of a multi-dimensional array
- Wrapped
- Helper type to wrap things. This helps avoiding trait coherency issues
w.r.t.
AsRef
andFrom
.
Traits§
- Layout
Helper - Helper trait for creating small
isize
andusize
arrays of a fixed size. They are used to store information about the memory layout of a multi-dimensional array. - Layout
Helper Ext - Extension trait for dimensions higher than one
Type Aliases§
- Array1D
- Type alias for a 1D array
- Array1D
Ref - Shared view of a 1D array
- Array1D
RefMut - Mutable view of a 1D array
- Array2D
- Type alias for a 2D array
- Array2D
Ref - Shared view of a 2D array
- Array2D
RefMut - Mutable view of a 2D array
- Array3D
- Type alias for a 3D array
- Array3D
Ref - Shared view of a 3D array
- Array3D
RefMut - Mutable view of a 3D array
- Array4D
- Type alias for a 4D array
- Array4D
Ref - Shared view of a 4D array
- Array4D
RefMut - Mutable view of a 4D array
- Array5D
- Type alias for a 5D array
- Array5D
Ref - Shared view of a 5D array
- Array5D
RefMut - Mutable view of a 5D array
- Array6D
- Type alias for a 6D array
- Array6D
Ref - Shared view of a 6D array
- Array6D
RefMut - Mutable view of a 6D array