| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "buzuluksky_d_bubble_sort/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "buzuluksky_d_bubble_sort/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace buzuluksky_d_bubble_sort { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | BuzulukskyDBubbleSortSEQ::BuzulukskyDBubbleSortSEQ(const InType &input) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
|
72 | GetInput() = input; |
| 14 | static_cast<void>(GetOutput()); | ||
| 15 | 72 | } | |
| 16 | |||
| 17 | 72 | bool BuzulukskyDBubbleSortSEQ::ValidationImpl() { | |
| 18 | 72 | return true; | |
| 19 | } | ||
| 20 | 72 | bool BuzulukskyDBubbleSortSEQ::PreProcessingImpl() { | |
| 21 | 72 | return true; | |
| 22 | } | ||
| 23 | |||
| 24 | 72 | bool BuzulukskyDBubbleSortSEQ::RunImpl() { | |
| 25 | 72 | auto data = GetInput(); | |
| 26 | const std::size_t n = data.size(); | ||
| 27 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 56 times.
|
72 | if (n <= 1U) { |
| 28 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | GetOutput() = data; |
| 29 | return true; | ||
| 30 | } | ||
| 31 | |||
| 32 | bool sorted = false; | ||
| 33 |
2/2✓ Branch 0 taken 200 times.
✓ Branch 1 taken 56 times.
|
256 | for (std::size_t pass = 0; pass < n && !sorted; ++pass) { |
| 34 | sorted = true; | ||
| 35 |
2/2✓ Branch 0 taken 768 times.
✓ Branch 1 taken 200 times.
|
968 | for (std::size_t i = 0; i + 1 < n; i += 2) { |
| 36 |
2/2✓ Branch 0 taken 392 times.
✓ Branch 1 taken 376 times.
|
768 | if (data[i] > data[i + 1]) { |
| 37 | std::swap(data[i], data[i + 1]); | ||
| 38 | sorted = false; | ||
| 39 | } | ||
| 40 | } | ||
| 41 |
2/2✓ Branch 0 taken 624 times.
✓ Branch 1 taken 200 times.
|
824 | for (std::size_t i = 1; i + 1 < n; i += 2) { |
| 42 |
2/2✓ Branch 0 taken 304 times.
✓ Branch 1 taken 320 times.
|
624 | if (data[i] > data[i + 1]) { |
| 43 | std::swap(data[i], data[i + 1]); | ||
| 44 | sorted = false; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 |
1/2✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
|
56 | GetOutput() = data; |
| 50 | return true; | ||
| 51 | } | ||
| 52 | |||
| 53 | 72 | bool BuzulukskyDBubbleSortSEQ::PostProcessingImpl() { | |
| 54 | 72 | return true; | |
| 55 | } | ||
| 56 | |||
| 57 | } // namespace buzuluksky_d_bubble_sort | ||
| 58 |