pub struct Dense<DS, const D: usize> { /* private fields */ }Expand description
Implementations§
Source§impl<DATA, DS, const D: usize> Dense<DS, D>
impl<DATA, DS, const D: usize> Dense<DS, D>
Sourcepub fn new(dims: [usize; D], data: DS) -> Result<Self>
pub fn new(dims: [usize; D], data: DS) -> Result<Self>
Creates a valid Dense instance.
§Arguments
dims: Array of dimensionsdata: Data collection
§Example
use ndstruct::dense::{DenseArray, DenseVec};
// Matrix ([1, 2, 3], [4, 5, 6])
let mut _matrix = DenseArray::new([2, 3], [1, 2, 3, 4, 5, 6]);
// A bunch of nothing for your overflow needs
let _over_nine: ndstruct::Result<DenseVec<(), 9001>>;
_over_nine = DenseVec::new([0; 9001], vec![]);Sourcepub fn data(&self) -> &[DATA]
pub fn data(&self) -> &[DATA]
The data that is being stored.
§Example
use ndstruct::doc_tests::dense_array_3;
assert_eq!(dense_array_3().data(), &[
1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36,
]);Sourcepub fn value(&self, indcs: [usize; D]) -> Option<&DATA>
pub fn value(&self, indcs: [usize; D]) -> Option<&DATA>
If any, retrieves an immutable data reference of a given set of indices.
§Arguments
indcs: Indices of the desired data location
§Example
use ndstruct::doc_tests::dense_array_3;
let elem = dense_array_3();
assert_eq!(elem.value([0, 0, 0]), Some(&1));
assert_eq!(elem.value([0, 0, 2]), Some(&3));
assert_eq!(elem.value([0, 2, 2]), Some(&9));
assert_eq!(elem.value([3, 2, 2]), Some(&36));
assert_eq!(elem.value([3, 2, 3]), None);Trait Implementations§
Source§impl<'de, DS, const D: usize> Deserialize<'de> for Dense<DS, D>where
DS: Deserialize<'de>,
impl<'de, DS, const D: usize> Deserialize<'de> for Dense<DS, D>where
DS: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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<DS: Ord, const D: usize> Ord for Dense<DS, D>
impl<DS: Ord, const D: usize> Ord for Dense<DS, D>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<DS: PartialOrd, const D: usize> PartialOrd for Dense<DS, D>
impl<DS: PartialOrd, const D: usize> PartialOrd for Dense<DS, D>
impl<DS: Eq, const D: usize> Eq for Dense<DS, D>
impl<DS, const D: usize> StructuralPartialEq for Dense<DS, D>
Auto Trait Implementations§
impl<DS, const D: usize> Freeze for Dense<DS, D>where
DS: Freeze,
impl<DS, const D: usize> RefUnwindSafe for Dense<DS, D>where
DS: RefUnwindSafe,
impl<DS, const D: usize> Send for Dense<DS, D>where
DS: Send,
impl<DS, const D: usize> Sync for Dense<DS, D>where
DS: Sync,
impl<DS, const D: usize> Unpin for Dense<DS, D>where
DS: Unpin,
impl<DS, const D: usize> UnwindSafe for Dense<DS, D>where
DS: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more