pub trait IntoSparseVecIter<'a, N: 'a> {
    type IterType;

    // Required methods
    fn into_sparse_vec_iter(
        self
    ) -> <Self as IntoSparseVecIter<'a, N>>::IterType
       where <Self as IntoSparseVecIter<'a, N>>::IterType: Iterator<Item = (usize, &'a N)>;
    fn dim(&self) -> usize;

    // Provided methods
    fn is_dense(&self) -> bool { ... }
    fn index(self, idx: usize) -> &'a N
       where Self: Sized { ... }
}
Expand description

Trait for types that can be iterated as sparse vectors

Required Associated Types§

Required Methods§

source

fn into_sparse_vec_iter(self) -> <Self as IntoSparseVecIter<'a, N>>::IterTypewhere <Self as IntoSparseVecIter<'a, N>>::IterType: Iterator<Item = (usize, &'a N)>,

Transform self into an iterator that yields (usize, &N) tuples where the usize is the index of the value in the sparse vector. The indices should be sorted.

source

fn dim(&self) -> usize

The dimension of the vector

Provided Methods§

source

fn is_dense(&self) -> bool

Indicator to check whether the vector is actually dense

source

fn index(self, idx: usize) -> &'a Nwhere Self: Sized,

Random access to an element in the vector.

Panics
  • if the vector is not dense
  • if the index is out of bounds

Implementations on Foreign Types§

source§

impl<'a, N: 'a, V> IntoSparseVecIter<'a, N> for &'a Vwhere V: DenseVector<Scalar = N> + ?Sized,

§

type IterType = Map<Zip<Repeat<&'a V>, Range<usize>>, fn(_: (&'a V, usize)) -> (usize, &'a N)>

source§

fn into_sparse_vec_iter(self) -> Self::IterType

source§

fn dim(&self) -> usize

source§

fn is_dense(&self) -> bool

source§

fn index(self, idx: usize) -> &'a N

Implementors§

source§

impl<'a, N: 'a, I> IntoSparseVecIter<'a, N> for CsVecViewI<'a, N, I>where I: SpIndex + 'a,

§

type IterType = VectorIterator<'a, N, I>

source§

impl<'a, N: 'a, I, IS, DS> IntoSparseVecIter<'a, N> for &'a CsVecBase<IS, DS, N, I>where I: SpIndex + 'a, IS: Deref<Target = [I]>, DS: Deref<Target = [N]>,

§

type IterType = VectorIterator<'a, N, I>