www.mooseframework.org
Public Types | Public Member Functions | Protected Attributes | List of all members
MultiIndex< T >::const_noconst_iterator< is_const > Class Template Reference

MultiIndex container iterator. More...

#include <MultiIndex.h>

Public Types

typedef std::conditional< is_const, const MultiIndex< T > &, MultiIndex< T > & >::type reference_type
 

Public Member Functions

 const_noconst_iterator (reference_type multi_index, unsigned int position)
 
unsigned int flatIndex () const
 
reference_type getMultiIndexObject () const
 
const_noconst_iteratoroperator= (const const_noconst_iterator &other)
 
 const_noconst_iterator (const const_noconst_iterator &)=default
 
const_noconst_iteratoroperator++ ()
 
const_noconst_iteratoroperator++ (int)
 
const_noconst_iteratoroperator-- ()
 
const_noconst_iteratoroperator-- (int)
 
bool operator== (const const_noconst_iterator &other) const
 to be equal both iterators must hold a reference to the same MultiIndexObject and be at the same _flat_index More...
 
bool operator!= (const const_noconst_iterator &other) const
 
std::pair< const size_type &, T & > operator* ()
 dereferencing operator More...
 
std::pair< const size_type &, const T & > operator* () const
 

Protected Attributes

reference_type _multi_index
 
unsigned int _flat_index
 
size_type _shape
 
size_type _indices
 

Detailed Description

template<class T>
template<bool is_const>
class MultiIndex< T >::const_noconst_iterator< is_const >

MultiIndex container iterator.

Nested iterator class for MultiIndex containers.

Definition at line 27 of file MultiIndex.h.

Member Typedef Documentation

◆ reference_type

template<class T>
template<bool is_const>
typedef std::conditional<is_const, const MultiIndex<T> &, MultiIndex<T> &>::type MultiIndex< T >::const_noconst_iterator< is_const >::reference_type

Definition at line 132 of file MultiIndex.h.

Constructor & Destructor Documentation

◆ const_noconst_iterator() [1/2]

template<class T>
template<bool is_const>
MultiIndex< T >::const_noconst_iterator< is_const >::const_noconst_iterator ( reference_type  multi_index,
unsigned int  position 
)
inline

Definition at line 134 of file MultiIndex.h.

135  : _multi_index(multi_index), _flat_index(position), _shape(multi_index.size())
136  {
137  _multi_index.findIndexVector(position, _indices);
138  }

◆ const_noconst_iterator() [2/2]

template<class T>
template<bool is_const>
MultiIndex< T >::const_noconst_iterator< is_const >::const_noconst_iterator ( const const_noconst_iterator< is_const > &  )
default

Member Function Documentation

◆ flatIndex()

template<class T>
template<bool is_const>
unsigned int MultiIndex< T >::const_noconst_iterator< is_const >::flatIndex ( ) const
inline

◆ getMultiIndexObject()

template<class T>
template<bool is_const>
reference_type MultiIndex< T >::const_noconst_iterator< is_const >::getMultiIndexObject ( ) const
inline

◆ operator!=()

template<class T>
template<bool is_const>
bool MultiIndex< T >::const_noconst_iterator< is_const >::operator!= ( const const_noconst_iterator< is_const > &  other) const
inline

Definition at line 229 of file MultiIndex.h.

229 { return !(*this == other); }

◆ operator*() [1/2]

template<class T>
template<bool is_const>
std::pair<const size_type &, T &> MultiIndex< T >::const_noconst_iterator< is_const >::operator* ( )
inline

dereferencing operator

Definition at line 232 of file MultiIndex.h.

233  {
234  return std::pair<const size_type &, T &>(_indices, _multi_index._data[_flat_index]);
235  }

◆ operator*() [2/2]

template<class T>
template<bool is_const>
std::pair<const size_type &, const T &> MultiIndex< T >::const_noconst_iterator< is_const >::operator* ( ) const
inline

Definition at line 236 of file MultiIndex.h.

237  {
238  return std::pair<const size_type &, const T &>(_indices, _multi_index._data[_flat_index]);
239  }

◆ operator++() [1/2]

template<class T>
template<bool is_const>
const_noconst_iterator& MultiIndex< T >::const_noconst_iterator< is_const >::operator++ ( )
inline

Definition at line 157 of file MultiIndex.h.

