diff --git a/nalgebra-sparse/src/coo.rs b/nalgebra-sparse/src/coo.rs index 25dc07fb..b71cb0b6 100644 --- a/nalgebra-sparse/src/coo.rs +++ b/nalgebra-sparse/src/coo.rs @@ -170,6 +170,16 @@ impl CooMatrix { .map(|((i, j), v)| (*i, *j, v)) } + /// A mutable iterator over triplets (i, j, v). + // TODO: Consider giving the iterator a concrete type instead of impl trait...? + pub fn triplet_iter_mut(&mut self) -> impl Iterator { + self.row_indices + .iter() + .zip(&self.col_indices) + .zip(self.values.iter_mut()) + .map(|((i, j), v)| (*i, *j, v)) + } + /// Reserves capacity for COO matrix by at least `additional` elements. /// /// This increase the capacities of triplet holding arrays by reserving more space to avoid