Iterator over all possible indexes in a given range.
More...
#include <IndexIterator.h>
|
| | IndexIterator (T max_value) |
| | Construct an index iterator with size given by max_value.size().
|
| |
| | IndexIterator (T min_value, T max_value) |
| | Construct an index iterator with size given by max_value.size().
|
| |
| | IndexIterator (std::size_t size, T max_value) |
| | Construct an index iterator with the given size.
|
| |
| | IndexIterator (std::size_t size, T min_value, T max_value) |
| | Construct an index iterator with the given size.
|
| |
| IndexIterator & | reset () |
| | Reset the iterator to the initial state.
|
| |
| IndexIterator & | operator++ () |
| | Increment the iterator.
|
| |
| const std::vector< Index > & | indexes () const |
| | Get read-only access to the whole vector of indexes of the index iterator.
|
| |
| Index | operator[] (const std::size_t index) const |
| | Get read-only access to the index element of the index iterator.
|
| |
| | operator bool () const |
| | Check whether the index iterator is done iterating, having gone over all valid indexes.
|
| |
|
| static IndexIterator< T > | end () |
| | Create an exhausted index iterator by assigning the same value to both min and max: 0.
|
| |
|
|
T | min_value_ |
| | Minimum value for each index. Inclusive.
|
| |
|
T | max_value_ |
| | Maximum value for each index. Exclusive.
|
| |
|
std::vector< Index > | indexes_ |
| | Current indexes.
|
| |
template<IsAnyOf< Index, std::vector< Index > > T>
class lucid::IndexIterator< T >
Iterator over all possible indexes in a given range.
It also supports individual range for each index.
std::cout << it[0] << it[1] << it[2] << std::endl;
}
for (
IndexIterator<std::vector<Index>> it{{0, -1, 0}, {4, 2, 2}}; it; ++it) {
std::cout << it[0] << it[1] << it[2] << std::endl;
}
IndexIterator(T max_value)
Construct an index iterator with size given by max_value.size().
Definition IndexIterator.cpp:42
- Template Parameters
-
| T | type of the range. It can be a single value or a vector of values. |
◆ IndexIterator() [1/4]
template<IsAnyOf< Index, std::vector< Index > > T>
requires std::is_same_v<T, std::vector<Index>>
Construct an index iterator with size given by max_value.size().
Each of the indexes will go from [0 to max_value[i] - 1] (inclusive).
- Parameters
-
| max_value | maximum value for each index |
◆ IndexIterator() [2/4]
template<IsAnyOf< Index, std::vector< Index > > T>
requires std::is_same_v<T, std::vector<Index>>
Construct an index iterator with size given by max_value.size().
Each of the indexes will go from [min_value[i] to max_value[i] - 1] (inclusive).
- Parameters
-
| min_value | minimum value for each index |
| max_value | maximum value for each index |
◆ IndexIterator() [3/4]
template<IsAnyOf< Index, std::vector< Index > > T>
requires std::is_same_v<T, Index>
Construct an index iterator with the given size.
Each of the indexes will go from [0 to max_value - 1] (inclusive).
- Parameters
-
| size | number of indexes |
| max_value | maximum value for each index |
◆ IndexIterator() [4/4]
template<IsAnyOf< Index, std::vector< Index > > T>
requires std::is_same_v<T, Index>
Construct an index iterator with the given size.
Each of the indexes will go from [min_value to max_value - 1] (inclusive).
- Parameters
-
| size | number of indexes |
| min_value | minimum value for each index |
| max_value | maximum value for each index |
◆ end()
template<IsAnyOf< Index, std::vector< Index > > T>
Create an exhausted index iterator by assigning the same value to both min and max: 0.
Useful to create something cheap to indicate that there is nothing to iterate.
- Returns
- index iterator already exhausted
◆ indexes()
template<IsAnyOf< Index, std::vector< Index > > T>
Get read-only access to the whole vector of indexes of the index iterator.
- Returns
- whole vector of indexes of the index iterator
◆ operator bool()
template<IsAnyOf< Index, std::vector< Index > > T>
Check whether the index iterator is done iterating, having gone over all valid indexes.
- Returns
- true if the index iterator is done iterating, having gone over all valid indexes
-
false if the index iterator is not done iterating, having gone over all valid indexes
◆ operator++()
template<IsAnyOf< Index, std::vector< Index > > T>
Increment the iterator.
Go to the next index.
- Returns
- reference to the iterator
◆ operator[]()
template<IsAnyOf< Index, std::vector< Index > > T>
Get read-only access to the index element of the index iterator.
- Returns
- index element of the index iterator
◆ reset()
template<IsAnyOf< Index, std::vector< Index > > T>
Reset the iterator to the initial state.
- Returns
- reference to the iterator
The documentation for this class was generated from the following files: