NFcore::MoleculeList Class Reference

#include <moleculeList.hh>

List of all members.


Detailed Description

Keeps a set of molecules neatly for a MoleculeType.

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.

Author:
Michael Sneddon

Public Member Functions

 MoleculeList (MoleculeType *mt, int init_capacity, int finalCapacity)
 ~MoleculeList ()
int size () const
NFcore::Moleculeat (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
MoleculeTypemt
Molecule ** mArray
int * molPos

Constructor & Destructor Documentation

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 (  ) 

Deletes the list and all Molecule objects associated with this list. A Molecule cannot exist outside of a list, so deleting this deletes all member molecules.


Member Function Documentation

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  ) 

Allocates a spot for a new Molecule in the system. The given pointer is assigned to the new Molecule (so it should be passed in as a null pointer) and the method returns the index this Molecule was assigned.

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.


Member Data Documentation

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


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 11:02:48 2010 for NFsim by  doxygen 1.5.4