pub trait DimOffset<const N: usize>: Collection {
// Required method
fn offset<V2>(&self, md_index: &V2) -> Self::Scalar
where V2: ArrayRef<Self::Scalar, N> + Collection<Scalar = Self::Scalar> + Debug + ?Sized;
}Expand description
Trait for converting a multidimensional index into a flat offset.
This trait is implemented for arrays of any dimension, allowing conversion of a multidimensional index into a single linear offset. It is useful for mapping coordinates in a multidimensional space to a flat array.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<E, V, const N: usize> DimOffset<N> for Vwhere
Self: Collection<Scalar = E> + Debug,
E: Mul<E, Output = E> + Add<E, Output = E> + PartialOrd + Copy + Default + From<u8>,
V: ArrayRef<E, N> + Collection<Scalar = E> + Debug + ?Sized,
Implementation of DimOffset for arrays of any dimension.
This implementation calculates the flat offset by iterating over the dimensions in reverse order, ensuring that the most significant dimension is processed last.