src/fast/rsort32/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../util/alias/others/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | template <class C> | ||
| 8 | requires(std::is_array_v<C> && std::integral<decltype(std::declval<C>()[0])> && sizeof(std::declval<C>()[0]) == 4) || (std::contiguous_iterator<TPN C::iterator> && std::integral<TPN C::value_type> && sizeof(TPN C::value_type) == 4) | ||
| 9 | 392 | void rsort32(C& a) NE { | |
| 10 |
3/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 111 times.
|
525 | if (a.size() <= 1) return; |
| 11 |
3/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 12 times.
|
145 | if (a.size() <= 200'000) { |
| 12 | 133 | std::ranges::sort(a); | |
| 13 | 133 | return; | |
| 14 | } | ||
| 15 | 12 | arr<u32, 256> _0{}, _1{}, _2{}, _3{}; | |
| 16 | 12 | cu32 n = (u32)a.size(); | |
| 17 | 12 | vecu b(n); | |
| 18 | 12 | u32 *a_ = (u32*)a.data(), *b_ = (u32*)b.data(); | |
| 19 |
2/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 4 not taken.
✗ Branch 5 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 4 taken 13117802 times.
✓ Branch 5 taken 12 times.
|
13117814 | for (cu32 *_ = a_ + n, *i = a_; i < _; ++i) ++_0[*i & 255], ++_1[*i >> 8 & 255], ++_2[*i >> 16 & 255], ++_3[*i >> 24 & 255]; |
| 20 |
2/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 8 not taken.
✗ Branch 9 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 8 taken 3060 times.
✓ Branch 9 taken 12 times.
|
3072 | flt_ (u32, i, 1, 256) _0[i] += _0[i - 1], _1[i] += _1[i - 1], _2[i] += _2[i - 1], _3[i] += _3[i - 1]; |
| 21 |
2/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 1 taken 13117802 times.
✓ Branch 2 taken 12 times.
|
13117814 | for (u32 CP i = a_ + n; --i >= a_;) b_[--_0[*i & 255]] = *i; |
| 22 |
2/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 1 taken 13117802 times.
✓ Branch 2 taken 12 times.
|
13117814 | for (u32 CP i = b_ + n; --i >= b_;) a_[--_1[*i >> 8 & 255]] = *i; |
| 23 |
2/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 1 taken 13117802 times.
✓ Branch 2 taken 12 times.
|
13117814 | for (u32 CP i = a_ + n; --i >= a_;) b_[--_2[*i >> 16 & 255]] = *i; |
| 24 |
2/4void tifa_libs::rsort32<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void tifa_libs::rsort32<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<unsigned int, std::allocator<unsigned int> >&):
✓ Branch 1 taken 13117802 times.
✓ Branch 2 taken 12 times.
|
13117814 | for (u32 CP i = b_ + n; --i >= b_;) a_[--_3[*i >> 24 & 255]] = *i; |
| 25 | if CEXP (std::is_signed_v<TPN C::value_type>) { | ||
| 26 | ✗ | u32 i = n; | |
| 27 | ✗ | while (i && a[i - 1] < 0) --i; | |
| 28 | ✗ | rotate(a_, a_ + n, a_ + i); | |
| 29 | } | ||
| 30 | 12 | } | |
| 31 | template <class C> | ||
| 32 | requires(std::is_array_v<C> && std::integral<decltype(std::declval<C>()[0])> && sizeof(std::declval<C>()[0]) == 4) || range<C> | ||
| 33 | 1085377 | void sort(C& a) NE { | |
| 34 | 382 | if CEXP (std::is_array_v<C> || (std::contiguous_iterator<TPN C::iterator> && std::integral<TPN C::value_type> && sizeof(TPN C::value_type) == 4)) rsort32(a); | |
| 35 | 1084995 | else std::ranges::sort(a); | |
| 36 | 1085377 | } | |
| 37 | |||
| 38 | } // namespace tifa_libs | ||
| 39 |