Skip to content

Commit

Permalink
Clarify the assosition between keys and values
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Sobolev <[email protected]>
  • Loading branch information
dmitriy-sobolev committed Sep 2, 2024
1 parent 6ee3677 commit ef9f079
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions source/elements/oneDPL/source/parallel_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,12 @@ The elements e of [start, end) must be partitioned with respect to the comparato
InputValueIt values_first, Comparator comp =
std::less<typename std::iterator_traits<InputKeyIt>::value_type>());
``oneapi::dpl::sort_by_key`` sorts a sequence of keys in the range ``[keys_first, keys_last)``,
and permutes a sequence of values in the range
``[values_first, values_first + distance(keys_first, keys_last))`` to match the order of the sorted keys.
``oneapi::dpl::sort_by_key`` sorts a sequence of keys within the range ``[keys_first, keys_last)``.
It also permutes the corresponding sequence of values within the range
``[values_first, values_first + distance(keys_first, keys_last))``.
Each key is associated with a corresponding value,
and this association is maintained throughout the sorting process.

The order of equal keys is not guaranteed to be preserved.

If no comparator is provided, the keys are sorted with respect to ``std::less{}``.
Expand All @@ -715,9 +718,12 @@ If no comparator is provided, the keys are sorted with respect to ``std::less{}`
InputValueIt values_first, Comparator comp =
std::less<typename std::iterator_traits<InputKeyIt>::value_type>());
``oneapi::dpl::stable_sort_by_key`` sorts a sequence of keys in the range ``[keys_first, keys_last)``,
and permutes a sequence of values in the range
``[values_first, values_first + distance(keys_first, keys_last))`` to match the order of the sorted keys.
``oneapi::dpl::stable_sort_by_key`` sorts a sequence of keys within the range ``[keys_first, keys_last)``.
It also permutes the corresponding sequence of values within the range
``[values_first, values_first + distance(keys_first, keys_last))``.
Each key is associated with a corresponding value,
and this association is maintained throughout the sorting process.

The order of equal keys is preserved.

If no comparator is provided, the keys are sorted with respect to ``std::less{}``.
Expand Down

0 comments on commit ef9f079

Please sign in to comment.