Struct indexical::IndexMatrix
source · pub struct IndexMatrix<R, C: IndexedValue, S: BitSet, P: PointerFamily> { /* private fields */ }
Expand description
An unordered collections of pairs (R, C)
, implemented with a sparse bit-matrix.
“Sparse” means “hash map from rows to bit-sets of columns”. Subsequently, only column types C
must be indexed,
while row types R
only need be hashable.
Implementations§
source§impl<R, C, S, P> IndexMatrix<R, C, S, P>
impl<R, C, S, P> IndexMatrix<R, C, S, P>
sourcepub fn new(col_domain: &P::Pointer<IndexedDomain<C>>) -> Self
pub fn new(col_domain: &P::Pointer<IndexedDomain<C>>) -> Self
Creates an empty matrix.
sourcepub fn insert<M>(&mut self, row: R, col: impl ToIndex<C, M>) -> bool
pub fn insert<M>(&mut self, row: R, col: impl ToIndex<C, M>) -> bool
Inserts a pair (row, col)
into the matrix, returning true if self
changed.
sourcepub fn union_into_row(&mut self, into: R, from: &IndexSet<C, S, P>) -> bool
pub fn union_into_row(&mut self, into: R, from: &IndexSet<C, S, P>) -> bool
Adds all elements of from
into the row into
.
sourcepub fn union_rows(&mut self, from: R, to: R) -> bool
pub fn union_rows(&mut self, from: R, to: R) -> bool
Adds all elements from the row from
into the row into
.
sourcepub fn row(&self, row: &R) -> impl Iterator<Item = &C> + '_
pub fn row(&self, row: &R) -> impl Iterator<Item = &C> + '_
Returns an iterator over the elements in row
.
sourcepub fn rows(&self) -> impl Iterator<Item = (&R, &IndexSet<C, S, P>)> + '_
pub fn rows(&self) -> impl Iterator<Item = (&R, &IndexSet<C, S, P>)> + '_
Returns an iterator over all rows in the matrix.
sourcepub fn row_set(&self, row: &R) -> &IndexSet<C, S, P>
pub fn row_set(&self, row: &R) -> &IndexSet<C, S, P>
Returns the IndexSet
for a particular row
.
sourcepub fn col_domain(&self) -> &P::Pointer<IndexedDomain<C>>
pub fn col_domain(&self) -> &P::Pointer<IndexedDomain<C>>
Returns the IndexedDomain
for the column type.
Trait Implementations§
source§impl<R, C, S, P> Clone for IndexMatrix<R, C, S, P>
impl<R, C, S, P> Clone for IndexMatrix<R, C, S, P>
source§impl<R, C, S, P> Debug for IndexMatrix<R, C, S, P>where
R: PartialEq + Eq + Hash + Clone + Debug,
C: IndexedValue + Debug,
S: BitSet,
P: PointerFamily,
impl<R, C, S, P> Debug for IndexMatrix<R, C, S, P>where
R: PartialEq + Eq + Hash + Clone + Debug,
C: IndexedValue + Debug,
S: BitSet,
P: PointerFamily,
source§impl<R, C, S, P> JoinSemiLattice for IndexMatrix<R, C, S, P>
impl<R, C, S, P> JoinSemiLattice for IndexMatrix<R, C, S, P>
source§impl<R, C, S, P> PartialEq for IndexMatrix<R, C, S, P>
impl<R, C, S, P> PartialEq for IndexMatrix<R, C, S, P>
impl<R, C, S, P> Eq for IndexMatrix<R, C, S, P>
Auto Trait Implementations§
impl<R, C, S, P> RefUnwindSafe for IndexMatrix<R, C, S, P>where
R: RefUnwindSafe,
S: RefUnwindSafe,
<P as PointerFamily>::Pointer<IndexedDomain<C>>: RefUnwindSafe,
impl<R, C, S, P> Send for IndexMatrix<R, C, S, P>
impl<R, C, S, P> Sync for IndexMatrix<R, C, S, P>
impl<R, C, S, P> Unpin for IndexMatrix<R, C, S, P>
impl<R, C, S, P> UnwindSafe for IndexMatrix<R, C, S, P>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more