equal.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
  11. #define BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
  12. #include <boost/compute/system.hpp>
  13. #include <boost/compute/command_queue.hpp>
  14. #include <boost/compute/algorithm/mismatch.hpp>
  15. namespace boost {
  16. namespace compute {
  17. /// Returns \c true if the range [\p first1, \p last1) and the range
  18. /// beginning at \p first2 are equal.
  19. template<class InputIterator1, class InputIterator2>
  20. inline bool equal(InputIterator1 first1,
  21. InputIterator1 last1,
  22. InputIterator2 first2,
  23. command_queue &queue = system::default_queue())
  24. {
  25. return ::boost::compute::mismatch(first1,
  26. last1,
  27. first2,
  28. queue).first == last1;
  29. }
  30. /// \overload
  31. template<class InputIterator1, class InputIterator2>
  32. inline bool equal(InputIterator1 first1,
  33. InputIterator1 last1,
  34. InputIterator2 first2,
  35. InputIterator2 last2,
  36. command_queue &queue = system::default_queue())
  37. {
  38. if(std::distance(first1, last1) != std::distance(first2, last2)){
  39. return false;
  40. }
  41. return ::boost::compute::equal(first1, last1, first2, queue);
  42. }
  43. } // end compute namespace
  44. } // end boost namespace
  45. #endif // BOOST_COMPUTE_ALGORITHM_EQUAL_HPP