#include <moleculeList.hh>
MoleculeTypes have to store a link to all Molecule objects that currently exist. This is done using this list. This list sets aside a certain number of pointers for molecules of a particular type so that adding and deleting molecules from the system is very fast. The code enforces that all existing Molecules are maintained with this list again for maximum effeciency and memory management.
Public Member Functions | |
MoleculeList (MoleculeType *mt, int init_capacity, int finalCapacity) | |
~MoleculeList () | |
int | size () const |
NFcore::Molecule * | at (int index) const |
int | create (Molecule *&m) |
void | remove (int listId, Molecule *m) |
void | removeLast () |
void | printDetails () |
Static Public Attributes | |
static const int | NO_LIMIT = -1 |
Protected Attributes | |
int | n_molecules |
int | lastAllocated |
int | capacity |
int | finalCapacity |
MoleculeType * | mt |
Molecule ** | mArray |
int * | molPos |
MoleculeList::MoleculeList | ( | MoleculeType * | mt, | |
int | init_capacity, | |||
int | finalCapacity | |||
) |
Create a new MoleculeList that stores the given type of molecule with an initial capacity (that is dynamically expanded if you add more than the given capacity of molecules).
MoleculeList::~MoleculeList | ( | ) |
int MoleculeList::size | ( | ) | const |
Returns the number of molecules that are on the list
Molecule * MoleculeList::at | ( | int | index | ) | const |
Returns a pointer to the Molecule with the given index.
int MoleculeList::create | ( | Molecule *& | m | ) |
void MoleculeList::remove | ( | int | listId, | |
Molecule * | m | |||
) |
Removes a Molecule from this list with the given ID.
void MoleculeList::removeLast | ( | ) |
Removes the very last Molecule on the list (which is the one you just created if you haven't touched anything)
void MoleculeList::printDetails | ( | ) |
Print out some (maybe too much) diagnostic debug information about the list.
const int NFcore::MoleculeList::NO_LIMIT = -1 [static] |
int NFcore::MoleculeList::n_molecules [protected] |
The number of Molecule objects currently on the list
int NFcore::MoleculeList::lastAllocated [protected] |
The number of Molecule objects currently on the list
int NFcore::MoleculeList::capacity [protected] |
The maximum number of Molecules that can be added before the list resizes itself
int NFcore::MoleculeList::finalCapacity [protected] |
The maximum number of Molecules that can be added, period.
MoleculeType* NFcore::MoleculeList::mt [protected] |
Keeps track of the type of molecule stored by this list
Molecule** NFcore::MoleculeList::mArray [protected] |
The actual array of Molecules that are stored
int* NFcore::MoleculeList::molPos [protected] |
Allows the list to map index values of Molecules to the index values in the list array