PSCF v1.1
|
A fixed capacity (static) contiguous array with a variable logical size. More...
#include <FSArray.h>
Public Member Functions | |
FSArray () | |
Constructor. More... | |
FSArray (FSArray< Data, Capacity > const &other) | |
Copy constructor. More... | |
FSArray< Data, Capacity > & | operator= (FSArray< Data, Capacity > const &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... | |
Data const & | operator[] (int i) const |
Mimic C array subscripting. More... | |
void | append (Data const &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... | |
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.
|
inline |
Util::FSArray< Data, Capacity >::FSArray | ( | FSArray< Data, Capacity > const & | 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= | ( | FSArray< Data, Capacity > const & | other | ) |
int Util::FSArray< Data, Capacity >::capacity |
int Util::FSArray< Data, Capacity >::size |
Return logical size of this array (i.e., number of elements).
Definition at line 207 of file FSArray.h.
Referenced by pscfpp.file.File::__eq__(), pscfpp.text.Record::__init__(), pscfpp.file.File::__init__(), pscfpp.file.File::__repr__(), pscfpp.text.Record::__str__(), Pscf::Pspc::Sweep< D >::extrapolate(), Pscf::Pspg::Sweep< D >::extrapolate(), Pscf::Pspc::FilmIterator< 2, IteratorType >::setFlexibleParams(), Pscf::Pspc::FilmIterator< 3, IteratorType >::setFlexibleParams(), Pscf::UnitCellBase< D >::setParameters(), Pscf::Pspc::Domain< D >::setUnitCell(), Pscf::Pspg::Domain< D >::setUnitCell(), and Pscf::Pspc::FilmIteratorBase< D, IteratorType >::updateWallFields().
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::ArrayIterator< Data >::setCurrent(), and Util::ArrayIterator< Data >::setEnd().
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::ConstArrayIterator< Data >::setCurrent(), and Util::ConstArrayIterator< Data >::setEnd().
Data & Util::FSArray< Data, Capacity >::operator[] | ( | int | i | ) |
Data const & Util::FSArray< Data, Capacity >::operator[] | ( | int | i | ) | const |
|
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_THROW.
Referenced by Pscf::Pspc::Block< D >::computeStress(), Pscf::UnitCellBase< D >::parameters(), Pscf::Pspc::FilmIterator< 1, IteratorType >::setFlexibleParams(), Pscf::Pspc::FilmIterator< 2, IteratorType >::setFlexibleParams(), and Pscf::Pspc::FilmIterator< 3, IteratorType >::setFlexibleParams().
|
inline |
|
inline |
Serialize to/from an archive.
ar | archive |
version | archive version id |
Definition at line 280 of file FSArray.h.
References UTIL_THROW.
|
inline |
|
protected |
Array of Data elements.
Definition at line 137 of file FSArray.h.
Referenced by Util::FSArray< Data, Capacity >::FSArray().
|
protected |
Logical size of array (number of elements used).
Definition at line 140 of file FSArray.h.
Referenced by Util::FSArray< Data, Capacity >::FSArray(), and Util::FSArray< Data, Capacity >::operator=().