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§

Floating point data type of slice elements.

This will be the same as crate::solver::LinAlg::F.

Required Methods§

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.

Mutable version of SliceLike::new_ref.

Divides one reference of a SliceLike into two SliceRefs at an index mid.

As with SliceLike::new_ref, SliceLike::drop shall be called when each of the SliceRefs 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.

Mutable version of SliceLike::split_ref.

Drops a SliceLike.

This shall be called when SliceRef or SliceMut drops. At this point the referenced SliceLike can be dropped safely.

Returns the length of the SliceLike’s content slice.

Returns a reference of the SliceLike’s content slice.

Mutable version of SliceLike::get_ref.

Provided Methods§

Returns a single element of the SliceLike at an index idx.

Using SliceLike::get_ref is more efficient if you traverse the SliceLike’s content.

Sets a single element of the SliceLike at an index idx with a given value val.

Using SliceLike::get_mut is more efficient if you traverse the SliceLike’s content.

Implementations on Foreign Types§

Implementors§