39 #ifndef ECUDA_ALGO_LEXICOGRAPHICAL_COMPARE_HPP
40 #define ECUDA_ALGO_LEXICOGRAPHICAL_COMPARE_HPP
46 #include "../global.hpp"
47 #include "../allocators.hpp"
48 #include "../iterator.hpp"
49 #include "../utility.hpp"
59 template<
class InputIterator1,
class InputIterator2>
62 InputIterator2 first2, InputIterator2 last2,
63 pair<ecuda::false_type,ecuda::false_type>
73 template<
class InputIterator1,
class InputIterator2>
76 InputIterator2 first2, InputIterator2 last2,
77 pair<ecuda::true_type,ecuda::false_type>
87 template<
class InputIterator1,
class InputIterator2>
90 InputIterator2 first2, InputIterator2 last2,
91 pair<ecuda::false_type,ecuda::true_type>
97 typedef typename ecuda::remove_const<typename ecuda::iterator_traits<InputIterator2>::value_type>::type value_type;
101 const bool isSomeKindOfContiguous =
102 ecuda::is_same<iterator_contiguity,ecuda::true_type>::value ||
103 ecuda::is_same<iterator_category,device_contiguous_block_iterator_tag>::value;
104 ECUDA_STATIC_ASSERT(isSomeKindOfContiguous,CANNOT_LEXICOGRAPHICALLY_COMPARE_RANGE_REPRESENTED_BY_NONCONTIGUOUS_DEVICE_MEMORY);
106 std::vector< value_type, host_allocator<value_type> > v( ::
ecuda::distance(first2,last2) );
113 template<
class InputIterator1,
class InputIterator2>
116 InputIterator2 first2, InputIterator2 last2,
117 pair<ecuda::true_type,ecuda::true_type>
121 for( ; (first1 != last1) and (first2 != last2); ++first1, ++first2 ) {
122 if( *first1 < *first2 )
return true;
123 if( *first2 < *first1 )
return false;
125 return (first1 == last1) and (first2 != last2);
128 typedef typename ecuda::remove_const<typename ecuda::iterator_traits<InputIterator1>::value_type>::type valtype1;
129 typedef typename ecuda::remove_const<typename ecuda::iterator_traits<InputIterator2>::value_type>::type valtype2;
130 std::vector< valtype1, host_allocator<valtype1> > v1(
ecuda::distance( first1, last1 ) );
131 std::vector< valtype2, host_allocator<valtype2> > v2(
ecuda::distance( first2, last2 ) );
142 template<
class InputIterator1,
class InputIterator2>
__HOST__ __DEVICE__ OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result)
Replacement for std::copy.
base_type::iterator_category iterator_category
ecuda::false_type is_device_iterator
Couples together a pair of values.
#define ECUDA_STATIC_ASSERT(x, msg)
__HOST__ __DEVICE__ bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
#define ECUDA_SUPPRESS_HD_WARNINGS
ECUDA_SUPPRESS_HD_WARNINGS __HOST__ __DEVICE__ bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
ECUDA_SUPPRESS_HD_WARNINGS __HOST__ __DEVICE__ std::iterator_traits< Iterator >::difference_type distance(const Iterator &first, const Iterator &last)