SSAGES
0.1
A MetaDynamics Package
|
Custom Iterator. More...
#include <Histogram.h>
Public Types | |
typedef HistIterator | self_type |
Type name of the iterator. | |
typedef int | difference_type |
Difference type is an int. | |
typedef R | value_type |
Either T or const T for iterator and const_iterator, respectively. | |
typedef R * | pointer |
Either T* or T const* for iterator and const_iterator, respectively. | |
typedef R & | reference |
Either T& or T const& for iterator and const_iterator, respectively. | |
typedef std::bidirectional_iterator_tag | iterator_category |
HistIterator is a bidirectional iterator. | |
Public Member Functions | |
HistIterator ()=default | |
Use default constructor. | |
HistIterator (const std::vector< int > &indices, Histogram< T > *hist) | |
Constructor. More... | |
HistIterator (const HistIterator &other) | |
Copy constructor. More... | |
reference | operator* () |
Dereference operator. More... | |
self_type & | operator++ () |
Pre-increment operator. More... | |
self_type | operator++ (int) |
Post-increment operator. More... | |
self_type & | operator+= (std::vector< int > shift) |
Addition assignment operator. | |
const self_type | operator+ (std::vector< int > shift) |
Addition operator. More... | |
self_type & | operator-- () |
Pre-decrement operator. More... | |
self_type | operator-- (int) |
Post-decrement operator. More... | |
self_type & | operator-= (std::vector< int > shift) |
Subtraction assignment operator. More... | |
const self_type | operator- (std::vector< int > shift) |
Subtraction iterator. More... | |
bool | operator== (const self_type &rhs) const |
Equality operator. More... | |
bool | operator!= (const self_type &rhs) const |
Non-equality operator. More... | |
std::vector< int > & | indices () |
Access indices. More... | |
int & | index (size_t d) |
Access a specific index. More... | |
bool | isUnderOverflowBin () const |
Check if current iterator position is under- or overflow bin. More... | |
std::vector< double > | coordinates () const |
Access coordinates. More... | |
double | coordinate (size_t d) const |
Access specific coordinate dimension. More... | |
Private Attributes | |
std::vector< int > | indices_ |
Indices of current bin. | |
Histogram< T > * | hist_ |
Pointer to histogram to iterate over. | |
Custom Iterator.
This iterator is designed of travesing through a histogram. The starting point is at grid index 0 (-1) for each periodic (non-periodic) dimension.
The iterator can be used as a standard iterator with operator* accessing the grid point at which the iterator currently is.
Additionally, the functions HistIterator::indices() and HistIterator::coordinates() are provided. These functions return the indices of the current bin and the bin center in real space, respectively.
The iterator can be moved to an arbitrary position. As indices() returns a reference (and not a const reference), it can be used to move the iterator. For example:
moves the iterator to the bin with indices [1, 1, 1].
The iterator can be traversed in a standard fashion with the increment and decrement operators operator++ and operator--. When the increment operator is invoked, the bin index for the lowest dimension is increased by 1. If it is beyond the histogram size in this dimension, the index is reset to its smallest value (0 for periodic, -1 for non-periodic dimensions) and the index of the next higher dimension is increased by 1. The decrement operator traveses the grid in the same fashion but opposite direction.
Additionaly, the iterator can be shifted by adding or subtracting a vector of ints. The vector needs to have the same dimension as the histogram.
Definition at line 256 of file Histogram.h.
|
inline |
Constructor.
indices | Bin indices specifying the current position of the iterator. |
hist | Pointer to the histogram to iterate over. |
Definition at line 285 of file Histogram.h.
|
inline |
Copy constructor.
other | HistIterator to be copied. |
Definition at line 294 of file Histogram.h.
|
inline |
Access specific coordinate dimension.
d | Dimension of the coordinate. |
Definition at line 523 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::coordinates().
|
inline |
Access coordinates.
Definition at line 513 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.
Referenced by SSAGES::Histogram< T >::HistIterator< R >::coordinate().
|
inline |
Access a specific index.
d | Dimension of the index. |
Definition at line 490 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::indices().
|
inline |
Access indices.
Definition at line 479 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::indices_.
Referenced by SSAGES::Histogram< T >::HistIterator< R >::index().
|
inline |
Check if current iterator position is under- or overflow bin.
True
if current bin is an underflow or an overflow bin. Definition at line 499 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.
|
inline |
Non-equality operator.
rhs | Iterator to which this iterator is compared. |
False
if both iterators access the same grid point on the same grid. Else return True
. Definition at line 467 of file Histogram.h.
|
inline |
Dereference operator.
Definition at line 303 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.
|
inline |
Addition operator.
shift | Amount of shift in each dimension. |
Shift the iterator by a given vector.
Definition at line 382 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::HistIterator().
|
inline |
Pre-increment operator.
Increments the bin index of the lowest dimension. If an index moves beyond the maximum value (num_points-1 for periodic and num_points for non-periodic dimensions), it is reset to its smallest value (0 for periodic, -1 for non-periodic dimensions) and the index of the next higher dimension is increased by 1.
Definition at line 315 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.
|
inline |
Post-increment operator.
Definition at line 339 of file Histogram.h.
|
inline |
Subtraction iterator.
shift | Vector to be subtracted from the current grid indices. |
Definition at line 445 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::HistIterator().
|
inline |
Pre-decrement operator.
Traveses the histogram in the opposite direction to the increment operator.
Definition at line 394 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.
|
inline |
Post-decrement operator.
Definition at line 414 of file Histogram.h.
|
inline |
Subtraction assignment operator.
shift | Vector to be subtracted from the current grid indices. |
Definition at line 426 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.
|
inline |
Equality operator.
rhs | Iterator to which this iterator is compared. |
True
if both iterators access the same grid point on the same grid. Else return False
. Definition at line 456 of file Histogram.h.
References SSAGES::Histogram< T >::HistIterator< R >::hist_, and SSAGES::Histogram< T >::HistIterator< R >::indices_.