Function merge_sparse_indices_intersect

Source
pub fn merge_sparse_indices_intersect<I: Ord, T, U>(
    left: impl Iterator<Item = (I, T)>,
    right: impl Iterator<Item = (I, T)>,
    operation: impl Fn(T, T) -> U,
    is_not_default: impl Fn(&U) -> bool,
) -> Vec<(I, U)>
Expand description

Collect two sparse iterators by merging the indices that they share, dropping the others.

§Arguments

  • left: The first iterator, sorted by index.
  • right: The second iterator, sorted by index.
  • operation: A binary operation applied when an element is found at some index in both iterators.
  • is_not_default: A function specifying whether the result if the binary operation is the default value (that is often zero).

§Return value

A vector with sparse elements by sorted and unique index.