SSAGES
0.1
A MetaDynamics Package
|
Custom Iterator. More...
#include <Grid.h>
Public Types | |
typedef GridIterator | 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 | |
GridIterator ()=default | |
Use default constructor. | |
GridIterator (const std::vector< int > &indices, Grid< T > *grid) | |
Constructor. More... | |
GridIterator (const std::vector< int > &indices, const Grid< T > *grid) | |
Const constructor. More... | |
GridIterator (const GridIterator &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... | |
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 grid point. | |
Grid< T > * | grid_ |
Pointer to grid to iterate over. | |
Custom Iterator.
This iterator is designed of travesing through a grid. The starting point is at grid index 0 for each dimension. The last valid grid point has the num_points in each dimension, where num_points is the number of grid points in the respective 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 GridIterator::indices() and GridIterator::coordinates() are provided. These functions return the indices of the current grid point and the center of the grid point interval 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 grid point [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 moves beyond the valid range in this dimension, the index is reset to 0 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.
|
inline |
Constructor.
indices | Bin indices specifying the current position of the iterator. |
hist | Pointer to the grid to iterate over. |
Definition at line 273 of file Grid.h.
|
inline |
Const constructor.
indices | Bin indices specifying the current position of the iterator. |
hist | Pointer to the grid to iterate over. |
Definition at line 284 of file Grid.h.
|
inline |
Copy constructor.
other | GridIterator to be copied. |
Definition at line 293 of file Grid.h.
|
inline |
Access specific coordinate dimension.
d | Dimension of the coordinate. |
Definition at line 498 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::coordinates().
|
inline |
Access coordinates.
Definition at line 488 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::grid_, and SSAGES::Grid< T >::GridIterator< R >::indices_.
Referenced by SSAGES::Grid< T >::GridIterator< R >::coordinate().
|
inline |
Access a specific index.
d | Dimension of the index. |
Definition at line 479 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::indices().
|
inline |
Access indices.
Definition at line 468 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::indices_.
Referenced by SSAGES::Grid< T >::GridIterator< R >::index().
|
inline |
|
inline |
Dereference operator.
Definition at line 302 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::grid_, and SSAGES::Grid< T >::GridIterator< R >::indices_.
|
inline |
Addition operator.
shift | Amount of shift in each dimension. |
Shift the iterator by a given vector.
Definition at line 374 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::GridIterator().
|
inline |
Pre-increment operator.
Increments the bin index of lowest dimension. If an index moves beyond the maximum value (num_points-1), it is reset to 0 and the index of the next higher dimension is increased by 1.
Definition at line 312 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::grid_, and SSAGES::Grid< T >::GridIterator< R >::indices_.
|
inline |
|
inline |
Subtraction iterator.
shift | Vector to be subtracted from the current grid indices. |
Definition at line 434 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::GridIterator().
|
inline |
Pre-decrement operator.
Traveses the histogram in the opposite direction to the increment operator.
Definition at line 386 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::grid_, and SSAGES::Grid< T >::GridIterator< R >::indices_.
|
inline |
|
inline |
Subtraction assignment operator.
shift | Vector to be subtracted from the current grid indices. |
Definition at line 415 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::grid_, and SSAGES::Grid< T >::GridIterator< 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 445 of file Grid.h.
References SSAGES::Grid< T >::GridIterator< R >::grid_, and SSAGES::Grid< T >::GridIterator< R >::indices_.