1 #ifndef DASH__ALGORITHM__GENERATE_H__ 2 #define DASH__ALGORITHM__GENERATE_H__ 4 #include <dash/algorithm/LocalRange.h> 5 #include <dash/algorithm/Operation.h> 6 #include <dash/iterator/GlobIter.h> 31 template <
typename GlobInputIt,
class UnaryFunction>
42 iterator_traits::is_global_iterator::value,
43 "must be a global iterator");
46 auto lfirst = lrange.begin;
47 auto llast = lrange.end;
70 template <
typename GlobInputIt,
class UnaryFunction>
81 iterator_traits::is_global_iterator::value,
82 "must be a global iterator");
85 auto lbegin_index = index_range.begin;
86 auto lend_index = index_range.end;
88 if (lbegin_index != lend_index) {
90 auto& pattern = first.pattern();
91 auto first_offset = first.pos();
93 for (
auto lindex = lbegin_index; lindex != lend_index; ++lindex) {
94 auto gindex = pattern.global(lindex);
95 auto element_it = first + (gindex - first_offset);
96 *element_it = gen(gindex);
103 #endif // DASH__ALGORITHM__GENERATE_H__ This class is a simple memory pool which holds allocates elements of size ValueType.
LocalRange< const typename GlobIterType::value_type > local_range(const GlobIterType &first, const GlobIterType &last)
Resolves the local address range between global iterators.
void generate_with_index(GlobInputIt first, GlobInputIt last, UnaryFunction gen)
Assigns each element in range [first, last) a value generated by the given function object g...
void generate(GlobInputIt first, GlobInputIt last, UnaryFunction gen)
Assigns each element in range [first, last) a value generated by the given function object g...
std::enable_if< !GlobInputIter::has_view::value, LocalIndexRange< typename GlobInputIter::pattern_type::index_type >>::type local_index_range(const GlobInputIter &first, const GlobInputIter &last)
Resolves the local index range between global iterators.