pub struct SparseBitMatrix<R, C>where
    R: Idx,
    C: Idx,
{ num_columns: usize, rows: IndexVec<R, Option<HybridBitSet<C>>>, }
Expand description

A fixed-column-size, variable-row-size 2D bit matrix with a moderately sparse representation.

Initially, every row has no explicit representation. If any bit within a row is set, the entire row is instantiated as Some(<HybridBitSet>). Furthermore, any previously uninstantiated rows prior to it will be instantiated as None. Those prior rows may themselves become fully instantiated later on if any of their bits are set.

R and C are index types used to identify rows and columns respectively; typically newtyped usize wrappers, but they can also just be usize.

Fields§

§num_columns: usize§rows: IndexVec<R, Option<HybridBitSet<C>>>

Implementations§

Creates a new empty sparse bit matrix with no rows or columns.

Sets the cell at (row, column) to true. Put another way, insert column to the bitset for row.

Returns true if this changed the matrix.

Sets the cell at (row, column) to false. Put another way, delete column from the bitset for row. Has no effect if row does not exist.

Returns true if this changed the matrix.

Sets all columns at row to false. Has no effect if row does not exist.

Do the bits from row contain column? Put another way, is the matrix cell at (row, column) true? Put yet another way, if the matrix represents (transitive) reachability, can row reach column?

Adds the bits from row read to the bits from row write, and returns true if anything changed.

This is used when computing transitive reachability because if you have an edge write -> read, because in that case write can reach everything that read can (and potentially more).

Insert all bits in the given row.

Iterates through all the columns set to true in a given row of the matrix.

Intersects row with set. set can be either BitSet or HybridBitSet. Has no effect if row does not exist.

Returns true if the row was changed.

Subtracts set from row. setcan be eitherBitSetorHybridBitSet. Has no effect if row` does not exist.

Returns true if the row was changed.

Unions row with set. set can be either BitSet or HybridBitSet.

Returns true if the row was changed.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes