Simpatico
v1.10
|
A fixed capacity (static) contiguous array with a variable logical size.
An FSArray < Data, Capacity > is a wrapper for a statically allocated C array containing Capacity objects of type Data. An FSArray has both a Capacity that is set at compile time, which is the physical size of the underlying C array, and a logical size, which is the number of contiguous elements (from 0 to one less than its size) that contain valid data. The size is initialized to zero, and can only be increased only by the append() method, which adds a new element to the end of the array.
When compiled in debug mode (i.e., when NDEBUG is defined) the subcript operator [] checks that the index is less than the logical size, and not merely less than the capacity.
#include <FSArray.h>
Public Member Functions | |
FSArray () | |
Constructor. More... | |
FSArray (const FSArray< Data, Capacity > &other) | |
Copy constructor. More... | |
FSArray< Data, Capacity > & | operator= (const FSArray< Data, Capacity > &other) |
Assignment, element by element. More... | |
virtual | ~FSArray () |
Destructor. More... | |
int | capacity () const |
Return physical capacity of array. More... | |
int | size () const |
Return logical size of this array (i.e., number of elements). More... | |
void | begin (ArrayIterator< Data > &iterator) |
Set an ArrayIterator to the beginning of this container. More... | |
void | begin (ConstArrayIterator< Data > &iterator) const |
Set a ConstArrayIterator to the beginning of this container. More... | |
Data & | operator[] (int i) |
Mimic C array subscripting. More... | |
const Data & | operator[] (int i) const |
Mimic C array subscripting. More... | |
void | append (const Data &data) |
Append data to the end of the array. More... | |
void | clear () |
Set logical size to zero. More... | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize to/from an archive. More... | |
int | packedSize () |
Packed size of FSArray in a MemoryArchive, in bytes. More... | |
Protected Attributes | |
Data | data_ [Capacity] |
Array of Data elements. More... | |
int | size_ |
Logical size of array (number of elements used). More... | |
|
inline |
Util::FSArray< Data, Capacity >::FSArray | ( | const FSArray< Data, Capacity > & | other | ) |
Copy constructor.
other | the FSArray to be copied. |
Definition at line 158 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, and Util::FSArray< Data, Capacity >::size_.
|
virtual |
FSArray< Data, Capacity > & Util::FSArray< Data, Capacity >::operator= | ( | const FSArray< Data, Capacity > & | other | ) |
Assignment, element by element.
Capacity of LHS FSArray must be >= size of RHS FSArray.
other | the RHS FSArray |
Definition at line 175 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, and Util::FSArray< Data, Capacity >::size_.
int Util::FSArray< Data, Capacity >::capacity | ( | ) | const |
Return physical capacity of array.
Definition at line 200 of file FSArray.h.
Referenced by Util::PointGroup::makeStar().
int Util::FSArray< Data, Capacity >::size | ( | ) | const |
Return logical size of this array (i.e., number of elements).
Definition at line 207 of file FSArray.h.
References Util::FSArray< Data, Capacity >::size_.
Referenced by McMd::CfbEndBase::addEndAtom(), McMd::BondPotentialImpl< Interaction >::atomEnergy(), McMd::McPairPotentialImpl< Interaction >::atomEnergy(), McMd::DihedralPotentialImpl< Interaction >::atomEnergy(), McMd::AnglePotentialImpl< Interaction >::atomEnergy(), McMd::Generator::attemptPlaceAtom(), DdMd::PairList::build(), McMd::PairList::build(), McMd::McPairPotentialImpl< Interaction >::computeEnergy(), DdMd::PairPotentialImpl< Interaction >::computeEnergy(), McMd::Activate::deactivate(), McMd::CfbEndBase::deleteEndAtom(), McMd::McPairExternalPerturbation< PairInteraction, ExternalInteraction >::derivative(), McMd::McPairPerturbation< Interaction >::derivative(), McMd::getAtomAngles(), McMd::getAtomBonds(), McMd::getAtomDihedrals(), DdMd::Cell::getNeighbors(), McMd::ClusterIdentifier::initialize(), Util::PointGroup::makeStar(), McMd::McPairPotentialImpl< Interaction >::moleculeEnergy(), McMd::Sliplinker::move(), McMd::SliplinkerAll::move(), McMd::SliplinkerEnd::move(), McMd::GcSliplinkMove::move(), McMd::SliplinkMove::move(), DdMd::PairPotential::nPair(), McMd::Activate::reactivate(), McMd::StructureFactorPGrid::readParameters(), McMd::StructureFactorGrid::readParameters(), DdMd::StructureFactorGrid::readParameters(), McMd::IntraStructureFactorGrid::readParameters(), McMd::Crosslinker::sample(), McMd::McMuExchange::sample(), Tools::PairEnergy::sample(), McMd::McPairEnergyAverage::sample(), McMd::StructureFactorPGrid::save(), McMd::RingOctaRebridgeMove::scanBridge(), and McMd::GroupRebridgeBase::tetraEnergy().
void Util::FSArray< Data, Capacity >::begin | ( | ArrayIterator< Data > & | iterator | ) |
Set an ArrayIterator to the beginning of this container.
iterator | ArrayIterator, initialized on output. |
Definition at line 216 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, Util::ArrayIterator< Data >::setCurrent(), Util::ArrayIterator< Data >::setEnd(), and Util::FSArray< Data, Capacity >::size_.
void Util::FSArray< Data, Capacity >::begin | ( | ConstArrayIterator< Data > & | iterator | ) | const |
Set a ConstArrayIterator to the beginning of this container.
iterator | ConstArrayIterator, initialized on output. |
Definition at line 226 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, Util::ConstArrayIterator< Data >::setCurrent(), Util::ConstArrayIterator< Data >::setEnd(), and Util::FSArray< Data, Capacity >::size_.
Data & Util::FSArray< Data, Capacity >::operator[] | ( | int | i | ) |
Mimic C array subscripting.
i | array index |
Definition at line 236 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, and Util::FSArray< Data, Capacity >::size_.
const Data & Util::FSArray< Data, Capacity >::operator[] | ( | int | i | ) | const |
Mimic C array subscripting.
i | array index |
Definition at line 247 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, and Util::FSArray< Data, Capacity >::size_.
|
inline |
Append data to the end of the array.
data | Data to add to end of array. |
Definition at line 258 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, Util::FSArray< Data, Capacity >::size_, and UTIL_THROW.
Referenced by McMd::getAtomAngles(), McMd::getAtomBonds(), McMd::getAtomDihedrals(), McMd::CellList::getCellNeighbors(), Tools::Cell::getNeighbors(), DdMd::Cell::getNeighbors(), Tools::CellList::makeGrid(), DdMd::CellList::makeGrid(), and Util::PointGroup::makeStar().
|
inline |
Set logical size to zero.
Definition at line 271 of file FSArray.h.
References Util::FSArray< Data, Capacity >::size_.
Referenced by McMd::getAtomAngles(), McMd::getAtomBonds(), McMd::getAtomDihedrals(), McMd::CellList::getCellNeighbors(), Tools::Cell::getNeighbors(), DdMd::Cell::getNeighbors(), DdMd::CellList::makeGrid(), and Util::PointGroup::makeStar().
|
inline |
Serialize to/from an archive.
ar | archive |
version | archive version id |
Definition at line 279 of file FSArray.h.
References Util::FSArray< Data, Capacity >::data_, Util::FSArray< Data, Capacity >::size_, and UTIL_THROW.
|
inline |
|
protected |
Array of Data elements.
Definition at line 137 of file FSArray.h.
Referenced by Util::FSArray< Data, Capacity >::append(), Util::FSArray< Data, Capacity >::begin(), Util::FSArray< Data, Capacity >::FSArray(), Util::FSArray< Data, Capacity >::operator=(), Util::FSArray< Data, Capacity >::operator[](), and Util::FSArray< Data, Capacity >::serialize().
|
protected |
Logical size of array (number of elements used).
Definition at line 140 of file FSArray.h.
Referenced by Util::FSArray< Data, Capacity >::append(), Util::FSArray< Data, Capacity >::begin(), Util::FSArray< Data, Capacity >::clear(), Util::FSArray< Data, Capacity >::FSArray(), Util::FSArray< Data, Capacity >::operator=(), Util::FSArray< Data, Capacity >::operator[](), Util::FSArray< Data, Capacity >::serialize(), and Util::FSArray< Data, Capacity >::size().