OpenASIP
2.0
|
#include <BitMatrix.hh>
Public Member Functions | |
BitMatrix (int width, int height, bool initialValue) | |
BitMatrix (const BitMatrix &another) | |
virtual | ~BitMatrix () |
bool | bitAt (int column, int row) const |
void | setBit (int column, int row, bool value) |
void | setAllToZero () |
void | setAllToOne () |
void | shiftLeft () |
void | orWith (const BitMatrix &another) |
bool | conflictsWith (const BitMatrix &another) const |
int | rowCount () const |
int | columnCount () const |
std::string | toString () const |
std::string | toDotString () const |
bool | operator== (const BitMatrix &other) const |
bool | operator< (const BitMatrix &rightHand) const |
Private Types | |
typedef unsigned | RowWord |
Private Attributes | |
RowWord * | matrix_ |
const int | rows_ |
const int | columns_ |
const int | wordsPerRow_ |
Models a bit matrix.
The implementation should be quite efficient. It uses natural words of the machine to store the bits to provide fast logical operations on larger bit chunks at the same time. Especially functions such as fully ORing and ANDing two bit matrices should be quite efficient. Checking a single matrix element is couple of cycles slower than the naive implementation of storing one bit per word. The main methods are inline non-virtual methods for fastest possible access.
Definition at line 49 of file BitMatrix.hh.
|
private |
Definition at line 73 of file BitMatrix.hh.
BitMatrix::BitMatrix | ( | int | width, |
int | height, | ||
bool | initialValue | ||
) |
Builds a bit matrix of given size and default content.
width | The width of the matrix. |
height | The height of the matrix. |
initialValue | The initial value for elements. |
Definition at line 46 of file BitMatrix.cc.
References matrix_, rows_, and wordsPerRow_.
BitMatrix::BitMatrix | ( | const BitMatrix & | another | ) |
Copy constructor.
Definition at line 75 of file BitMatrix.cc.
References matrix_, rows_, and wordsPerRow_.
|
virtual |
Frees the bit matrix content storage.
Definition at line 67 of file BitMatrix.cc.
References matrix_.
bool BitMatrix::bitAt | ( | int | column, |
int | row | ||
) | const |
Referenced by CollisionMatrix::isCollision(), operator<(), operator==(), toDotString(), and toString().
int BitMatrix::columnCount | ( | ) | const |
bool BitMatrix::conflictsWith | ( | const BitMatrix & | another | ) | const |
bool BitMatrix::operator< | ( | const BitMatrix & | rightHand | ) | const |
Returns true in case the given matrix is "smaller" than this one.
The one that has the first non-equal non-zero matrix element is considered larger. That is, the matrix is considered as a bit string. This is an arbitrary ordering constraint to make it possible to store BitMatrices in sets.
rightHand | The right hand side of the comparison. |
Definition at line 192 of file BitMatrix.cc.
References bitAt(), columns_, and rows_.
bool BitMatrix::operator== | ( | const BitMatrix & | other | ) | const |
Compares two bit matrices..
other | The RT to compare to. |
Definition at line 143 of file BitMatrix.cc.
References bitAt(), columns_, and rows_.
void BitMatrix::orWith | ( | const BitMatrix & | another | ) |
Referenced by FUFiniteStateAutomaton::resolveState().
int BitMatrix::rowCount | ( | ) | const |
Referenced by CollisionMatrix::CollisionMatrix(), and FUCollisionMatrixIndex::FUCollisionMatrixIndex().
void BitMatrix::setAllToOne | ( | ) |
Sets all bits to one.
Definition at line 106 of file BitMatrix.cc.
References matrix_, rows_, and wordsPerRow_.
void BitMatrix::setAllToZero | ( | ) |
Sets all bits to zero.
Definition at line 93 of file BitMatrix.cc.
References matrix_, rows_, and wordsPerRow_.
Referenced by DCMFUResourceConflictDetector::reset(), and ReservationTableFUResourceConflictDetector::reset().
void BitMatrix::setBit | ( | int | column, |
int | row, | ||
bool | value | ||
) |
Referenced by CollisionMatrix::CollisionMatrix(), and ReservationTable::ReservationTable().
void BitMatrix::shiftLeft | ( | ) |
Referenced by FUFiniteStateAutomaton::resolveState().
std::string BitMatrix::toDotString | ( | ) | const |
Returns a textual description of the matrix suitable to be used as a dot edge/node label.
Definition at line 164 of file BitMatrix.cc.
References bitAt(), columns_, and rows_.
std::string BitMatrix::toString | ( | ) | const |
ASCII representation of the bit matrix.
For debugging and testing.
Definition at line 124 of file BitMatrix.cc.
References bitAt(), columns_, and rows_.
|
private |
Definition at line 79 of file BitMatrix.hh.
Referenced by operator<(), operator==(), toDotString(), and toString().
|
private |
Definition at line 75 of file BitMatrix.hh.
Referenced by BitMatrix(), setAllToOne(), setAllToZero(), and ~BitMatrix().
|
private |
Definition at line 77 of file BitMatrix.hh.
Referenced by BitMatrix(), operator<(), operator==(), setAllToOne(), setAllToZero(), toDotString(), and toString().
|
private |
Definition at line 81 of file BitMatrix.hh.
Referenced by BitMatrix(), setAllToOne(), and setAllToZero().