158  {
159  ++_flat_index;
160  // increment indices
161  for (unsigned int j = 0; j < _indices.size(); ++j)
162  {
163  _indices[_indices.size() - j - 1] =
164  (_indices[_indices.size() - j - 1] + 1) % _shape[_indices.size() - j - 1];
165  if (_indices[_indices.size() - j - 1] != 0)
166  break;
167  }
168  return *this;
169  }

◆ operator++() [2/2]

template<class T>
template<bool is_const>
const_noconst_iterator& MultiIndex< T >::const_noconst_iterator< is_const >::operator++ ( int  )
inline

Definition at line 172 of file MultiIndex.h.

173  {
174  const_noconst_iterator clone(*this);
175  ++_flat_index;
176  // increment indices
177  for (unsigned int j = 0; j < _indices.size(); ++j)
178  {
179  _indices[_indices.size() - j - 1] =
180  (_indices[_indices.size() - j - 1] + 1) % _shape[_indices.size() - j - 1];
181  if (_indices[_indices.size() - j - 1] != 0)
182  break;
183  }
184  return clone;
185  }
const_noconst_iterator(reference_type multi_index, unsigned int position)
Definition: MultiIndex.h:134

◆ operator--() [1/2]

template<class T>
template<bool is_const>
const_noconst_iterator& MultiIndex< T >::const_noconst_iterator< is_const >::operator-- ( )
inline

Definition at line 188 of file MultiIndex.h.

189  {
190  --_flat_index;
191  // decrement indices
192  for (unsigned int j = 0; j < _indices.size(); ++j)
193  {
194  if (_indices[_indices.size() - j - 1] == 0)
195  _indices[_indices.size() - j - 1] = _shape[_indices.size() - j - 1] - 1;
196  else
197  {
198  --_indices[_indices.size() - j - 1];
199  break;
200  }
201  }
202  return *this;
203  }

◆ operator--() [2/2]

template<class T>
template<bool is_const>
const_noconst_iterator& MultiIndex< T >::const_noconst_iterator< is_const >::operator-- ( int  )
inline

Definition at line 206 of file MultiIndex.h.

207  {
208  const_noconst_iterator clone(*this);
209  --_flat_index;
210  // decrement indices
211  for (unsigned int j = 0; j < _indices.size(); ++j)
212  {
213  if (_indices[_indices.size() - j - 1] == 0)
214  _indices[_indices.size() - j - 1] = _shape[_indices.size() - j - 1] - 1;
215  else
216  {
217  --_indices[_indices.size() - j - 1];
218  break;
219  }
220  }
221  return clone;
222  }
const_noconst_iterator(reference_type multi_index, unsigned int position)
Definition: MultiIndex.h:134

◆ operator=()

template<class T>
template<bool is_const>
const_noconst_iterator& MultiIndex< T >::const_noconst_iterator< is_const >::operator= ( const const_noconst_iterator< is_const > &  other)
inline

Definition at line 145 of file MultiIndex.h.

146  {
147  _multi_index = other.getMultiIndexObject();
148  _flat_index = other.flatIndex();
149  _multi_index.findIndexVector(_flat_index, _indices);
150  return *this;
151  }

◆ operator==()

template<class T>
template<bool is_const>
bool MultiIndex< T >::const_noconst_iterator< is_const >::operator== ( const const_noconst_iterator< is_const > &  other) const
inline

to be equal both iterators must hold a reference to the same MultiIndexObject and be at the same _flat_index

Definition at line 225 of file MultiIndex.h.

226  {
227  return _flat_index == other.flatIndex() && &_multi_index == &other.getMultiIndexObject();
228  }

Member Data Documentation

◆ _flat_index

template<class T>
template<bool is_const>
unsigned int MultiIndex< T >::const_noconst_iterator< is_const >::_flat_index
protected

Definition at line 243 of file MultiIndex.h.

◆ _indices

template<class T>
template<bool is_const>
size_type MultiIndex< T >::const_noconst_iterator< is_const >::_indices
protected

Definition at line 245 of file MultiIndex.h.

◆ _multi_index

template<class T>
template<bool is_const>
reference_type MultiIndex< T >::const_noconst_iterator< is_const >::_multi_index
protected

Definition at line 242 of file MultiIndex.h.

◆ _shape

template<class T>
template<bool is_const>
size_type MultiIndex< T >::const_noconst_iterator< is_const >::_shape
protected

Definition at line 244 of file MultiIndex.h.


The documentation for this class was generated from the following file: