partition_point.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2014 Roshan <thisisroshansmail@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. #ifndef BOOST_COMPUTE_ALGORITHM_PARTITION_POINT_HPP
  11. #define BOOST_COMPUTE_ALGORITHM_PARTITION_POINT_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/detail/binary_find.hpp>
  16. #include <boost/compute/type_traits/is_device_iterator.hpp>
  17. namespace boost {
  18. namespace compute {
  19. ///
  20. /// \brief Partition point algorithm
  21. ///
  22. /// Finds the end of true values in the partitioned range [first, last)
  23. /// \return Iterator pointing to end of true values
  24. ///
  25. /// \param first Iterator pointing to start of range
  26. /// \param last Iterator pointing to end of range
  27. /// \param predicate Unary predicate to be applied on each element
  28. /// \param queue Queue on which to execute
  29. ///
  30. /// Space complexity: \Omega(1)
  31. ///
  32. /// \see partition() and stable_partition()
  33. ///
  34. template<class InputIterator, class UnaryPredicate>
  35. inline InputIterator partition_point(InputIterator first,
  36. InputIterator last,
  37. UnaryPredicate predicate,
  38. command_queue &queue = system::default_queue())
  39. {
  40. BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
  41. return detail::binary_find(first, last, not1(predicate), queue);
  42. }
  43. } // end compute namespace
  44. } // end boost namespace
  45. #endif // BOOST_COMPUTE_ALGORITHM_PARTITION_POINT_HPP