MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / sortedInsert

Function sortedInsert

src/openrct2/core/Algorithm.hpp:29–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28 template<typename Container, typename T, class Compare = std::less<>>
29 auto sortedInsert(Container& cont, T&& value, const Compare comp = {})
30 {
31 if (cont.empty() || value < cont.front())
32 {
33 return cont.insert(cont.begin(), value);
34 }
35 if (value > cont.back())
36 {
37 return cont.insert(cont.end(), value);
38 }
39 return cont.insert(std::lower_bound(cont.begin(), cont.end(), std::forward<T>(value), comp), std::forward<T>(value));
40 }
41
42} // namespace OpenRCT2::Core::Algorithm
43

Callers 2

AddToEntityListMethod · 0.85
EntitySpatialInsertMethod · 0.85

Calls 5

endMethod · 0.65
emptyMethod · 0.45
frontMethod · 0.45
beginMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected