#include <GLStorageVector.h>
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 |
GLBaseOrganism * | getOrganismPointer (unsigned i) |
const GLBaseOrganism * | getOrganismPointer (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) |
Definition at line 11 of file GLStorageVector.h.
GLStorageVector::GLStorageVector | ( | unsigned | expected_size = 0 |
) |
Constructor.
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. |
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.
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.
organism | new organism to be added to storage. | |
twins | when set to NO_TWINS, check that this organism is not in the storage already. |
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 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.
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.
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.
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.
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.
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.
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 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.
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 160 of file GLStorageVector.cpp.
virtual int GLStorageVector::getSize | ( | ) | const [inline, virtual] |
Returns the 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.
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.
new_size | new number of organisms in the storage. |
Implements GLBaseOrganismStorage.
Definition at line 278 of file GLStorageVector.cpp.