mod builder_impl;
mod iterator;
use iterator::EntriesIterator;
pub struct CsrMatrix<T> {
pub m: usize, pub n: usize, offsets: Vec<usize>, entries: Vec<(usize, T)>,
}
impl<T> CsrMatrix<T> {
pub fn entries_iter(&self) -> impl Iterator<Item = (usize, &(usize, T))> {
EntriesIterator::<T>::new(&self)
}
pub fn row_iter(&self, row: usize) -> impl Iterator<Item = &(usize, T)> {
self.entries
.iter()
.skip(self.offsets[row])
.take(self.offsets[row + 1] - self.offsets[row])
}
}
pub struct CsrMatrixBuilder<T> {
m: usize, n: usize, entries: Vec<(usize, usize, T)>,
}