Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:56

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_EQUAL_HPP
0013 
0014 #include <boost/static_assert.hpp>
0015 
0016 #include <boost/compute/system.hpp>
0017 #include <boost/compute/command_queue.hpp>
0018 #include <boost/compute/algorithm/mismatch.hpp>
0019 #include <boost/compute/type_traits/is_device_iterator.hpp>
0020 
0021 namespace boost {
0022 namespace compute {
0023 
0024 /// Returns \c true if the range [\p first1, \p last1) and the range
0025 /// beginning at \p first2 are equal.
0026 ///
0027 /// Space complexity: \Omega(1)
0028 template<class InputIterator1, class InputIterator2>
0029 inline bool equal(InputIterator1 first1,
0030                   InputIterator1 last1,
0031                   InputIterator2 first2,
0032                   command_queue &queue = system::default_queue())
0033 {
0034     BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
0035     BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
0036     return ::boost::compute::mismatch(first1,
0037                                       last1,
0038                                       first2,
0039                                       queue).first == last1;
0040 }
0041 
0042 /// \overload
0043 template<class InputIterator1, class InputIterator2>
0044 inline bool equal(InputIterator1 first1,
0045                   InputIterator1 last1,
0046                   InputIterator2 first2,
0047                   InputIterator2 last2,
0048                   command_queue &queue = system::default_queue())
0049 {
0050     BOOST_STATIC_ASSERT(is_device_iterator<InputIterator1>::value);
0051     BOOST_STATIC_ASSERT(is_device_iterator<InputIterator2>::value);
0052     if(std::distance(first1, last1) != std::distance(first2, last2)){
0053         return false;
0054     }
0055 
0056     return ::boost::compute::equal(first1, last1, first2, queue);
0057 }
0058 
0059 } // end compute namespace
0060 } // end boost namespace
0061 
0062 #endif // BOOST_COMPUTE_ALGORITHM_EQUAL_HPP