| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "safronov_m_bubble_sort_odd_even/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <vector> | ||
| 4 | |||
| 5 | #include "safronov_m_bubble_sort_odd_even/common/include/common.hpp" | ||
| 6 | |||
| 7 | namespace safronov_m_bubble_sort_odd_even { | ||
| 8 | |||
| 9 |
1/2✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
|
104 | SafronovMBubbleSortOddEvenSEQ::SafronovMBubbleSortOddEvenSEQ(const InType &in) { |
| 10 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 11 |
1/2✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
|
104 | GetInput() = in; |
| 12 | 104 | } | |
| 13 | |||
| 14 | 104 | bool SafronovMBubbleSortOddEvenSEQ::ValidationImpl() { | |
| 15 | 104 | return GetOutput().empty(); | |
| 16 | } | ||
| 17 | |||
| 18 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
|
104 | bool SafronovMBubbleSortOddEvenSEQ::PreProcessingImpl() { |
| 19 | GetOutput().clear(); | ||
| 20 | 104 | return true; | |
| 21 | } | ||
| 22 | |||
| 23 | 104 | bool SafronovMBubbleSortOddEvenSEQ::RunImpl() { | |
| 24 | bool flag = true; | ||
| 25 | 104 | std::vector<int> array = GetInput(); | |
| 26 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 8 times.
|
104 | if (array.empty()) { |
| 27 | return true; | ||
| 28 | } | ||
| 29 | 96 | int n = static_cast<int>(array.size()); | |
| 30 |
2/2✓ Branch 0 taken 896 times.
✓ Branch 1 taken 96 times.
|
992 | while (flag) { |
| 31 | flag = false; | ||
| 32 |
2/2✓ Branch 0 taken 18016 times.
✓ Branch 1 taken 896 times.
|
18912 | for (int j = 0; j < n - 1; j += 2) { |
| 33 |
2/2✓ Branch 0 taken 6088 times.
✓ Branch 1 taken 11928 times.
|
18016 | if (array[j] > array[j + 1]) { |
| 34 | int tmp = array[j + 1]; | ||
| 35 | 6088 | array[j + 1] = array[j]; | |
| 36 | 6088 | array[j] = tmp; | |
| 37 | flag = true; | ||
| 38 | } | ||
| 39 | } | ||
| 40 |
2/2✓ Branch 0 taken 17312 times.
✓ Branch 1 taken 896 times.
|
18208 | for (int j = 1; j < n - 1; j += 2) { |
| 41 |
2/2✓ Branch 0 taken 5936 times.
✓ Branch 1 taken 11376 times.
|
17312 | if (array[j] > array[j + 1]) { |
| 42 | int tmp = array[j + 1]; | ||
| 43 | 5936 | array[j + 1] = array[j]; | |
| 44 | 5936 | array[j] = tmp; | |
| 45 | flag = true; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | GetOutput().swap(array); | ||
| 50 | 96 | return true; | |
| 51 | } | ||
| 52 | |||
| 53 | 104 | bool SafronovMBubbleSortOddEvenSEQ::PostProcessingImpl() { | |
| 54 | 104 | return true; | |
| 55 | } | ||
| 56 | |||
| 57 | } // namespace safronov_m_bubble_sort_odd_even | ||
| 58 |