| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "vasiliev_m_bubble_sort/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <cstddef> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "vasiliev_m_bubble_sort/common/include/common.hpp" | ||
| 8 | |||
| 9 | namespace vasiliev_m_bubble_sort { | ||
| 10 | |||
| 11 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | VasilievMBubbleSortSEQ::VasilievMBubbleSortSEQ(const InType &in) { |
| 12 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 13 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | GetInput() = in; |
| 14 | 64 | GetOutput() = OutType{}; | |
| 15 | 64 | } | |
| 16 | |||
| 17 | 64 | bool VasilievMBubbleSortSEQ::ValidationImpl() { | |
| 18 | 64 | return !GetInput().empty(); | |
| 19 | } | ||
| 20 | |||
| 21 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
|
64 | bool VasilievMBubbleSortSEQ::PreProcessingImpl() { |
| 22 | GetOutput().clear(); | ||
| 23 | 64 | return true; | |
| 24 | } | ||
| 25 | |||
| 26 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | bool VasilievMBubbleSortSEQ::RunImpl() { |
| 27 | auto &vec = GetInput(); | ||
| 28 | const size_t n = vec.size(); | ||
| 29 | bool sorted = false; | ||
| 30 | |||
| 31 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | if (vec.empty()) { |
| 32 | return true; | ||
| 33 | } | ||
| 34 | |||
| 35 |
2/2✓ Branch 0 taken 184 times.
✓ Branch 1 taken 64 times.
|
248 | while (!sorted) { |
| 36 | sorted = true; | ||
| 37 | |||
| 38 |
2/2✓ Branch 0 taken 760 times.
✓ Branch 1 taken 184 times.
|
944 | for (size_t i = 0; i < n - 1; i += 2) { |
| 39 |
2/2✓ Branch 0 taken 344 times.
✓ Branch 1 taken 416 times.
|
760 | if (vec[i] > vec[i + 1]) { |
| 40 | std::swap(vec[i], vec[i + 1]); | ||
| 41 | sorted = false; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 |
2/2✓ Branch 0 taken 720 times.
✓ Branch 1 taken 184 times.
|
904 | for (size_t i = 1; i < n - 1; i += 2) { |
| 46 |
2/2✓ Branch 0 taken 272 times.
✓ Branch 1 taken 448 times.
|
720 | if (vec[i] > vec[i + 1]) { |
| 47 | std::swap(vec[i], vec[i + 1]); | ||
| 48 | sorted = false; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | 64 | GetOutput() = vec; | |
| 54 | 64 | return true; | |
| 55 | } | ||
| 56 | |||
| 57 | 64 | bool VasilievMBubbleSortSEQ::PostProcessingImpl() { | |
| 58 | 64 | return true; | |
| 59 | } | ||
| 60 | |||
| 61 | } // namespace vasiliev_m_bubble_sort | ||
| 62 |