pub struct CsrMatrixRowConstructor<'a, DS, US> { /* private fields */ }Expand description
Constructs a new valid row in a easy and interactive manner, abstracting away the complexity of the CSR format.
This struct may panic when out of scope. Please see the Drop documentation in
the Trait Implementations section for more information.
Implementations§
Source§impl<'a, DS, US> CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS, US> CsrMatrixRowConstructor<'a, DS, US>
Sourcepub fn commit(self)
pub fn commit(self)
Commits the row construction, modifying the internal structure.
§Examples
use mop_structs::{
doc_tests::csr_matrix_empty_vec_array,
matrix::csr_matrix::CsrMatrixRef
};
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().commit();
assert_eq!(a.as_ref(), CsrMatrixRef::new([1, 5], &[], &[], &[0, 0]));§Assertions
- Inserted indices must be less than the number of columns of
Self.
ⓘ
use mop_structs::doc_tests::csr_matrix_empty_vec_array;
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(10, 1).commit();- Inserted indices must be unique.
ⓘ
use mop_structs::doc_tests::csr_matrix_empty_vec_array;
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(1, 1).set_value(1, 10).commit();Sourcepub unsafe fn commit_unchecked(self)
pub unsafe fn commit_unchecked(self)
A faster and unsafe version of commit.
Sourcepub fn copy_values_from_row(self, row: &CssSlice<'_, DS::Item>) -> Self
pub fn copy_values_from_row(self, row: &CssSlice<'_, DS::Item>) -> Self
Copies all values of row into the current row.
§Examples
use mop_structs::{
doc_tests::csr_matrix_empty_vec_array,
matrix::csr_matrix::CsrMatrixRef,
vec::css::CssSlice
};
let mut a = csr_matrix_empty_vec_array();
let b = CssSlice::new(5, &[1, 2], &[0, 1]);
a.row_constructor().copy_values_from_row(&b).commit();
assert_eq!(a.as_ref(), CsrMatrixRef::new(
[1, 5],
&[1, 2],
&[0, 1],
&[0, 2]
));Sourcepub fn set_value(self, column_idx: usize, value: DS::Item) -> Self
pub fn set_value(self, column_idx: usize, value: DS::Item) -> Self
Sets a new value in the current row and column index column_idx.
§Examples
use mop_structs::{
doc_tests::csr_matrix_empty_vec_array,
matrix::csr_matrix::CsrMatrixRef
};
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(1, 1).commit();
assert_eq!(a.as_ref(), CsrMatrixRef::new([1, 5], &[1], &[1], &[0, 1]));Trait Implementations§
Source§impl<'a, DS, US> Drop for CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS, US> Drop for CsrMatrixRowConstructor<'a, DS, US>
Source§fn drop(&mut self)
fn drop(&mut self)
Some measures are taken to ensure the CSR format and avoid unexpected runtime behavior.
§Assertions
- Every single nonempty instance of
CsrRowLayerConstructormust end with a call to thecommitmethod.
ⓘ
use mop_structs::doc_tests::csr_matrix_empty_vec_array;
let mut a = csr_matrix_empty_vec_array();
a.row_constructor().set_value(1, 1);Source§impl<'a, DS: PartialEq, US: PartialEq> PartialEq for CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS: PartialEq, US: PartialEq> PartialEq for CsrMatrixRowConstructor<'a, DS, US>
Source§fn eq(&self, other: &CsrMatrixRowConstructor<'a, DS, US>) -> bool
fn eq(&self, other: &CsrMatrixRowConstructor<'a, DS, US>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<'a, DS, US> StructuralPartialEq for CsrMatrixRowConstructor<'a, DS, US>
Auto Trait Implementations§
impl<'a, DS, US> Freeze for CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS, US> RefUnwindSafe for CsrMatrixRowConstructor<'a, DS, US>where
DS: RefUnwindSafe,
US: RefUnwindSafe,
impl<'a, DS, US> Send for CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS, US> Sync for CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS, US> Unpin for CsrMatrixRowConstructor<'a, DS, US>
impl<'a, DS, US> !UnwindSafe for CsrMatrixRowConstructor<'a, DS, US>
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> 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