This class defines a set of bit fields of the same length which are to be stored in a contiguous piece of memory to avoid multiple memory allocation/deallocation. More...
#include <bitfield.h>
Public Member Functions | |
SetOfBitFields (int_t len, int_t maxelem) | |
The constructor of a set of a fixed maximal number of bit fields, each of the same length. | |
~SetOfBitFields () | |
The destructor. | |
int | add (const BitField &b, int value) |
Adds a bit field to the set. | |
int | check (const BitField &b) const |
Returns the value of the given bit field value or return -1 if the bit field is not in the set. | |
int | used (void) const |
Returns the number of bit fields contained in the set. | |
void | forget () |
Forgets all the bit fields and deallocates the memory. | |
Private Attributes | |
int | avail |
The number of bit fields that still can be stored. | |
int | usedcount |
The number of bit fields used. | |
int_t | size |
The actual size of the table. | |
int_t | length |
The length of bit fields. | |
BitField * | bf |
The table of bit fields. | |
BitField | values |
The values of bit fields. | |
unsigned char * | buf |
The memory buffer used for bit fields. | |
unsigned char * | bufcur |
The current position in the buffer. |
This class defines a set of bit fields of the same length which are to be stored in a contiguous piece of memory to avoid multiple memory allocation/deallocation.
Each bit field in the set is assigned a value 1 or 0. Hashing is used for quick retrieval of the values of bit fields.
Definition at line 243 of file bitfield.h.
The constructor of a set of a fixed maximal number of bit fields, each of the same length.
The set is initially empty.
chomp::homology::SetOfBitFields::~SetOfBitFields | ( | ) | [inline] |
int chomp::homology::SetOfBitFields::add | ( | const BitField & | b, | |
int | value | |||
) |
Adds a bit field to the set.
If it already was there then returns its value. If there is no room available for the bit field then returns -1. Otherwise returns 2.
int chomp::homology::SetOfBitFields::check | ( | const BitField & | b | ) | const |
Returns the value of the given bit field value or return -1 if the bit field is not in the set.
void chomp::homology::SetOfBitFields::forget | ( | void | ) | [inline] |
Forgets all the bit fields and deallocates the memory.
Definition at line 313 of file bitfield.h.
int chomp::homology::SetOfBitFields::used | ( | void | ) | const [inline] |
Returns the number of bit fields contained in the set.
Definition at line 308 of file bitfield.h.
References usedcount.
{ return usedcount; } /* SetOfBitFields::used */
int chomp::homology::SetOfBitFields::avail [private] |
The number of bit fields that still can be stored.
Definition at line 270 of file bitfield.h.
Referenced by forget().
BitField* chomp::homology::SetOfBitFields::bf [private] |
The table of bit fields.
Definition at line 282 of file bitfield.h.
Referenced by forget(), and ~SetOfBitFields().
unsigned char* chomp::homology::SetOfBitFields::buf [private] |
The memory buffer used for bit fields.
Definition at line 288 of file bitfield.h.
Referenced by forget(), and ~SetOfBitFields().
unsigned char* chomp::homology::SetOfBitFields::bufcur [private] |
The current position in the buffer.
Definition at line 291 of file bitfield.h.
int_t chomp::homology::SetOfBitFields::length [private] |
The length of bit fields.
Definition at line 279 of file bitfield.h.
Referenced by forget(), and ~SetOfBitFields().
int_t chomp::homology::SetOfBitFields::size [private] |
int chomp::homology::SetOfBitFields::usedcount [private] |
The values of bit fields.
Definition at line 285 of file bitfield.h.
Referenced by forget(), and ~SetOfBitFields().