itertools::chunk_range

#include <itertools.hpp>

Synopsis

std::pair<std::ptrdiff_t, std::ptrdiff_t> chunk_range (std::ptrdiff_t start,
std::ptrdiff_t end,
long n_chunks,
long rank)

Given an integer range [start, end), chunk it as equally as possible into n_chunks. If the range is not dividable in n_chunks equal parts, the first chunks have one more element than the last ones.