Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions include/oneapi/dpl/pstl/utils_ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,18 @@ class zip_view

explicit zip_view(_Ranges... __args) : __m_ranges(__args...) {}

auto
begin() const
{
return __make_begin(std::make_index_sequence<__num_ranges>());
}

auto
end() const
{
return __make_end(std::make_index_sequence<__num_ranges>());
}

auto
size() const
{
Expand Down Expand Up @@ -387,6 +399,20 @@ class zip_view
}

private:
template <std::size_t... _Ip>
auto
__make_begin(std::index_sequence<_Ip...>) const
{
return oneapi::dpl::make_zip_iterator(oneapi::dpl::__ranges::__begin(std::get<_Ip>(__m_ranges))...);
}

template <std::size_t... _Ip>
auto
__make_end(std::index_sequence<_Ip...>) const
{
return oneapi::dpl::make_zip_iterator(oneapi::dpl::__ranges::__end(std::get<_Ip>(__m_ranges))...);
}

_tuple_ranges_t __m_ranges;
};

Expand Down Expand Up @@ -454,6 +480,18 @@ struct reverse_view_simple

reverse_view_simple(_R __rng) : __r(__rng) {}

auto
begin() const
{
return std::make_reverse_iterator(__begin(__r) + size());
}

auto
end() const
{
return std::make_reverse_iterator(__begin(__r));
}

//TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range
template <typename Idx>
auto operator[](Idx __i) const -> decltype(__r[__i])
Expand Down Expand Up @@ -495,6 +533,18 @@ struct take_view_simple
assert(__n >= 0 && __n <= oneapi::dpl::__ranges::__size(__r));
}

auto
begin() const
{
return __begin(__r);
}

auto
end() const
{
return __begin(__r) + __n;
}

//TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range
template <typename Idx>
auto operator[](Idx __i) const -> decltype(__r[__i])
Expand Down Expand Up @@ -591,6 +641,21 @@ struct replicate_start_view_simple
assert(__repl_count >= 0);
}

auto
begin() const
{
auto __map_fn = [__c = __repl_count](auto __i) -> decltype(__i) {
return __i < __c ? decltype(__i)(0) : __i - __c;
};
return oneapi::dpl::make_permutation_iterator(__begin(__r), __map_fn);
}

auto
end() const
{
return begin() + size();
}

//TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range
template <typename Idx>
auto operator[](Idx __i) const -> decltype(__r[__i])
Expand Down Expand Up @@ -627,6 +692,18 @@ struct transform_view_simple
_R __r;
_F __f;

auto
begin() const
{
return oneapi::dpl::make_transform_iterator(__begin(__r), __f);
}

auto
end() const
{
return begin() + size();
}

//TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range
template <typename Idx>
auto operator[](Idx __i) const -> decltype(__f(__r[__i]))
Expand Down Expand Up @@ -685,6 +762,21 @@ struct permutation_view_simple<_Source, _M, ::std::enable_if_t<oneapi::dpl::__in

permutation_view_simple(_Source __data, _M __m, _Size __s) : __src(__data), __map_fn(__m), __size(__s) {}

auto
begin() const
{
if constexpr (oneapi::dpl::__internal::__is_random_access_iterator_v<_Source>)
return oneapi::dpl::make_permutation_iterator(__src, __map_fn);
else
return oneapi::dpl::make_permutation_iterator(__begin(__src), __map_fn);
}

auto
end() const
{
return begin() + __size;
}

//TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range
template <typename Idx>
decltype(auto)
Expand Down Expand Up @@ -724,6 +816,21 @@ struct permutation_view_simple<_Source, _M, ::std::enable_if_t<is_map_view<_M>::

permutation_view_simple(_Source __data, _M __m) : __src(__data), __map(__m) {}

auto
begin() const
{
if constexpr (oneapi::dpl::__internal::__is_random_access_iterator_v<_Source>)
return oneapi::dpl::make_permutation_iterator(__src, __begin(__map));
else
return oneapi::dpl::make_permutation_iterator(__begin(__src), __begin(__map));
}

auto
end() const
{
return begin() + size();
}

//TODO: to be consistent with C++ standard, this Idx should be changed to diff_type of underlying range
template <typename Idx>
decltype(auto)
Expand Down
Loading