| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "rozenberg_a_bubble_odd_even_sort/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "rozenberg_a_bubble_odd_even_sort/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace rozenberg_a_bubble_odd_even_sort { | ||
| 10 | |||
| 11 | 64 | RozenbergABubbleOddEvenSortSEQ::RozenbergABubbleOddEvenSortSEQ(const InType &in) { | |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 | |||
| 14 | InType empty; | ||
| 15 | GetInput().swap(empty); | ||
| 16 | |||
| 17 |
2/2✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 64 times.
|
1352 | for (const auto &elem : in) { |
| 18 | GetInput().push_back(elem); | ||
| 19 | } | ||
| 20 | |||
| 21 | GetOutput().clear(); | ||
| 22 | 64 | } | |
| 23 | |||
| 24 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | bool RozenbergABubbleOddEvenSortSEQ::ValidationImpl() { |
| 25 |
2/4✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
|
64 | return (!(GetInput().empty())) && (GetOutput().empty()); |
| 26 | } | ||
| 27 | |||
| 28 | 64 | bool RozenbergABubbleOddEvenSortSEQ::PreProcessingImpl() { | |
| 29 | 64 | GetOutput().resize(GetInput().size()); | |
| 30 | 64 | return GetOutput().size() == GetInput().size(); | |
| 31 | } | ||
| 32 | |||
| 33 | 64 | bool RozenbergABubbleOddEvenSortSEQ::RunImpl() { | |
| 34 | 64 | GetOutput() = GetInput(); | |
| 35 | size_t n = GetOutput().size(); | ||
| 36 | |||
| 37 |
2/2✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 64 times.
|
1352 | for (size_t i = 0; i < n; i++) { |
| 38 |
2/2✓ Branch 0 taken 42360 times.
✓ Branch 1 taken 1288 times.
|
43648 | for (size_t j = i % 2 == 0 ? 0 : 1; j < n - 1; j += 2) { |
| 39 |
2/2✓ Branch 0 taken 20456 times.
✓ Branch 1 taken 21904 times.
|
42360 | if (GetOutput()[j] > GetOutput()[j + 1]) { |
| 40 | std::swap(GetOutput()[j + 1], GetOutput()[j]); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | 64 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 | 64 | bool RozenbergABubbleOddEvenSortSEQ::PostProcessingImpl() { | |
| 49 | 64 | return true; | |
| 50 | } | ||
| 51 | |||
| 52 | } // namespace rozenberg_a_bubble_odd_even_sort | ||
| 53 |