Regina Calculation Engine
|
A small but extremely fast "base 4 bitmask" class that can store up to 8 * sizeof(T) "qits", each equal to 0, 1, 2 or 3. More...
#include <utilities/nqitmask.h>
Public Member Functions | |
NQitmask1 () | |
Creates a new qitmask with all qits set to 0. More... | |
NQitmask1 (const NQitmask1< T > &cloneMe) | |
Creates a clone of the given qitmask. More... | |
void | reset () |
Sets all qits of this qitmask to 0. More... | |
NQitmask1< T > & | operator= (const NQitmask1< T > &other) |
Sets this qitmask to a copy of the given qitmask. More... | |
char | get (unsigned index) const |
Returns the value of the given qit in this qitmask. More... | |
void | set (unsigned index, char value) |
Sets the given qit of this qitmask to the given value. More... | |
bool | empty () const |
Determines whether this qitmask contains all zeroes. More... | |
bool | nonEmpty () const |
Determines whether this qitmask contains at least one non-zero qit. More... | |
bool | has3 () const |
Determines whether this qitmask contains at least one qit with value 3. More... | |
NQitmask1< T > & | operator+= (const NQitmask1< T > &rhs) |
Sets this to the sum of this and the given qitmask. More... | |
NQitmask1< T > & | operator-= (const NQitmask1< T > &rhs) |
Sets this to the difference of this and the given qitmask. More... | |
bool | operator== (const NQitmask1< T > &other) const |
Determines whether this and the given qitmask are identical. More... | |
bool | hasNonZeroMatch (const NQitmask1< T > &other) const |
Determines whether there is some index at which both this and the given qitmask both have non-zero qits. More... | |
Friends | |
template<typename X > | |
std::ostream & | operator<< (std::ostream &out, const NQitmask1< X > &mask) |
A small but extremely fast "base 4 bitmask" class that can store up to 8 * sizeof(T) "qits", each equal to 0, 1, 2 or 3.
This qitmask packs all of the qits together into two variables of type T. This means that operations on qitmasks are extremely fast, because all of the qits can be processed in just a few native CPU operations.
The downside of course is that the number of qits that can be stored is limited to 8 * sizeof(T), where T must be a native unsigned integer type (such as unsigned char, unsigned int, or unsigned long long).
For another extremely fast qitmask class that can store twice as many qits, see NQitmask2. At present there is no qitmask class in Regina that can store arbitrarily many qits.
|
inline |
Creates a new qitmask with all qits set to 0.
|
inline |
Creates a clone of the given qitmask.
cloneMe | the qitmask to clone. |
|
inline |
Determines whether this qitmask contains all zeroes.
true
if every qit is zero, or false
otherwise.
|
inline |
Returns the value of the given qit in this qitmask.
index | indicates which qit to query; this must be between 0 and (8 * sizeof(T) - 1) inclusive. |
|
inline |
Determines whether this qitmask contains at least one qit with value 3.
true
if at least one qit is 3, or false
otherwise.
|
inline |
Determines whether there is some index at which both this and the given qitmask both have non-zero qits.
That is, there is some index i for which get(i)
and other.get(i)
are both non-zero.
Note that these two qits do not need to be equal; they just both need to be non-zero. Note also that this only needs to happen at one index; there may be other indices at which the qit is zero in one qitmask but not the other.
other | the qitmask to compare with this. |
true
if there is some index at which this and other both have non-zero qits, or false
otherwise.
|
inline |
Determines whether this qitmask contains at least one non-zero qit.
true
if at least one qit is non-zero, or false
otherwise.
|
inline |
Sets this to the sum of this and the given qitmask.
Each pair of qits is added modulo 4 (so, for instance, 2 + 3 = 1).
rhs | the qitmask to add to this. |
|
inline |
Sets this to the difference of this and the given qitmask.
Each pair of qits is subtracted modulo 4 (so, for instance, 1 - 3 = 2).
rhs | the qitmask to subtract from this. |
|
inline |
Sets this qitmask to a copy of the given qitmask.
other | the qitmask to clone. |
|
inline |
Determines whether this and the given qitmask are identical.
other | the qitmask to compare against this. |
true
if and only if this and the given qitmask are identical.
|
inline |
Sets all qits of this qitmask to 0.
|
inline |
Sets the given qit of this qitmask to the given value.
index | indicates which qit to set; this must be between 0 and (8 * sizeof(T) - 1) inclusive. |
value | the value that will be assigned to the (index)th qit; this must be 0, 1, 2 or 3. |