| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "artyushkina_string_matrix/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <algorithm> | ||
| 4 | #include <climits> | ||
| 5 | #include <cstddef> | ||
| 6 | #include <ranges> // IWYU pragma: keep | ||
| 7 | #include <vector> | ||
| 8 | |||
| 9 | #include "artyushkina_string_matrix/common/include/common.hpp" | ||
| 10 | |||
| 11 | namespace artyushkina_string_matrix { | ||
| 12 | |||
| 13 | ✗ | ArtyushkinaStringMatrixSEQ::ArtyushkinaStringMatrixSEQ(const InType &in) { | |
| 14 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 15 | |||
| 16 | ✗ | if (!in.empty()) { | |
| 17 | ✗ | GetInput() = in; | |
| 18 | } else { | ||
| 19 | ✗ | GetInput() = InType{}; | |
| 20 | } | ||
| 21 | |||
| 22 | ✗ | GetOutput() = OutType{}; | |
| 23 | ✗ | } | |
| 24 | |||
| 25 | ✗ | bool ArtyushkinaStringMatrixSEQ::ValidationImpl() { | |
| 26 | const auto &input = GetInput(); | ||
| 27 | ✗ | if (input.empty()) { | |
| 28 | return false; | ||
| 29 | } | ||
| 30 | |||
| 31 | const std::size_t cols = input[0].size(); | ||
| 32 | ✗ | if (cols == 0) { | |
| 33 | return false; | ||
| 34 | } | ||
| 35 | |||
| 36 | return std::ranges::all_of(input, [cols](const auto &row) { return row.size() == cols; }); | ||
| 37 | } | ||
| 38 | |||
| 39 | ✗ | bool ArtyushkinaStringMatrixSEQ::PreProcessingImpl() { | |
| 40 | GetOutput().clear(); | ||
| 41 | ✗ | return true; | |
| 42 | } | ||
| 43 | |||
| 44 | ✗ | bool ArtyushkinaStringMatrixSEQ::RunImpl() { | |
| 45 | const auto &matrix = GetInput(); | ||
| 46 | auto &result = GetOutput(); | ||
| 47 | |||
| 48 | result.clear(); | ||
| 49 | ✗ | result.reserve(matrix.size()); | |
| 50 | |||
| 51 | ✗ | for (const auto &row : matrix) { | |
| 52 | ✗ | int min_val = INT_MAX; | |
| 53 | ✗ | for (const int val : row) { | |
| 54 | ✗ | min_val = std::min(val, min_val); | |
| 55 | } | ||
| 56 | result.push_back(min_val); | ||
| 57 | } | ||
| 58 | |||
| 59 | ✗ | return true; | |
| 60 | } | ||
| 61 | |||
| 62 | ✗ | bool ArtyushkinaStringMatrixSEQ::PostProcessingImpl() { | |
| 63 | ✗ | return true; | |
| 64 | } | ||
| 65 | |||
| 66 | } // namespace artyushkina_string_matrix | ||
| 67 |