Public Member Functions | Private Attributes

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 <chomp/struct/bitfield.h>

List of all members.

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.
BitFieldbf
 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.

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


Constructor & Destructor Documentation

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.

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

The destructor.

Definition at line 297 of file bitfield.h.

References bf, buf, length, and values.


Member Function Documentation

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 (  ) [inline]

Forgets all the bit fields and deallocates the memory.

Definition at line 313 of file bitfield.h.

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

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.


Member Data Documentation

The number of bit fields that still can be stored.

Definition at line 270 of file bitfield.h.

Referenced by forget().

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.

The length of bit fields.

Definition at line 279 of file bitfield.h.

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

The actual size of the table.

Definition at line 276 of file bitfield.h.

Referenced by forget().

The number of bit fields used.

Definition at line 273 of file bitfield.h.

Referenced by used().

The values of bit fields.

Definition at line 285 of file bitfield.h.

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


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