GCC Code Coverage Report


Directory: ./
File: tasks/safronov_m_quicksort_with_batcher_even_odd_merge/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 38 38 100.0%
Functions: 6 6 100.0%
Branches: 25 34 73.5%

Line Branch Exec Source
1 #include "safronov_m_quicksort_with_batcher_even_odd_merge/seq/include/ops_seq.hpp"
2
3 #include <utility>
4 #include <vector>
5
6 #include "safronov_m_quicksort_with_batcher_even_odd_merge/common/include/common.hpp"
7
8 namespace safronov_m_quicksort_with_batcher_even_odd_merge {
9
10
1/2
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
104 SafronovMQuicksortWithBatcherEvenOddMergeSEQ::SafronovMQuicksortWithBatcherEvenOddMergeSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
104 GetInput() = in;
13 104 }
14
15 104 bool SafronovMQuicksortWithBatcherEvenOddMergeSEQ::ValidationImpl() {
16 104 return GetOutput().empty();
17 }
18
19
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 bool SafronovMQuicksortWithBatcherEvenOddMergeSEQ::PreProcessingImpl() {
20 GetOutput().clear();
21 104 return true;
22 }
23
24 1440 std::pair<int, int> SafronovMQuicksortWithBatcherEvenOddMergeSEQ::SplitRange(std::vector<int> &array, int left,
25 int right) {
26 int i = left;
27 int j = right;
28 1440 int mid = left + ((right - left) / 2);
29 1440 int pivot = array[mid];
30
31
2/2
✓ Branch 0 taken 2624 times.
✓ Branch 1 taken 1440 times.
5504 while (i <= j) {
32
2/2
✓ Branch 0 taken 2072 times.
✓ Branch 1 taken 2624 times.
4696 while (array[i] < pivot) {
33 2072 i++;
34 }
35
2/2
✓ Branch 0 taken 2792 times.
✓ Branch 1 taken 2624 times.
5416 while (array[j] > pivot) {
36 2792 j--;
37 }
38
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2304 times.
2624 if (i <= j) {
39 int tmp = array[i];
40 2304 array[i] = array[j];
41 2304 array[j] = tmp;
42 2304 i++;
43 2304 j--;
44 }
45 }
46
47 1440 return {i, j};
48 }
49
50 104 bool SafronovMQuicksortWithBatcherEvenOddMergeSEQ::RunImpl() {
51 104 std::vector<int> array = GetInput();
52
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 8 times.
104 if (array.empty()) {
53 return true;
54 }
55
56
1/2
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
96 std::vector<std::pair<int, int>> stack;
57
1/4
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 stack.emplace_back(0, static_cast<int>(array.size()) - 1);
58
59
2/2
✓ Branch 0 taken 1448 times.
✓ Branch 1 taken 96 times.
1544 while (!stack.empty()) {
60 auto range = stack.back();
61 stack.pop_back();
62
63 1448 int left = range.first;
64 1448 int right = range.second;
65
66
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1440 times.
1448 if (left >= right) {
67 8 continue;
68 }
69
70 1440 auto borders = SplitRange(array, left, right);
71
72
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 816 times.
1440 if (left < borders.second) {
73
1/2
✓ Branch 1 taken 624 times.
✗ Branch 2 not taken.
624 stack.emplace_back(left, borders.second);
74 }
75
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 712 times.
1440 if (borders.first < right) {
76
1/2
✓ Branch 1 taken 728 times.
✗ Branch 2 not taken.
728 stack.emplace_back(borders.first, right);
77 }
78 }
79
80 GetOutput().swap(array);
81 return true;
82 }
83
84 104 bool SafronovMQuicksortWithBatcherEvenOddMergeSEQ::PostProcessingImpl() {
85 104 return true;
86 }
87
88 } // namespace safronov_m_quicksort_with_batcher_even_odd_merge
89