]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/algorithm/partition_copy.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / algorithm / partition_copy.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
12 #define BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/functional.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/algorithm/copy_if.hpp>
18
19 namespace boost {
20 namespace compute {
21
22 /// Copies all of the elements in the range [\p first, \p last) for which
23 /// \p predicate returns \c true to the range beginning at \p first_true
24 /// and all of the elements for which \p predicate returns \c false to
25 /// the range beginning at \p first_false.
26 ///
27 /// \see partition()
28 template<class InputIterator,
29 class OutputIterator1,
30 class OutputIterator2,
31 class UnaryPredicate>
32 inline std::pair<OutputIterator1, OutputIterator2>
33 partition_copy(InputIterator first,
34 InputIterator last,
35 OutputIterator1 first_true,
36 OutputIterator2 first_false,
37 UnaryPredicate predicate,
38 command_queue &queue = system::default_queue())
39 {
40 // copy true values
41 OutputIterator1 last_true =
42 ::boost::compute::copy_if(first,
43 last,
44 first_true,
45 predicate,
46 queue);
47
48 // copy false values
49 OutputIterator2 last_false =
50 ::boost::compute::copy_if(first,
51 last,
52 first_false,
53 not1(predicate),
54 queue);
55
56 // return iterators to the end of the true and the false ranges
57 return std::make_pair(last_true, last_false);
58 }
59
60 } // end compute namespace
61 } // end boost namespace
62
63 #endif // BOOST_COMPUTE_ALGORITHM_PARTITION_COPY_HPP