GLStorageVector Class Reference

#include <GLStorageVector.h>

Inheritance diagram for GLStorageVector:

GLBaseOrganismStorage

List of all members.

Public Member Functions

 GLStorageVector (unsigned expected_size=0)
virtual ~GLStorageVector ()
virtual bool addOrganism (GLBaseOrganism *organism, GLConstants::TTwinsFlags twins=GLConstants::NO_TWINS)
void emptyStorage ()
virtual
GLBaseOrganismStorage::iterator
getIterator ()
virtual
GLBaseOrganismStorage::const_iterator
getIteratorConst () const
int findOrganismIndex (const GLBaseOrganism *organism, bool soft=true) const
GLBaseOrganismgetOrganismPointer (unsigned i)
const GLBaseOrganismgetOrganismPointer (unsigned i) const
virtual int getOrganismsVector (vector< GLBaseOrganism * > &container, GLConstants::TStorageFilling fill=GLConstants::APPEND, int size=-1, bool copy_clones=false)
virtual int getOrganismsVector (vector< const GLBaseOrganism * > &container, GLConstants::TStorageFilling fill=GLConstants::APPEND, int size=-1, bool copy_clones=false) const
virtual int getSize () const
virtual void merge (const GLBaseOrganismStorage *storage, GLConstants::TTwinsFlags twins=GLConstants::NO_TWINS)
virtual int trimSize (unsigned int new_size)


Detailed Description

Class for storing organisms based on vector container.

Definition at line 11 of file GLStorageVector.h.


Constructor & Destructor Documentation

GLStorageVector::GLStorageVector ( unsigned  expected_size = 0  ) 

Constructor.

Parameters:
expected_size expected size of the storage -- memory will be reserved to avoid re-allocation once elements are added to storage. Note, that initial size of the storage will stay 0.
Constructor.
Parameters:
size expected size of the storage -- memory will be reserved to avoid re-allocation once elements are added to storage. Note, that initial size of the storage will stay 0.

Definition at line 11 of file GLStorageVector.cpp.

GLStorageVector::~GLStorageVector (  )  [virtual]

Frees memory allocated to the organisms, depending on the memory policy property.

Definition at line 18 of file GLStorageVector.cpp.


Member Function Documentation

bool GLStorageVector::addOrganism ( GLBaseOrganism organism,
GLConstants::TTwinsFlags  twins = GLConstants::NO_TWINS 
) [virtual]

Adds the new organism to storage. If the 'no duplication' flag is set and organism is already in the storage -- do not add it. Organisms are checked in 'soft' manner.

Parameters:
organism new organism to be added to storage.
twins when set to NO_TWINS, check that this organism is not in the storage already.
Returns:
true if organism was successfully added and false otherwise.
Adds the new organism to storage. If the 'no duplication' flag is set and organism is already in the storage -- do not add it. Organisms are checked in 'soft' manner.
Parameters:
organism new organism to be added to storage.
twins when set to NO_TWINS, check that this organism is not in the storage already.
Returns:
true if organism was succesfully added and false otherwise.

Implements GLBaseOrganismStorage.

Definition at line 32 of file GLStorageVector.cpp.

void GLStorageVector::emptyStorage (  )  [virtual]

Removes all the organisms from the storage and frees memory

Implements GLBaseOrganismStorage.

Definition at line 49 of file GLStorageVector.cpp.

int GLStorageVector::findOrganismIndex ( const GLBaseOrganism organism,
bool  soft = true 
) const

Returns the index of the organism in the storage which is equal to one provided or -1 if no such organism was found.

Parameters:
organism organism for comparison.
soft when true 'soft' comparison of organisms is conducted.

Definition at line 73 of file GLStorageVector.cpp.

GLBaseOrganismStorage::iterator * GLStorageVector::getIterator (  )  [virtual]

Returns the pointer to iterator at the first element of the storage.

Returns:
pointer to iterator at the first element of the storage.

Implements GLBaseOrganismStorage.

Definition at line 90 of file GLStorageVector.cpp.

GLBaseOrganismStorage::const_iterator * GLStorageVector::getIteratorConst (  )  const [virtual]

Returns the pointer to constant iterator at the first element of the storage.

Returns:
pointer to constant iterator at the first element of the storage.

Implements GLBaseOrganismStorage.

Definition at line 102 of file GLStorageVector.cpp.

const GLBaseOrganism * GLStorageVector::getOrganismPointer ( unsigned  i  )  const

Returns the pointer to the organism with given index.

Parameters:
i index of the organism to be returned.

Definition at line 129 of file GLStorageVector.cpp.

GLBaseOrganism * GLStorageVector::getOrganismPointer ( unsigned  i  ) 

Returns the pointer to the organism with given index.

Parameters:
i index of the organism to be returned.

Definition at line 111 of file GLStorageVector.cpp.

int GLStorageVector::getOrganismsVector ( vector< const GLBaseOrganism * > &  container,
GLConstants::TStorageFilling  fill = GLConstants::APPEND,
int  size = -1,
bool  copy_clones = false 
) const [virtual]

Provides the vector of pointers to the organisms in storage starting from the first one.

Parameters:
container vector of pointers to the organisms from storage (output value).
fill when APPEND the new organisms are added to the container, when REPLACE -- the container is cleaned before adding the organisms.
size number of organisms from storage to be returned in vector. if < 0 or > getSize() then returns all the organisms.
copy_clones when true the pointers to the clones of the organisms will be copied, otherwise -- pointers to the original organisms.
Returns:
number of elements transferred to container.

Reimplemented from GLBaseOrganismStorage.

Definition at line 206 of file GLStorageVector.cpp.

int GLStorageVector::getOrganismsVector ( vector< GLBaseOrganism * > &  container,
GLConstants::TStorageFilling  fill = GLConstants::APPEND,
int  size = -1,
bool  copy_clones = false 
) [virtual]

Provides the vector of pointers to the organisms in storage starting from the first one. The base version uses iterator to fill the vector, however, for real implementation of storage which uses stl containers more efficient approach should be possible.

Parameters:
container vector of pointers to the organisms from storage (output value).
fill when APPEND the new organisms are added to the container, when REPLACE -- the container is cleaned before adding the organisms.
size number of organisms from storage to be returned in vector. if < 0 or > getSize() then returns all the organisms.
copy_clones when true the pointers to the clones of the organisms will be copied, otherwise -- pointers to the original organisms.
Returns:
number of elements transferred to container.

Reimplemented from GLBaseOrganismStorage.

Definition at line 160 of file GLStorageVector.cpp.

virtual int GLStorageVector::getSize (  )  const [inline, virtual]

Returns the number of elements in storage.

Returns:
number of elements in storage.

Implements GLBaseOrganismStorage.

Definition at line 131 of file GLStorageVector.h.

void GLStorageVector::merge ( const GLBaseOrganismStorage storage,
GLConstants::TTwinsFlags  twins = GLConstants::NO_TWINS 
) [virtual]

Adds organisms from another storage to the current one.

Parameters:
storage another organism storage.
twins when equal to NO_TWINS, check that this organism is not in the storage already.

Implements GLBaseOrganismStorage.

Definition at line 243 of file GLStorageVector.cpp.

int GLStorageVector::trimSize ( unsigned int  new_size  )  [virtual]

Decreases the size of the storage. If the size of storage was less, than new size, that nothing will be done.

Parameters:
new_size new number of organisms in the storage.
Returns:
the number of organisms in storage after operation.

Implements GLBaseOrganismStorage.

Definition at line 278 of file GLStorageVector.cpp.


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

Generated on Sat Jun 13 13:58:13 2009 for GenLib by  doxygen 1.5.9