regina::Bitmask2< T, U > Class Template Reference
Miscellaneous Utilities

A small but extremely fast bitmask class that can store up to 8 * sizeof(T) + 8 * sizeof(U) true-or-false bits. More...

`#include <utilities/bitmask.h>`

## Public Member Functions

| Bitmask2 ()
| Creates a new bitmask with all bits set to `false`. More...
| Bitmask2 (size_t)
| Creates a new bitmask with all bits set to `false`. More...
| Bitmask2 (const Bitmask2< T, U > &cloneMe)
| Creates a clone of the given bitmask. More...
void | reset ()
| Sets all bits of this bitmask to `false`. More...
void | reset (size_t)
| Sets all bits of this bitmask to `false`. More...
Bitmask2< T, U > & | operator= (const Bitmask2< T, U > &other)
| Sets this bitmask to a copy of the given bitmask. More...
void | truncate (size_t numBits)
| Leaves the first numBits bits of this bitmask intact, but sets all subsequent bits to `false`. More...
bool | get (size_t index) const
| Returns the value of the given bit of this bitmask. More...
void | set (size_t index, bool value)
| Sets the given bit of this bitmask to the given value. More...
template<typename ForwardIterator >
void | set (ForwardIterator indexBegin, ForwardIterator indexEnd, bool value)
| Sets all bits in the given sorted list to the given value. More...
Bitmask2< T, U > & | operator&= (const Bitmask2< T, U > &other)
| Sets this to the intersection of this and the given bitmask. More...
Bitmask2< T, U > & | operator|= (const Bitmask2< T, U > &other)
| Sets this to the union of this and the given bitmask. More...
Bitmask2< T, U > & | operator^= (const Bitmask2< T, U > &other)
| Sets this to the exclusive disjunction (XOR) of this and the given bitmask. More...
Bitmask2< T, U > & | operator-= (const Bitmask2< T, U > &other)
| Sets this to the set difference of this and the given bitmask. More...
void | flip ()
| Negates every bit in this bitmask. More...
bool | operator== (const Bitmask2< T, U > &other) const
| Determines whether this and the given bitmask are identical. More...
bool | lessThan (const Bitmask2< T, U > &other) const
| Determines whether this bitmask appears strictly before the given bitmask when bitmasks are sorted in lexicographical order. More...
bool | operator<= (const Bitmask2< T, U > &other) const
| Determines whether this bitmask is entirely contained within the given bitmask. More...
bool | inUnion (const Bitmask2< T, U > &x, const Bitmask2< T, U > &y) const
| Determines whether this bitmask is entirely contained within the union of the two given bitmasks. More...
bool | containsIntn (const Bitmask2< T, U > &x, const Bitmask2< T, U > &y) const
| Determines whether this bitmask contains the intersection of the two given bitmasks. More...
size_t | bits () const
| Returns the number of bits currently set to `true` in this bitmask. More...
long | firstBit () const
| Returns the index of the first `true` bit in this bitmask, or -1 if there are no `true` bits. More...
long | lastBit () const
| Returns the index of the last `true` bit in this bitmask, or -1 if there are no `true` bits. More...
bool | atMostOneBit () const
| Determines whether at most one bit is set to `true` in this bitmask. More...

## Friends

std::ostream & | operator (std::ostream &out, const Bitmask2< T, U > &mask)

## Detailed Description

### template<typename T, typename U = T>
class regina::Bitmask2< T, U >

A small but extremely fast bitmask class that can store up to 8 * sizeof(T) + 8 * sizeof(U) true-or-false bits.

This bitmask packs all of the bits together into a single variable of type T and a single variable of type U. This means that operations on entire bitmasks are extremely fast, because all of the bits can be processed in just two "native" operations.

The downside of course is that the number of bits that can be stored is limited to 8 * sizeof(T) + 8 * sizeof(U), where T and U must be native unsigned integer types (such as unsigned char, unsigned int, or unsigned long long).

For an even faster bitmask class that can only store half as many bits, see Bitmask1. For a bitmask class that can store arbitrarily many bits, see Bitmask.

Precondition
  Types T and U are unsigned integral numeric types.

Python:\n Not present.

The documentation for this class was generated from the following file:

- utilities/bitmask.h

Copyright © 1999-2016, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).