Provides an iterator over a permutation of a range. More...
#include <reorder_iterator.hpp>
Public Member Functions | |
reorder_iterator (ElementIterator first, const index_container_ptr &index_collection) | |
Constructs an iterator that will walk through the elements of the range that begins at first , follwing the order defined by index_collection . | |
template<class OtherElementIterator > | |
reorder_iterator (reorder_iterator< OtherElementIterator > const &r, typename boost::enable_if_convertible< OtherElementIterator, ElementIterator >::type *=0) | |
Allows conversion from a reorder_iterator to a const reorder_iterator, won't allow conversion from a const reorder_iterator to a reorder_iterator. More... | |
reorder_iterator< ElementIterator > | begin () const |
Returns a reorder_iterator pointing to the begining of the permutation. | |
reorder_iterator< ElementIterator > | end () const |
Returns a reorder_iterator pointing to the end of the permutation. | |
index_t | index () const |
Returns the index of the element that the iterator is currently pointing to. | |
Protected Attributes | |
index_container_ptr | m_index_collection |
Friends | |
class | boost::iterator_core_access |
Provides an iterator over a permutation of a range.
This class is a fork of boost::permutation_iterator. With boost::permutation_iterator, the user provides a population, and a range of index that defines a permutation over the population. It allows for much flexibility, but leaves the user responsible for storing an array of index. This class allows to store the array internally, in the same way as boost::shared_container_iterator.
The index array is stored within the iterator, by means of a boost::shared_ptr; thus, all copies of a reorder iterator share the same index array. One drawback is that reorder_iterator copy is somewhat slower than ElementIterator copy. Incrementation is still plainly efficient, nevertheless.
When iterating over a permutation of a population range using an index range, the iteration is actually performed over the index range; the population range is only used when dereferencing. Thus, every trsl::reorder_iterator knows where it begins and where it ends, hence provided begin() and end() methods.
TRSL provides several functions that generate reoder iterators for common reorderings. See random_permutation_iterator() and sort_iterator().
ElementIterator
should model Random Access Iterator. See the doc on boost::permutation_iterator for further details.
Definition at line 31 of file reorder_iterator.hpp.
|
inline |
Allows conversion from a reorder_iterator to a const reorder_iterator, won't allow conversion from a const reorder_iterator to a reorder_iterator.
By “const reorder_iterator”, we mean that the ElementIterator
is const, e.g. std::vector<Particle>::const_iterator
.
Definition at line 142 of file reorder_iterator.hpp.