| 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 |
no test coverage detected