MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / smallest

Function smallest

Exercises/Modules/Chapter 09/Soln9_03.cpp:48–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48std::optional<double> smallest(std::span<const double> data)
49{
50 if (data.empty()) return {}; // There is no smallest in an empty sequence
51
52 size_t index_min {};
53 for (size_t i {1}; i < data.size(); ++i)
54 if (data[index_min] > data[i])
55 index_min = i;
56
57 return data[index_min];
58}
59
60std::span<double> shift_range(std::span<double> data, double delta)
61{

Callers 1

normalize_rangeFunction · 0.70

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected