| 4 | #include <cmath> // For std::abs() |
| 5 | |
| 6 | std::optional<double> Finder::findNearest(const std::vector<double>& values) const |
| 7 | { |
| 8 | if (values.empty()) |
| 9 | return std::nullopt; |
| 10 | else |
| 11 | return *findOptimum(values, [this](double x, double y) { |
| 12 | return std::abs(x - m_number_to_search_for) < std::abs(y - m_number_to_search_for); |
| 13 | }); |
| 14 | } |
| 15 | |
| 16 | double Finder::getNumberToSearchFor() const |
| 17 | { |
no test coverage detected