Skip to main content

VectorViewSparse

Trait VectorViewSparse 

Source
pub trait VectorViewSparse<T: ?Sized>: VectorView<T> {
    type Iter<'a>: Iterator<Item = (usize, &'a T)>
       where Self: 'a,
             T: 'a;

    // Required method
    fn nontrivial_entries<'a>(&'a self) -> Self::Iter<'a>;
}
Expand description

View on a sequence type that stores its data in a sparse format. This clearly requires that the underlying type T has some notion of a “zero” element.

Required Associated Types§

Source

type Iter<'a>: Iterator<Item = (usize, &'a T)> where Self: 'a, T: 'a

Required Methods§

Source

fn nontrivial_entries<'a>(&'a self) -> Self::Iter<'a>

Returns an iterator over all elements of the sequence with their indices that are “nonzero” (T must have an appropriate notion of zero).

§Example
let mut vector = SparseMapVector::new(10, StaticRing::<i64>::RING);
*vector.at_mut(2) = 100;
assert_eq!(
    vec![(2, 100)],
    vector
        .nontrivial_entries()
        .map(|(i, x)| (i, *x))
        .collect::<Vec<_>>()
);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: ?Sized, V: ?Sized + VectorViewSparse<T>> VectorViewSparse<T> for &V

Source§

type Iter<'b> = <V as VectorViewSparse<T>>::Iter<'b> where Self: 'b, T: 'b

Source§

fn nontrivial_entries<'b>(&'b self) -> Self::Iter<'b>

Source§

impl<T: ?Sized, V: ?Sized + VectorViewSparse<T>> VectorViewSparse<T> for &mut V

Source§

type Iter<'b> = <V as VectorViewSparse<T>>::Iter<'b> where Self: 'b, T: 'b

Source§

fn nontrivial_entries<'b>(&'b self) -> Self::Iter<'b>

Source§

impl<T: ?Sized, V: ?Sized + VectorViewSparse<T>> VectorViewSparse<T> for Box<V>

Source§

type Iter<'b> = <V as VectorViewSparse<T>>::Iter<'b> where Self: 'b, T: 'b

Source§

fn nontrivial_entries<'b>(&'b self) -> Self::Iter<'b>

Implementors§

Source§

impl<R: RingStore> VectorViewSparse<<<R as RingStore>::Type as RingBase>::Element> for SparseMapVector<R>

Source§

type Iter<'a> = SparseMapVectorIter<'a, R> where Self: 'a

Source§

impl<V: VectorViewSparse<T>, T: ?Sized> VectorViewSparse<T> for SubvectorView<V, T>

Source§

type Iter<'a> = FilterWithinRangeIter<'a, T, <V as VectorViewSparse<T>>::Iter<'a>> where Self: 'a, T: 'a