Skip to content

Commit

Permalink
Container version of move
Browse files Browse the repository at this point in the history
  • Loading branch information
brjsp committed Dec 1, 2017
1 parent 964b573 commit ddbc8f9
Show file tree
Hide file tree
Showing 4 changed files with 543 additions and 0 deletions.
1 change: 1 addition & 0 deletions hpx/include/parallel_move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define HPX_PARALLEL_MOVE_JUN_28_2014_0827AM

#include <hpx/parallel/algorithms/move.hpp>
#include <hpx/parallel/container_algorithms/move.hpp>

#endif

90 changes: 90 additions & 0 deletions hpx/parallel/container_algorithms/move.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) 2017 Bruno Pitrus
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

/// \file parallel/container_algorithms/move.hpp

#if !defined(HPX_PARALLEL_CONTAINER_ALGORITHM_MOVE_26_NOV_2017_1248PM)
#define HPX_PARALLEL_CONTAINER_ALGORITHM_MOVE_26_NOV_2017_1248PM

#include <hpx/config.hpp>
#include <hpx/traits/concepts.hpp>
#include <hpx/traits/is_iterator.hpp>
#include <hpx/traits/is_range.hpp>
#include <hpx/util/range.hpp>
#include <hpx/util/tagged_pair.hpp>

#include <hpx/parallel/algorithms/move.hpp>

#include <type_traits>
#include <utility>

namespace hpx { namespace parallel { inline namespace v1
{
/// Moves the elements in the range \a rng to another range beginning
/// at \a dest. After this operation the elements in the moved-from
/// range will still contain valid values of the appropriate type,
/// but not necessarily the same values as before the move.
///
/// \note Complexity: Performs exactly
/// std::distance(begin(rng), end(rng)) assignments.
///
/// \tparam 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.
/// \tparam Rng The type of the source range used (deduced).
/// The iterators extracted from this range type must
/// meet the requirements of an input iterator.
/// \tparam OutIter The type of the iterator representing the
/// destination range (deduced).
/// This iterator type must meet the requirements of an
/// output iterator.
///
/// \param policy The execution policy to use for the scheduling of
/// the iterations.
/// \param rng Refers to the sequence of elements the algorithm
/// will be applied to.
/// \param dest Refers to the beginning of the destination range.
///
/// The assignments in the parallel \a copy algorithm invoked with an
/// execution policy object of type \a sequenced_policy
/// execute in sequential order in the calling thread.
///
/// The assignments in the parallel \a copy algorithm invoked with
/// an execution policy object of type \a parallel_policy or
/// \a parallel_task_policy are permitted to execute in an unordered
/// fashion in unspecified threads, and indeterminately sequenced
/// within each thread.
///
/// \returns The \a move algorithm returns a
/// \a hpx::future<tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> > if the execution policy is of type
/// \a sequenced_task_policy or \a parallel_task_policy and
/// returns \a tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> otherwise.
/// The \a move algorithm returns the pair of the input iterator
/// \a last and the output iterator to the element in the
/// destination range, one past the last element moved.
///
template <typename ExPolicy, typename Rng, typename OutIter,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_range<Rng>::value &&
hpx::traits::is_iterator<OutIter>::value)>
typename util::detail::algorithm_result<
ExPolicy,
hpx::util::tagged_pair<
tag::in(typename hpx::traits::range_traits<Rng>::iterator_type),
tag::out(OutIter)
>
>::type
move(ExPolicy && policy, Rng && rng, OutIter dest)
{
return move(std::forward<ExPolicy>(policy),
hpx::util::begin(rng), hpx::util::end(rng), dest);
}
}}}

#endif
1 change: 1 addition & 0 deletions tests/unit/parallel/container_algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(tests
merge_range
min_element_range
minmax_element_range
move_range
none_of_range
partition_range
partition_copy_range
Expand Down
Loading

0 comments on commit ddbc8f9

Please sign in to comment.