The Original CHomP Software
Public Member Functions | Private Attributes | List of all members
chomp::homology::SetOfBitFields Class Reference

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. More...
 
 ~SetOfBitFields ()
 The destructor. More...
 
int add (const BitField &b, int value)
 Adds a bit field to the set. More...
 
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. More...
 
int used (void) const
 Returns the number of bit fields contained in the set. More...
 
void forget ()
 Forgets all the bit fields and deallocates the memory. More...
 

Private Attributes

int avail
 The number of bit fields that still can be stored. More...
 
int usedcount
 The number of bit fields used. More...
 
int_t size
 The actual size of the table. More...
 
int_t length
 The length of bit fields. More...
 
BitFieldbf
 The table of bit fields. More...
 
BitField values
 The values of bit fields. More...
 
unsigned char * buf
 The memory buffer used for bit fields. More...
 
unsigned char * bufcur
 The current position in the buffer. More...
 

Detailed Description

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 244 of file bitfield.h.

Constructor & Destructor Documentation

◆ SetOfBitFields()

chomp::homology::SetOfBitFields::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.

The set is initially empty.

◆ ~SetOfBitFields()

chomp::homology::SetOfBitFields::~SetOfBitFields ( )
inline

The destructor.

Definition at line 298 of file bitfield.h.

299{
300 if (bf)
301 delete [] bf;
302 if (buf)
303 delete [] buf;
304 if (length)
305 values. free ();
306 return;
307} /* SetOfBitFields::~SetOfBitFields */
int_t length
The length of bit fields.
Definition: bitfield.h:280
BitField * bf
The table of bit fields.
Definition: bitfield.h:283
unsigned char * buf
The memory buffer used for bit fields.
Definition: bitfield.h:289
BitField values
The values of bit fields.
Definition: bitfield.h:286

References bf, buf, length, and values.

Member Function Documentation

◆ add()

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.

◆ check()

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.

◆ forget()

void chomp::homology::SetOfBitFields::forget ( void  )
inline

Forgets all the bit fields and deallocates the memory.

Definition at line 314 of file bitfield.h.

315{
316 if (bf)
317 delete [] bf;
318 bf = NULL;
319 if (buf)
320 delete [] buf;
321 buf = NULL;
322 if (length)
323 values. free ();
324 length = 0;
325 size = 0;
326 avail = 0;
327 return;
328} /* SetOfBitFields::forget */
int avail
The number of bit fields that still can be stored.
Definition: bitfield.h:271
int_t size
The actual size of the table.
Definition: bitfield.h:277

References avail, bf, buf, length, size, and values.

◆ used()

int chomp::homology::SetOfBitFields::used ( void  ) const
inline

Returns the number of bit fields contained in the set.

Definition at line 309 of file bitfield.h.

310{
311 return usedcount;
312} /* SetOfBitFields::used */
int usedcount
The number of bit fields used.
Definition: bitfield.h:274

References usedcount.

Member Data Documentation

◆ avail

int chomp::homology::SetOfBitFields::avail
private

The number of bit fields that still can be stored.

Definition at line 271 of file bitfield.h.

Referenced by forget().

◆ bf

BitField* chomp::homology::SetOfBitFields::bf
private

The table of bit fields.

Definition at line 283 of file bitfield.h.

Referenced by forget(), and ~SetOfBitFields().

◆ buf

unsigned char* chomp::homology::SetOfBitFields::buf
private

The memory buffer used for bit fields.

Definition at line 289 of file bitfield.h.

Referenced by forget(), and ~SetOfBitFields().

◆ bufcur

unsigned char* chomp::homology::SetOfBitFields::bufcur
private

The current position in the buffer.

Definition at line 292 of file bitfield.h.

◆ length

int_t chomp::homology::SetOfBitFields::length
private

The length of bit fields.

Definition at line 280 of file bitfield.h.

Referenced by forget(), and ~SetOfBitFields().

◆ size

int_t chomp::homology::SetOfBitFields::size
private

The actual size of the table.

Definition at line 277 of file bitfield.h.

Referenced by forget().

◆ usedcount

int chomp::homology::SetOfBitFields::usedcount
private

The number of bit fields used.

Definition at line 274 of file bitfield.h.

Referenced by used().

◆ values

BitField chomp::homology::SetOfBitFields::values
private

The values of bit fields.

Definition at line 286 of file bitfield.h.

Referenced by forget(), and ~SetOfBitFields().


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