|
TRIQS/itertools 2.0.0
C++ range library
|
Utilities are mostly internal implementation details and should not concern everyday users.
The only functions that might be interesting to some users are: chunk_range, make_vector_from_range and omp_chunk.
Classes | |
| struct | itertools::iterator_facade< Iter, Value, std::forward_iterator_tag, Reference, Difference > |
| CRTP base class for various iterator types in itertools. More... | |
| struct | itertools::sentinel_t< Iter > |
| Generic sentinel type that can be used to mark the end of a range. More... | |
Functions | |
| std::pair< std::ptrdiff_t, std::ptrdiff_t > | itertools::chunk_range (std::ptrdiff_t first, std::ptrdiff_t last, long n_chunks, long rank) |
| Given an integer range [first, last), divide it as equally as possible into N chunks. | |
| template<typename Iter1, typename Iter2> | |
| std::iterator_traits< Iter1 >::difference_type | itertools::distance (Iter1 first, Iter2 last) |
| Calculate the distance between two iterators. | |
| template<typename Iter> | |
| sentinel_t< Iter > | itertools::make_sentinel (Iter it) |
| Create an itertools::sentinel_t from an iterator using template type deduction. | |
| template<typename R> | |
| auto | itertools::make_vector_from_range (R const &rg) |
| Create a vector from a range. | |
| template<typename R> | |
| auto | itertools::omp_chunk (R &&rg) |
| Distribute a range as evenly as possible across all OMP threads. | |
|
inlinenodiscard |
#include <itertools/utils.hpp>
Given an integer range [first, last), divide it as equally as possible into N chunks.
It is intended to divide a range among different processes. If the size of the range is not divisible by \( N \) without a remainder, i.e. r = (last - first) % N, then the first r chunks have one more element.
| first | First value of the range. |
| last | Last value of the range (excluded). |
| n_chunks | Number of chunks to divide the range into. |
| rank | Rank of the calling process. |
|
inlinenodiscard |
#include <itertools/utils.hpp>
Calculate the distance between two iterators.
It is similar to std::distance, except that it can be used for two different iterator types, e.g. in case one of them is a const iterator.
| Iter1 | Iterator type #1. |
| Iter2 | Iterator type #2. |
| first | Iterator #1. |
| last | Iterator #2. |
|
nodiscard |
#include <itertools/sentinel.hpp>
Create an itertools::sentinel_t from an iterator using template type deduction.
| Iter | Iterator type. |
| it | Iterator to be turned into an itertools::sentinel_t. |
Definition at line 50 of file sentinel.hpp.
|
nodiscard |
#include <itertools/utils.hpp>
Create a vector from a range.
| R | Range type. |
| rg | Range. |
| auto itertools::omp_chunk | ( | R && | rg | ) |
#include <itertools/omp_chunk.hpp>
Distribute a range as evenly as possible across all OMP threads.
See chunk_range(std::ptrdiff_t, std::ptrdiff_t, long, long) and slice(R &&, std::ptrdiff_t, std::ptrdiff_t) for more details.
| R | Range type. |
| rg | Range to chunk. |
Definition at line 41 of file omp_chunk.hpp.