MCPcopy Create free account
hub / github.com/catboost/catboost / ExtremeElementBy

Function ExtremeElementBy

util/generic/algorithm.h:16–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace NPrivate {
15 template <class I, class F, class P>
16 constexpr I ExtremeElementBy(I begin, I end, F&& func, P&& pred) {
17 if (begin == end) {
18 return end;
19 }
20
21 auto bestValue = func(*begin);
22 auto bestPos = begin;
23
24 for (++begin; begin != end; ++begin) {
25 auto curValue = func(*begin);
26 if (pred(curValue, bestValue)) {
27 bestValue = std::move(curValue);
28 bestPos = begin;
29 }
30 }
31
32 return bestPos;
33 }
34} // namespace NPrivate
35
36template <class T>

Callers 2

MaxElementByFunction · 0.85
MinElementByFunction · 0.85

Calls 2

funcFunction · 0.85
moveFunction · 0.50

Tested by

no test coverage detected