3
3
4
4
#include " xss-network-qsort.hpp"
5
5
6
+ enum class pivot_result_t : int { Normal, Sorted, Only2Values };
7
+
6
8
template <typename type_t >
7
9
struct pivot_results {
8
- bool alreadySorted = false ;
9
- bool only2Values = false ;
10
- type_t pivot = 0 ;
11
10
12
- pivot_results (type_t _pivot){
13
- pivot = _pivot;
14
- alreadySorted = false ;
15
- }
11
+ pivot_result_t result = pivot_result_t ::Normal;
12
+ type_t pivot = 0 ;
16
13
17
- pivot_results (type_t _pivot, bool _alreadySorted ){
14
+ pivot_results (type_t _pivot, pivot_result_t _result = pivot_result_t ::Normal ){
18
15
pivot = _pivot;
19
- alreadySorted = _alreadySorted ;
16
+ result = _result ;
20
17
}
21
18
};
22
19
@@ -197,7 +194,7 @@ X86_SIMD_SORT_INLINE pivot_results<type_t> get_pivot_near_constant(type_t *arr,
197
194
if (index == right + 1 ){
198
195
// The array is completely constant
199
196
// Setting the second flag to true skips partitioning, as the array is constant and thus sorted
200
- return pivot_results<type_t >(commonValue, true );
197
+ return pivot_results<type_t >(commonValue, pivot_result_t ::Sorted );
201
198
}
202
199
203
200
// Secondly, search for a second value not equal to either of the previous two
@@ -224,9 +221,7 @@ X86_SIMD_SORT_INLINE pivot_results<type_t> get_pivot_near_constant(type_t *arr,
224
221
// We can also skip recursing, as it is guaranteed both partitions are constant after partitioning with the larger value
225
222
// TODO this logic now assumes we use greater than or equal to specifically when partitioning, might be worth noting that somewhere
226
223
type_t pivot = std::max (value1, commonValue, comparison_func<vtype>);
227
- auto result = pivot_results<type_t >(pivot, false );
228
- result.only2Values = true ;
229
- return result;
224
+ return pivot_results<type_t >(pivot, pivot_result_t ::Only2Values);
230
225
}
231
226
232
227
// The array has at least 3 distinct values. Use the middle one as the pivot
0 commit comments