partition.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013 Kyle Lutz <[email protected]>
  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. #ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_HPP
  11. #define BOOST_COMPUTE_ALGORITHM_PARTITION_HPP
  12. #include <boost/static_assert.hpp>
  13. #include <boost/compute/system.hpp>
  14. #include <boost/compute/command_queue.hpp>
  15. #include <boost/compute/algorithm/stable_partition.hpp>
  16. #include <boost/compute/type_traits/is_device_iterator.hpp>
  17. namespace boost {
  18. namespace compute {
  19. ///
  20. /// Partitions the elements in the range [\p first, \p last) according to
  21. /// \p predicate. Order of the elements need not be preserved.
  22. ///
  23. /// Space complexity: \Omega(3n)
  24. ///
  25. /// \see is_partitioned() and stable_partition()
  26. ///
  27. template<class Iterator, class UnaryPredicate>
  28. inline Iterator partition(Iterator first,
  29. Iterator last,
  30. UnaryPredicate predicate,
  31. command_queue &queue = system::default_queue())
  32. {
  33. BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
  34. return stable_partition(first, last, predicate, queue);
  35. }
  36. } // end compute namespace
  37. } // end boost namespace
  38. #endif // BOOST_COMPUTE_ALGORITHM_PARTITION_HPP