MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / fold1

Function fold1

source/core/StarAlgorithm.hpp:87–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85// Like fold, but returns default value when container is empty.
86template <typename Container, typename Function>
87typename Container::value_type fold1(Container const& l, Function f) {
88 typename Container::value_type res = {};
89 typename Container::const_iterator i = l.begin();
90 typename Container::const_iterator e = l.end();
91
92 if (i == e)
93 return res;
94
95 res = *i;
96 ++i;
97 while (i != e) {
98 res = f(res, *i);
99 ++i;
100 }
101 return res;
102}
103
104// Return intersection of sorted containers.
105template <typename Container>

Callers 2

sumFunction · 0.85
productFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected