41
template<typename RandomAccessIterator>
41
template<typename ExecutionPolicy,
42
typename RandomAccessIterator>
43
void sort(thrust::execution_policy<ExecutionPolicy> &exec,
43
44
RandomAccessIterator first,
44
45
RandomAccessIterator last)
46
47
typedef typename thrust::iterator_value<RandomAccessIterator>::type value_type;
47
thrust::sort(first, last, thrust::less<value_type>());
48
thrust::sort(exec, first, last, thrust::less<value_type>());
51
template<typename RandomAccessIterator,
52
template<typename ExecutionPolicy,
53
typename RandomAccessIterator,
52
54
typename StrictWeakOrdering>
55
void sort(thrust::execution_policy<ExecutionPolicy> &exec,
54
56
RandomAccessIterator first,
55
57
RandomAccessIterator last,
56
58
StrictWeakOrdering comp)
58
60
// implement with stable_sort
59
thrust::stable_sort(first,last,comp);
61
thrust::stable_sort(exec, first, last, comp);
63
template<typename RandomAccessIterator1,
65
template<typename ExecutionPolicy,
66
typename RandomAccessIterator1,
64
67
typename RandomAccessIterator2>
68
void sort_by_key(thrust::execution_policy<ExecutionPolicy> &exec,
66
69
RandomAccessIterator1 keys_first,
67
70
RandomAccessIterator1 keys_last,
68
71
RandomAccessIterator2 values_first)
70
73
typedef typename thrust::iterator_value<RandomAccessIterator1>::type value_type;
71
thrust::sort_by_key(keys_first, keys_last, values_first, thrust::less<value_type>());
74
thrust::sort_by_key(exec, keys_first, keys_last, values_first, thrust::less<value_type>());
72
75
} // end sort_by_key()
75
template<typename RandomAccessIterator1,
78
template<typename ExecutionPolicy,
79
typename RandomAccessIterator1,
76
80
typename RandomAccessIterator2,
77
81
typename StrictWeakOrdering>
82
void sort_by_key(thrust::execution_policy<ExecutionPolicy> &exec,
79
83
RandomAccessIterator1 keys_first,
80
84
RandomAccessIterator1 keys_last,
81
85
RandomAccessIterator2 values_first,
82
86
StrictWeakOrdering comp)
84
88
// implement with stable_sort_by_key
85
thrust::stable_sort_by_key(keys_first, keys_last, values_first, comp);
89
thrust::stable_sort_by_key(exec, keys_first, keys_last, values_first, comp);
86
90
} // end sort_by_key()
89
template<typename RandomAccessIterator>
93
template<typename ExecutionPolicy,
94
typename RandomAccessIterator>
95
void stable_sort(thrust::execution_policy<ExecutionPolicy> &exec,
91
96
RandomAccessIterator first,
92
97
RandomAccessIterator last)
94
99
typedef typename thrust::iterator_value<RandomAccessIterator>::type value_type;
95
thrust::stable_sort(first, last, thrust::less<value_type>());
100
thrust::stable_sort(exec, first, last, thrust::less<value_type>());
96
101
} // end stable_sort()
99
template<typename RandomAccessIterator1,
104
template<typename ExecutionPolicy,
105
typename RandomAccessIterator1,
100
106
typename RandomAccessIterator2>
101
void stable_sort_by_key(tag,
107
void stable_sort_by_key(thrust::execution_policy<ExecutionPolicy> &exec,
102
108
RandomAccessIterator1 keys_first,
103
109
RandomAccessIterator1 keys_last,
104
110
RandomAccessIterator2 values_first)
106
112
typedef typename iterator_value<RandomAccessIterator1>::type value_type;
107
thrust::stable_sort_by_key(keys_first, keys_last, values_first, thrust::less<value_type>());
113
thrust::stable_sort_by_key(exec, keys_first, keys_last, values_first, thrust::less<value_type>());
108
114
} // end stable_sort_by_key()
111
template<typename ForwardIterator>
117
template<typename ExecutionPolicy, typename ForwardIterator>
118
bool is_sorted(thrust::execution_policy<ExecutionPolicy> &exec,
113
119
ForwardIterator first,
114
120
ForwardIterator last)
116
return thrust::is_sorted_until(first, last) == last;
122
return thrust::is_sorted_until(exec, first, last) == last;
117
123
} // end is_sorted()
120
template<typename ForwardIterator,
126
template<typename ExecutionPolicy,
127
typename ForwardIterator,
121
128
typename Compare>
129
bool is_sorted(thrust::execution_policy<ExecutionPolicy> &exec,
123
130
ForwardIterator first,
124
131
ForwardIterator last,
127
return thrust::is_sorted_until(first, last, comp) == last;
134
return thrust::is_sorted_until(exec, first, last, comp) == last;
128
135
} // end is_sorted()
131
template<typename ForwardIterator>
132
ForwardIterator is_sorted_until(tag,
138
template<typename ExecutionPolicy, typename ForwardIterator>
139
ForwardIterator is_sorted_until(thrust::execution_policy<ExecutionPolicy> &exec,
133
140
ForwardIterator first,
134
141
ForwardIterator last)
136
143
typedef typename thrust::iterator_value<ForwardIterator>::type InputType;
138
return thrust::is_sorted_until(first, last, thrust::less<InputType>());
145
return thrust::is_sorted_until(exec, first, last, thrust::less<InputType>());
139
146
} // end is_sorted_until()
142
template<typename ForwardIterator,
149
template<typename ExecutionPolicy,
150
typename ForwardIterator,
143
151
typename Compare>
144
ForwardIterator is_sorted_until(tag,
152
ForwardIterator is_sorted_until(thrust::execution_policy<ExecutionPolicy> &exec,
145
153
ForwardIterator first,
146
154
ForwardIterator last,