| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "levonychev_i_radix_batcher_sort/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <ranges> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "levonychev_i_radix_batcher_sort/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace levonychev_i_radix_batcher_sort { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | LevonychevIRadixBatcherSortSEQ::LevonychevIRadixBatcherSortSEQ(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
|
32 | GetInput() = in; |
| 14 | 32 | } | |
| 15 | |||
| 16 | 128 | void LevonychevIRadixBatcherSortSEQ::CountingSort(InType &arr, size_t byte_index) { | |
| 17 | const size_t byte = 256; | ||
| 18 |
1/2✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
|
128 | std::vector<int> count(byte, 0); |
| 19 |
1/4✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
128 | OutType result(arr.size()); |
| 20 | |||
| 21 | bool is_last_byte = (byte_index == (sizeof(int) - 1ULL)); | ||
| 22 |
2/2✓ Branch 0 taken 800 times.
✓ Branch 1 taken 128 times.
|
928 | for (auto number : arr) { |
| 23 | 800 | int value_of_byte = (number >> (byte_index * 8ULL)) & 0xFF; | |
| 24 | |||
| 25 |
2/2✓ Branch 0 taken 200 times.
✓ Branch 1 taken 600 times.
|
800 | if (is_last_byte) { |
| 26 | 200 | value_of_byte ^= 0x80; | |
| 27 | } | ||
| 28 | |||
| 29 | 800 | ++count[value_of_byte]; | |
| 30 | } | ||
| 31 | |||
| 32 |
2/2✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 128 times.
|
32768 | for (size_t i = 1ULL; i < byte; ++i) { |
| 33 | 32640 | count[i] += count[i - 1]; | |
| 34 | } | ||
| 35 | |||
| 36 |
2/2✓ Branch 0 taken 800 times.
✓ Branch 1 taken 128 times.
|
928 | for (int &val : std::ranges::reverse_view(arr)) { |
| 37 | 800 | int value_of_byte = (val >> (byte_index * 8ULL)) & 0xFF; | |
| 38 | |||
| 39 |
2/2✓ Branch 0 taken 200 times.
✓ Branch 1 taken 600 times.
|
800 | if (is_last_byte) { |
| 40 | 200 | value_of_byte ^= 0x80; | |
| 41 | } | ||
| 42 | |||
| 43 | 800 | result[--count[value_of_byte]] = val; | |
| 44 | } | ||
| 45 |
1/2✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
|
128 | arr = result; |
| 46 | 128 | } | |
| 47 | |||
| 48 | 32 | bool LevonychevIRadixBatcherSortSEQ::ValidationImpl() { | |
| 49 | 32 | return !GetInput().empty(); | |
| 50 | } | ||
| 51 | |||
| 52 | 32 | bool LevonychevIRadixBatcherSortSEQ::PreProcessingImpl() { | |
| 53 | 32 | return true; | |
| 54 | } | ||
| 55 | |||
| 56 | 32 | bool LevonychevIRadixBatcherSortSEQ::RunImpl() { | |
| 57 | 32 | GetOutput() = GetInput(); | |
| 58 | |||
| 59 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 32 times.
|
160 | for (size_t i = 0; i < sizeof(int); ++i) { |
| 60 | 128 | CountingSort(GetOutput(), i); | |
| 61 | } | ||
| 62 | |||
| 63 | 32 | return true; | |
| 64 | } | ||
| 65 | |||
| 66 | 32 | bool LevonychevIRadixBatcherSortSEQ::PostProcessingImpl() { | |
| 67 | 32 | return true; | |
| 68 | } | ||
| 69 | |||
| 70 | } // namespace levonychev_i_radix_batcher_sort | ||
| 71 |