#include <GLStorageSet.h>
Public Member Functions | |
GLStorageSet () | |
virtual | ~GLStorageSet () |
virtual bool | addOrganism (GLBaseOrganism *organism, GLConstants::TTwinsFlags twins=GLConstants::NO_TWINS) |
void | emptyStorage () |
virtual const GLBaseOrganism * | findOrganism (const GLBaseOrganism *organism, bool soft=true) const |
virtual GLBaseOrganismStorage::iterator * | getIterator () |
virtual GLBaseOrganismStorage::const_iterator * | getIteratorConst () 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) |
Definition at line 12 of file GLStorageSet.h.
GLStorageSet::GLStorageSet | ( | ) |
Simple constructor
Definition at line 6 of file GLStorageSet.cpp.
GLStorageSet::~GLStorageSet | ( | ) | [virtual] |
Frees memory allocated to the organisms, depending on the memory policy property.
Definition at line 10 of file GLStorageSet.cpp.
bool GLStorageSet::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.
organism | new organism to be added to storage. | |
twins | when set to NO_TWINS, check that this organism is not in the storage already. |
Implements GLBaseOrganismStorage.
Definition at line 23 of file GLStorageSet.cpp.
void GLStorageSet::emptyStorage | ( | ) | [virtual] |
Removes all the organisms from the storage and frees memory
Implements GLBaseOrganismStorage.
Definition at line 34 of file GLStorageSet.cpp.
const GLBaseOrganism * GLStorageSet::findOrganism | ( | const GLBaseOrganism * | organism, | |
bool | soft = true | |||
) | const [virtual] |
Checks, if the organism is already in storage (compared not pointers, but the content of the organisms).
organism | organism to be found. | |
soft | when true comparison is made in the 'soft' sense. |
Reimplemented from GLBaseOrganismStorage.
Definition at line 60 of file GLStorageSet.cpp.
GLBaseOrganismStorage::iterator * GLStorageSet::getIterator | ( | ) | [virtual] |
Returns the pointer to iterator at the first element of the storage.
Implements GLBaseOrganismStorage.
Definition at line 76 of file GLStorageSet.cpp.
GLBaseOrganismStorage::const_iterator * GLStorageSet::getIteratorConst | ( | ) | const [virtual] |
Returns the pointer to constant iterator at the first element of the storage.
Implements GLBaseOrganismStorage.
Definition at line 88 of file GLStorageSet.cpp.
int GLStorageSet::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.
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. |
Reimplemented from GLBaseOrganismStorage.
Definition at line 149 of file GLStorageSet.cpp.
int GLStorageSet::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.
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. |
Reimplemented from GLBaseOrganismStorage.
Definition at line 111 of file GLStorageSet.cpp.
virtual int GLStorageSet::getSize | ( | ) | const [inline, virtual] |
Returns the number of elements in storage.
Implements GLBaseOrganismStorage.
Definition at line 118 of file GLStorageSet.h.
void GLStorageSet::merge | ( | const GLBaseOrganismStorage * | storage, | |
GLConstants::TTwinsFlags | twins = GLConstants::NO_TWINS | |||
) | [virtual] |
Adds organisms from another storage to the current one.
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 186 of file GLStorageSet.cpp.
int GLStorageSet::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.
new_size | new number of organisms in the storage. |
Implements GLBaseOrganismStorage.
Definition at line 212 of file GLStorageSet.cpp.