| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "ovchinnikov_m_bubble_sort/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "ovchinnikov_m_bubble_sort/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace ovchinnikov_m_bubble_sort { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
|
56 | OvchinnikovMBubbleSortSEQ::OvchinnikovMBubbleSortSEQ(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
|
56 | GetInput() = in; |
| 14 | static_cast<void>(GetOutput()); | ||
| 15 | 56 | } | |
| 16 | |||
| 17 | 56 | bool OvchinnikovMBubbleSortSEQ::ValidationImpl() { | |
| 18 | 56 | return true; | |
| 19 | } | ||
| 20 | |||
| 21 | 56 | bool OvchinnikovMBubbleSortSEQ::PreProcessingImpl() { | |
| 22 | 56 | return true; | |
| 23 | } | ||
| 24 | |||
| 25 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
|
56 | bool OvchinnikovMBubbleSortSEQ::RunImpl() { |
| 26 | auto &array = GetInput(); | ||
| 27 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
|
56 | if (array.empty()) { |
| 28 | return true; | ||
| 29 | } | ||
| 30 | bool sorted = false; | ||
| 31 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 48 times.
|
168 | while (!sorted) { |
| 32 | sorted = true; | ||
| 33 |
2/2✓ Branch 0 taken 368 times.
✓ Branch 1 taken 120 times.
|
488 | for (size_t i = 0; i < array.size() - 1; i += 2) { |
| 34 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 200 times.
|
368 | if (array[i] > array[i + 1]) { |
| 35 | std::swap(array[i], array[i + 1]); | ||
| 36 | sorted = false; | ||
| 37 | } | ||
| 38 | } | ||
| 39 |
2/2✓ Branch 0 taken 312 times.
✓ Branch 1 taken 120 times.
|
432 | for (size_t i = 1; i < array.size() - 1; i += 2) { |
| 40 |
2/2✓ Branch 0 taken 136 times.
✓ Branch 1 taken 176 times.
|
312 | if (array[i] > array[i + 1]) { |
| 41 | std::swap(array[i], array[i + 1]); | ||
| 42 | sorted = false; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | 48 | GetOutput() = array; | |
| 47 | 48 | return true; | |
| 48 | } | ||
| 49 | |||
| 50 | 56 | bool OvchinnikovMBubbleSortSEQ::PostProcessingImpl() { | |
| 51 | 56 | return true; | |
| 52 | } | ||
| 53 | |||
| 54 | } // namespace ovchinnikov_m_bubble_sort | ||
| 55 |