pub struct BitMatrix<R: Idx, C: Idx> {
    num_rows: usize,
    num_columns: usize,
    words: Vec<u64>,
    marker: PhantomData<(R, C)>,
}
Expand description

A fixed-size 2D bit matrix type with a dense representation.

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

All operations that involve a row and/or column index will panic if the index exceeds the relevant bound.

Fields

num_rows: usizenum_columns: usizewords: Vec<u64>marker: PhantomData<(R, C)>

Implementations

Creates a new rows x columns matrix, initially empty.

Creates a new matrix, with row used as the value for every row.

The range of bits for a given row.

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.

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?

Returns those indices that are true in rows a and b. This is an O(n) operation where n is the number of elements (somewhat independent from the actual size of the intersection, in particular).

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).

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

Sets every cell in row to true.

Gets a slice of the underlying words.

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

Returns the number of elements in row.

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
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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: 40 bytes