Trait totsu_core::solver::SliceLike
source · pub trait SliceLike {
type F: Float;
fn new_ref(s: &[Self::F]) -> SliceRef<'_, Self>;
fn new_mut(s: &mut [Self::F]) -> SliceMut<'_, Self>;
fn split_ref(&self, mid: usize) -> (SliceRef<'_, Self>, SliceRef<'_, Self>);
fn split_mut(
&mut self,
mid: usize
) -> (SliceMut<'_, Self>, SliceMut<'_, Self>);
fn drop(&self);
fn len(&self) -> usize;
fn get_ref(&self) -> &[Self::F];
fn get_mut(&mut self) -> &mut [Self::F];
fn get(&self, idx: usize) -> Self::F { ... }
fn set(&mut self, idx: usize, val: Self::F) { ... }
}
Expand description
Slice-like trait for a vector of linear algebra.
crate::solver::LinAlg::Sl
shall have this trait boundary.
Required Associated Types§
sourcetype F: Float
type F: Float
Floating point data type of slice elements.
This will be the same as crate::solver::LinAlg::F
.
Required Methods§
sourcefn new_ref(s: &[Self::F]) -> SliceRef<'_, Self>
fn new_ref(s: &[Self::F]) -> SliceRef<'_, Self>
Borrows a slice from which SliceLike
is created, and a reference of the SliceLike
is wrapped by a SliceRef
.
SliceLike::drop
shall be called when the SliceRef
drops,
which means the borrowal ends and the SliceLike
can be dropped safely.
Returns the SliceRef
wrapping the reference of SliceLike
.
s
is a reference of the original slice.
sourcefn new_mut(s: &mut [Self::F]) -> SliceMut<'_, Self>
fn new_mut(s: &mut [Self::F]) -> SliceMut<'_, Self>
Mutable version of SliceLike::new_ref
.
sourcefn split_ref(&self, mid: usize) -> (SliceRef<'_, Self>, SliceRef<'_, Self>)
fn split_ref(&self, mid: usize) -> (SliceRef<'_, Self>, SliceRef<'_, Self>)
Divides one reference of a SliceLike
into two SliceRef
s at an index mid
.
As with SliceLike::new_ref
, SliceLike::drop
shall be called when each of the SliceRef
s drop.
Returns all indices from [0
, mid
) as the first and all indices from [mid
, SliceLike::len()
) as the second.
mid
is an index for splitting.
sourcefn split_mut(&mut self, mid: usize) -> (SliceMut<'_, Self>, SliceMut<'_, Self>)
fn split_mut(&mut self, mid: usize) -> (SliceMut<'_, Self>, SliceMut<'_, Self>)
Mutable version of SliceLike::split_ref
.
sourcefn get_mut(&mut self) -> &mut [Self::F]
fn get_mut(&mut self) -> &mut [Self::F]
Mutable version of SliceLike::get_ref
.