Utilities are mostly internal implementation details and should not concern everyday users.
The only functions the might be intersting to some users are: chunk_range, make_vector_from_range and omp_chunk.
|
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.
|
|
◆ chunk_range()
std::pair< std::ptrdiff_t, std::ptrdiff_t > itertools::chunk_range |
( |
std::ptrdiff_t | first, |
|
|
std::ptrdiff_t | last, |
|
|
long | n_chunks, |
|
|
long | rank ) |
|
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.
- Parameters
-
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. |
- Returns
- Pair of indices specifying the first and last (excluded) value of the chunk assigned to the calling process.
Definition at line 92 of file utils.hpp.
◆ distance()
template<typename Iter1 , typename Iter2 >
std::iterator_traits< Iter1 >::difference_type itertools::distance |
( |
Iter1 | first, |
|
|
Iter2 | last ) |
|
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.
- Template Parameters
-
Iter1 | Iterator type #1. |
Iter2 | Iterator type #2. |
- Parameters
-
first | Iterator #1. |
last | Iterator #2. |
- Returns
- Number of elements between the two iterators.
Definition at line 51 of file utils.hpp.
◆ make_sentinel()
template<typename Iter >
sentinel_t< Iter > itertools::make_sentinel |
( |
Iter | it | ) |
|
|
nodiscard |
◆ make_vector_from_range()
template<typename R >
auto itertools::make_vector_from_range |
( |
R const & | rg | ) |
|
|
nodiscard |
#include <itertools/utils.hpp>
Create a vector from a range.
- Template Parameters
-
- Parameters
-
- Returns
- std::vector<T> containing the elements of the range, where T denotes the value type of the range.
Definition at line 69 of file utils.hpp.
◆ omp_chunk()
template<typename R >
auto itertools::omp_chunk |
( |
R && | rg | ) |
|