hpx/parallel/container_algorithms/unique.hpp#

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace ranges

Functions

template<typename FwdIter, typename Sent, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
subrange_t<FwdIter, Sent> unique(FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())#

Eliminates all but the first element from every consecutive group of equivalent elements from the range [first, last) and returns a past-the-end iterator for the new logical end of the range.

The assignments in the parallel unique algorithm invoked without an execution policy object execute in sequential order in the calling thread.

Note

Complexity: Performs not more than last - first assignments, exactly last - first - 1 applications of the predicate pred and no more than twice as many applications of the projection proj.

Template Parameters
  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1 and Type2 must be such that objects of types FwdIter can be dereferenced and then implicitly converted to both Type1 and Type2

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique algorithm returns subrange_t<FwdIter, Sent>. The unique algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange.

template<typename ExPolicy, typename FwdIter, typename Sent, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<FwdIter, Sent>>::type unique(ExPolicy &&policy, FwdIter first, Sent last, Pred &&pred = Pred(), Proj &&proj = Proj())#

Eliminates all but the first element from every consecutive group of equivalent elements from the range [first, last) and returns a past-the-end iterator for the new logical end of the range.

The assignments in the parallel unique algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The assignments in the parallel unique algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note

Complexity: Performs not more than last - first assignments, exactly last - first - 1 applications of the predicate pred and no more than twice as many applications of the projection proj.

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter.

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type1 &a, const Type2 &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The types Type1 and Type2 must be such that objects of types FwdIter can be dereferenced and then implicitly converted to both Type1 and Type2

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique algorithm returns subrange_t<FwdIter, Sent>. The unique algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange.

template<typename Rng, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
subrange_t<hpx::traits::range_iterator_t<Rng>, hpx::traits::range_iterator_t<Rng>> unique(Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())#

Eliminates all but the first element from every consecutive group of equivalent elements from the range rng and returns a past-the-end iterator for the new logical end of the range.

The assignments in the parallel unique algorithm invoked without an execution policy object execute in sequential order in the calling thread.

Note

Complexity: Performs not more than N assignments, exactly N - 1 applications of the predicate pred and no more than twice as many applications of the projection proj, where N = std::distance(begin(rng), end(rng)).

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type &a, const Type &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique algorithm returns subrange_t<typename hpx::traits::range_iterator_t<Rng>, hpx::traits::range_iterator_t<Rng>>. The unique algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange.

template<typename ExPolicy, typename Rng, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, subrange_t<hpx::traits::range_iterator_t<Rng>, hpx::traits::range_iterator_t<Rng>>>::type unique(ExPolicy &&policy, Rng &&rng, Pred &&pred = Pred(), Proj &&proj = Proj())#

Eliminates all but the first element from every consecutive group of equivalent elements from the range rng and returns a past-the-end iterator for the new logical end of the range.

The assignments in the parallel unique algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The assignments in the parallel unique algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note

Complexity: Performs not more than N assignments, exactly N - 1 applications of the predicate pred and no more than twice as many applications of the projection proj, where N = std::distance(begin(rng), end(rng)).

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type &a, const Type &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique algorithm returns a hpx::future <subrange_t<hpx::traits::range_iterator_t<Rng>, hpx::traits::range_iterator_t<Rng>>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns subrange_t<typename hpx::traits::range_iterator<Rng>::type, hpx::traits::range_iterator_t<Rng>> otherwise. The unique algorithm returns an object {ret, last}, where ret is a past-the-end iterator for a new subrange.

template<typename InIter, typename Sent, typename O, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
unique_copy_result<InIter, O> unique_copy(InIter first, Sent last, O dest, Pred &&pred = Pred(), Proj &&proj = Proj())#

Copies the elements from the range [first, last), to another range beginning at dest in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

The assignments in the parallel unique_copy algorithm invoked without an execution policy object will execute in sequential order in the calling thread.

Note

Complexity: Performs not more than last - first assignments, exactly last - first - 1 applications of the predicate pred and no more than twice as many applications of the projection proj

Template Parameters
  • InIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for InIter.

  • O – The type of the iterator representing the destination range (deduced).

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique_copy requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • dest – Refers to the beginning of the destination range.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type &a, const Type &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type InIter1 can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique_copy algorithm returns a returns unique_copy_result<InIter, O>. The unique_copy algorithm returns an in_out_result with the source iterator to one past the last element and out containing the destination iterator to the end of the dest range.

template<typename ExPolicy, typename FwdIter, typename Sent, typename O, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, unique_copy_result<FwdIter, O>>::type unique_copy(ExPolicy &&policy, FwdIter first, Sent last, O dest, Pred &&pred = Pred(), Proj &&proj = Proj())#

