hid CsInnerIter behind CsrInnerIter and CscInnerIter
This commit is contained in:
parent
4788dd19c9
commit
c3bec364d3
|
@ -720,12 +720,14 @@ macro_rules! impl_csc_col_common_methods {
|
|||
self.lane.get_entry(global_row_index)
|
||||
}
|
||||
|
||||
/// Iterator over the row indices and elements of a column of a CSC matrix.
|
||||
/// Iterator over `(row_idx, value)`, the row indices and elements of a column of a CSC matrix.
|
||||
/// Equivalent to `col.row_indices().iter().zip(col.values().iter())`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn iter(&self) -> CsInnerIter<'_, T> {
|
||||
self.lane.iter()
|
||||
pub fn iter(&self) -> CscInnerIter<'_, T> {
|
||||
CscInnerIter {
|
||||
inner_iter: self.lane.iter(),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -755,12 +757,14 @@ impl<'a, T> CscColMut<'a, T> {
|
|||
self.lane.get_entry_mut(global_row_index)
|
||||
}
|
||||
|
||||
/// Iterator over the row indices and mutable elements of a column of a CSC matrix.
|
||||
/// Iterator over `(row_idx, mut_value)`, the row indices and mutable elements of a column of a CSC matrix.
|
||||
/// Equivalent to `col.row_indices().iter().zip(col.values_mut().iter_mut())`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn iter_mut(&mut self) -> CsInnerIterMut<'_, T> {
|
||||
self.lane.iter_mut()
|
||||
pub fn iter_mut(&mut self) -> CscInnerIterMut<'_, T> {
|
||||
CscInnerIterMut {
|
||||
inner_iter: self.lane.iter_mut(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,3 +796,35 @@ where
|
|||
self.lane_iter.next().map(|lane| CscColMut { lane })
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator for [CscCol](struct.CscCol.html).
|
||||
pub struct CscInnerIter<'a, T> {
|
||||
inner_iter: CsInnerIter<'a, T>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for CscInnerIter<'a, T>
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Item = (usize, &'a T);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner_iter.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// Mutable iterator for [CscCol](struct.CscCol.html).
|
||||
pub struct CscInnerIterMut<'a, T> {
|
||||
inner_iter: CsInnerIterMut<'a, T>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for CscInnerIterMut<'a, T>
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Item = (usize, &'a mut T);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner_iter.next()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -722,12 +722,14 @@ macro_rules! impl_csr_row_common_methods {
|
|||
self.lane.get_entry(global_col_index)
|
||||
}
|
||||
|
||||
/// Iterator over the column indices and elements of a row of a CSR matrix.
|
||||
/// Iterator over `(col_idx, value)`, the column indices and elements of a row of a CSR matrix.
|
||||
/// Equivalent to `row.col_indices().iter().zip(row.values().iter())`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn iter(&self) -> CsInnerIter<'_, T> {
|
||||
self.lane.iter()
|
||||
pub fn iter(&self) -> CsrInnerIter<'_, T> {
|
||||
CsrInnerIter {
|
||||
inner_iter: self.lane.iter(),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -760,12 +762,14 @@ impl<'a, T> CsrRowMut<'a, T> {
|
|||
self.lane.get_entry_mut(global_col_index)
|
||||
}
|
||||
|
||||
/// Iterator over the column indices and mutable elements of a row of a CSR matrix.
|
||||
/// Iterator over `(col_idx, mut_value)`, the column indices and mutable elements of a row of a CSR matrix.
|
||||
/// Equivalent to `row.col_indices().iter().zip(row.values_mut().iter_mut())`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn iter_mut(&mut self) -> CsInnerIterMut<'_, T> {
|
||||
self.lane.iter_mut()
|
||||
pub fn iter_mut(&mut self) -> CsrInnerIterMut<'_, T> {
|
||||
CsrInnerIterMut {
|
||||
inner_iter: self.lane.iter_mut(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -797,3 +801,35 @@ where
|
|||
self.lane_iter.next().map(|lane| CsrRowMut { lane })
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator for [CsrRow](struct.CsrRow.html).
|
||||
pub struct CsrInnerIter<'a, T> {
|
||||
inner_iter: CsInnerIter<'a, T>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for CsrInnerIter<'a, T>
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Item = (usize, &'a T);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner_iter.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// Mutable iterator for [CsrRowMut](struct.CsrRowMut.html).
|
||||
pub struct CsrInnerIterMut<'a, T> {
|
||||
inner_iter: CsInnerIterMut<'a, T>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for CsrInnerIterMut<'a, T>
|
||||
where
|
||||
T: 'a,
|
||||
{
|
||||
type Item = (usize, &'a mut T);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner_iter.next()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue