PSCF v1.3
|
A fixed capacity (static) contiguous array with a variable logical size. More...
#include <FSArray.h>
Public Member Functions | |
FSArray () | |
Constructor. | |
FSArray (FSArray< Data, Capacity > const &other) | |
Copy constructor. | |
FSArray< Data, Capacity > & | operator= (FSArray< Data, Capacity > const &other) |
Assignment, element by element. | |
virtual | ~FSArray () |
Destructor. | |
int | capacity () const |
Return physical capacity of array. | |
int | size () const |
Return logical size of this array (i.e., number of elements). | |
void | begin (ArrayIterator< Data > &iterator) |
Set an ArrayIterator to the beginning of this container. | |
void | begin (ConstArrayIterator< Data > &iterator) const |
Set a ConstArrayIterator to the beginning of this container. | |
Data & | operator[] (int i) |
Mimic C array subscripting. | |
Data const & | operator[] (int i) const |
Mimic C array subscripting. | |
void | append (Data const &data) |
Append data to the end of the array. | |
void | clear () |
Set logical size to zero. | |
template<class Archive> | |
void | serialize (Archive &ar, const unsigned int version) |
Serialize to/from an archive. | |
int | packedSize () |
Packed size of FSArray in a MemoryArchive, in bytes. |
Protected Attributes | |
Data | data_ [Capacity] |
Array of Data elements. | |
int | size_ |
Logical size of array (number of elements used). |
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 |
Constructor.
Definition at line 148 of file FSArray.h.
References size_.
Referenced by FSArray(), and operator=().
Util::FSArray< Data, Capacity >::FSArray | ( | FSArray< Data, Capacity > const & | other | ) |
|
virtual |
FSArray< Data, Capacity > & Util::FSArray< Data, Capacity >::operator= | ( | FSArray< Data, Capacity > const & | other | ) |
int Util::FSArray< Data, Capacity >::capacity | ( | ) | const |
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 size_.
Referenced by Pscf::Rpc::Sweep< D >::extrapolate(), and Pscf::Rpg::Sweep< D >::extrapolate().
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 data_, Util::ArrayIterator< Data >::setCurrent(), Util::ArrayIterator< Data >::setEnd(), and 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 data_, Util::ConstArrayIterator< Data >::setCurrent(), Util::ConstArrayIterator< Data >::setEnd(), and size_.
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 data_, size_, and UTIL_THROW.
Referenced by Pscf::Rpc::Block< D >::computeStressBead(), Pscf::Rpg::Block< D >::computeStressBead(), Pscf::Rpc::Block< D >::computeStressThread(), Pscf::Rpg::Block< D >::computeStressThread(), Pscf::Prdc::replicateUnitCell(), Pscf::Prdc::replicateUnitCell(), and Pscf::Prdc::replicateUnitCell().
|
inline |
Set logical size to zero.
Definition at line 271 of file FSArray.h.
References size_.
Referenced by Pscf::Rpg::Block< D >::computeStressBead().
|
inline |
Serialize to/from an archive.
ar | archive |
version | archive version id |
Definition at line 280 of file FSArray.h.
References data_, size_, and UTIL_THROW.
|
inline |
|
protected |
Array of Data elements.
Definition at line 137 of file FSArray.h.
Referenced by append(), begin(), begin(), FSArray(), operator=(), operator[](), operator[](), and serialize().
|
protected |
Logical size of array (number of elements used).
Definition at line 140 of file FSArray.h.
Referenced by append(), begin(), begin(), clear(), FSArray(), FSArray(), operator=(), operator[](), operator[](), serialize(), and size().