pub struct IndexMatrix<'a, R, C: IndexedValue + 'a, S: BitSet, P: PointerFamily<'a>> { /* 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<'a, R, C, S, P> IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> IndexMatrix<'a, 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<'a, C, S, P>) -> bool
pub fn union_into_row(&mut self, into: R, from: &IndexSet<'a, 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 ExactSizeIterator<Item = (&R, &IndexSet<'a, C, S, P>)>
pub fn rows( &self, ) -> impl ExactSizeIterator<Item = (&R, &IndexSet<'a, C, S, P>)>
Returns an iterator over all rows in the matrix.
Sourcepub fn row_set(&self, row: &R) -> &IndexSet<'a, C, S, P>
pub fn row_set(&self, row: &R) -> &IndexSet<'a, 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.
Source§impl<'a, R, C, S, P> IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> IndexMatrix<'a, R, C, S, P>
Sourcepub fn transpose<T, M>(
&self,
row_domain: &P::Pointer<IndexedDomain<T>>,
) -> IndexMatrix<'a, C::Index, T, S, P>where
T: IndexedValue + 'a,
R: ToIndex<T, M>,
pub fn transpose<T, M>(
&self,
row_domain: &P::Pointer<IndexedDomain<T>>,
) -> IndexMatrix<'a, C::Index, T, S, P>where
T: IndexedValue + 'a,
R: ToIndex<T, M>,
Transposes the matrix, assuming the row type is also indexed.
Trait Implementations§
Source§impl<'a, R, C, S, P> Clone for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> Clone for IndexMatrix<'a, R, C, S, P>
Source§impl<'a, R, C, S, P> Debug for IndexMatrix<'a, R, C, S, P>where
R: PartialEq + Eq + Hash + Clone + Debug,
C: IndexedValue + Debug + 'a,
S: BitSet,
P: PointerFamily<'a>,
impl<'a, R, C, S, P> Debug for IndexMatrix<'a, R, C, S, P>where
R: PartialEq + Eq + Hash + Clone + Debug,
C: IndexedValue + Debug + 'a,
S: BitSet,
P: PointerFamily<'a>,
Source§impl<'a, R, C, S, P> JoinSemiLattice for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> JoinSemiLattice for IndexMatrix<'a, R, C, S, P>
Source§impl<'a, R, C, S, P> PartialEq for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> PartialEq for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> Eq for IndexMatrix<'a, R, C, S, P>
Auto Trait Implementations§
impl<'a, R, C, S, P> Freeze for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> RefUnwindSafe for IndexMatrix<'a, R, C, S, P>where
<P as PointerFamily<'a>>::Pointer<IndexedDomain<C>>: RefUnwindSafe,
S: RefUnwindSafe,
R: RefUnwindSafe,
impl<'a, R, C, S, P> Send for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> Sync for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> Unpin for IndexMatrix<'a, R, C, S, P>
impl<'a, R, C, S, P> UnwindSafe for IndexMatrix<'a, R, C, S, P>where
<P as PointerFamily<'a>>::Pointer<IndexedDomain<C>>: UnwindSafe,
R: UnwindSafe,
S: UnwindSafe,
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