Copies the elements from the range [first, last), to another range beginning at dest in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

The assignments in the parallel unique_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The assignments in the parallel unique_copy algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note

Complexity: Performs not more than last - first assignments, exactly last - first - 1 applications of the predicate pred and no more than twice as many applications of the projection proj

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • FwdIter – The type of the source iterators used (deduced). This iterator type must meet the requirements of a forward iterator.

  • Sent – The type of the source sentinel (deduced). This sentinel type must be a sentinel for FwdIter1.

  • O – The type of the iterator representing the destination range (deduced).

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique_copy requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • first – Refers to the beginning of the sequence of elements the algorithm will be applied to.

  • last – Refers to sentinel value denoting the end of the sequence of elements the algorithm will be applied.

  • dest – Refers to the beginning of the destination range.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by [first, last). This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type &a, const Type &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique_copy algorithm returns areturns hpx::future< unique_copy_result<FwdIter, O>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns unique_copy_result<FwdIter, O> otherwise. The unique_copy algorithm returns an in_out_result with the source iterator to one past the last element and out containing the destination iterator to the end of the dest range.

template<typename Rng, typename O, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
unique_copy_result<hpx::traits::range_iterator_t<Rng>, O> unique_copy(Rng &&rng, O dest, Pred &&pred = Pred(), Proj &&proj = Proj())#

Copies the elements from the range rng, to another range beginning at dest in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

The assignments in the parallel unique_copy algorithm invoked without an execution policy object will execute in sequential order in the calling thread.

Note

Complexity: Performs not more than N assignments, exactly N - 1 applications of the predicate pred, where N = std::distance(begin(rng), end(rng)).

Template Parameters
  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • O – The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique_copy requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • dest – Refers to the beginning of the destination range.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by the range rng. This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type &a, const Type &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique_copy algorithm returns unique_copy_result< hpx::traits::range_iterator_t<Rng>, O>. The unique_copy algorithm returns the pair of the source iterator to last, and the destination iterator to the end of the dest range.

template<typename ExPolicy, typename Rng, typename O, typename Pred = ranges::equal_to, typename Proj = parallel::util::projection_identity>
parallel::util::detail::algorithm_result<ExPolicy, unique_copy_result<hpx::traits::range_iterator_t<Rng>, O>>::type unique_copy(ExPolicy &&policy, Rng &&rng, O dest, Pred &&pred = Pred(), Proj &&proj = Proj())#

Copies the elements from the range rng, to another range beginning at dest in such a way that there are no consecutive equal elements. Only the first element of each group of equal elements is copied.

The assignments in the parallel unique_copy algorithm invoked with an execution policy object of type sequenced_policy execute in sequential order in the calling thread.

The assignments in the parallel unique_copy algorithm invoked with an execution policy object of type parallel_policy or parallel_task_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

Note

Complexity: Performs not more than N assignments, exactly N - 1 applications of the predicate pred, where N = std::distance(begin(rng), end(rng)).

Template Parameters
  • ExPolicy – The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

  • Rng – The type of the source range used (deduced). The iterators extracted from this range type must meet the requirements of an forward iterator.

  • O – The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of a forward iterator.

  • Pred – The type of the function/function object to use (deduced). Unlike its sequential form, the parallel overload of unique_copy requires Pred to meet the requirements of CopyConstructible. This defaults to std::equal_to<>

  • Proj – The type of an optional projection function. This defaults to util::projection_identity

Parameters
  • policy – The execution policy to use for the scheduling of the iterations.

  • rng – Refers to the sequence of elements the algorithm will be applied to.

  • dest – Refers to the beginning of the destination range.

  • pred – Specifies the function (or function object) which will be invoked for each of the elements in the sequence specified by the range rng. This is an binary predicate which returns true for the required elements. The signature of this predicate should be equivalent to:

    bool pred(const Type &a, const Type &b);
    
    The signature does not need to have const&, but the function must not modify the objects passed to it. The type Type must be such that an object of type FwdIter1 can be dereferenced and then implicitly converted to Type.

  • proj – Specifies the function (or function object) which will be invoked for each of the elements as a projection operation before the actual predicate is invoked.

Returns

The unique_copy algorithm returns a hpx::future<unique_copy_result< hpx::traits::range_iterator_t<Rng>, O>> if the execution policy is of type sequenced_task_policy or parallel_task_policy and returns unique_copy_result< hpx::traits::range_iterator_t<Rng>, O> otherwise. The unique_copy algorithm returns the pair of the source iterator to last, and the destination iterator to the end of the dest range.