The Original CHomP Software
|
This class uses bit representation to store many small sets. More...
#include <bitsets.h>
Public Member Functions | |
BitSets (int_t _nsets, int_t _nelem) | |
Constructor of a family of empty sets. More... | |
BitSets (const BitSets &s) | |
Copy constructor. More... | |
BitSets & | operator= (const BitSets &s) |
Assignment operator. More... | |
~BitSets () | |
Destructor. More... | |
void | add (int_t n, int_t e) |
Adds an element to the given set. More... | |
void | remove (int_t n, int_t e) |
Removes an element from the given set. More... | |
bool | check (int_t n, int_t e) const |
Checks if an element belongs to the given set. More... | |
void | addset (int_t n, int_t m) |
Adds the entire set 'm' to the set 'n'. More... | |
int_t | get (int_t n, int_t start=0) const |
Retrieves an element >= 'start' in the given set. More... | |
Private Member Functions | |
int_t | arraySize () |
Computes the size of the memory array for storing the bits. More... | |
Private Attributes | |
int_t | nsets |
The number of sets. More... | |
int_t | nelem |
The maximal number of elements in each set. More... | |
int_t | nunits |
The number of array entries used for each set. More... | |
unsigned long * | bits |
The memory buffer for storing the bits. More... | |
Static Private Attributes | |
static const int_t | longBits = sizeof (long) * 8 |
static const int_t | longBitMask = longBits - 1 |
static const int_t | longBitShift = (sizeof (long) == 8) ? 6 : 5 |
This class uses bit representation to store many small sets.
Each of the sets can contain integer numbers from 0 to the limit specified in the constructor. The number of sets must also be given in the constructor. A contiguous chunk of memory is used to store the bits that represent the sets. This class is not fool-proof, so use it carefully. Minimal interface, sorry.
Constructor of a family of empty sets.
The number of the sets and the maximal number of elements in each set must be provided at initialization. Both numbers must be positive.
Definition at line 123 of file bitsets.h.
References arraySize(), and bits.
|
inline |
Copy constructor.
Definition at line 135 of file bitsets.h.
References arraySize(), and bits.
|
inline |
Adds an element to the given set.
Definition at line 166 of file bitsets.h.
References bits, longBitMask, longBitShift, and nunits.
|
inlineprivate |
Computes the size of the memory array for storing the bits.
Definition at line 115 of file bitsets.h.
Referenced by BitSets(), and operator=().
Checks if an element belongs to the given set.
Definition at line 181 of file bitsets.h.
References bits, longBitMask, longBitShift, and nunits.
Retrieves an element >= 'start' in the given set.
Returns -1 if none.
Definition at line 196 of file bitsets.h.
References bits, longBitMask, longBits, longBitShift, nelem, and nunits.
Removes an element from the given set.
Definition at line 174 of file bitsets.h.
References bits, longBitMask, longBitShift, and nunits.
|
private |
The memory buffer for storing the bits.
Definition at line 106 of file bitsets.h.
Referenced by add(), addset(), BitSets(), check(), get(), operator=(), remove(), and ~BitSets().
|
staticprivate |
|
staticprivate |
|
private |
The maximal number of elements in each set.
Definition at line 100 of file bitsets.h.
Referenced by get(), and operator=().
|
private |
The number of sets.
Definition at line 97 of file bitsets.h.
Referenced by arraySize(), and operator=().
|
private |
The number of array entries used for each set.
Definition at line 103 of file bitsets.h.
Referenced by add(), addset(), arraySize(), check(), get(), operator=(), and remove().