| 65 | // In and Tmp can be the same, but Out must be different |
| 66 | template <class SeqIn, class Slice, class GetKey> |
| 67 | void seq_radix_sort(SeqIn const &In, Slice Out, Slice Tmp, GetKey const &g, |
| 68 | size_t key_bits, bool inplace = true) { |
| 69 | bool odd = ((key_bits - 1) / radix) & 1; |
| 70 | size_t n = In.size(); |
| 71 | if (slice_eq(In.slice(), Tmp)) { // inplace |
| 72 | seq_radix_sort_(Tmp.slice(), Out, g, key_bits, inplace); |
| 73 | } else { |
| 74 | if (odd) { |
| 75 | for (size_t i = 0; i < n; i++) move_uninitialized(Tmp[i], In[i]); |
| 76 | seq_radix_sort_(Tmp, Out, g, key_bits, false); |
| 77 | } else { |
| 78 | for (size_t i = 0; i < n; i++) move_uninitialized(Out[i], In[i]); |
| 79 | seq_radix_sort_(Out, Tmp, g, key_bits, true); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // a top down recursive radix sort |
| 85 | // g extracts the integer keys from In |
no test coverage detected