From: Mikko Rasa Date: Fri, 2 Apr 2021 11:05:04 +0000 (+0300) Subject: Add wrappers for lower_bound and upper_bound X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=fa87d901ba9fa075e51637608902b7fbdd71f896;ds=sidebyside Add wrappers for lower_bound and upper_bound --- diff --git a/source/core/algorithm.h b/source/core/algorithm.h index 63d1cf4..804db7b 100644 --- a/source/core/algorithm.h +++ b/source/core/algorithm.h @@ -29,6 +29,54 @@ inline typename Container::const_iterator find_if(const Container &cont, Predica return std::find_if(cont.begin(), cont.end(), pred); } +template +inline typename Container::iterator lower_bound(Container &cont, const T &value) +{ + return std::lower_bound(cont.begin(), cont.end(), value); +} + +template +inline typename Container::const_iterator lower_bound(const Container &cont, const T &value) +{ + return std::lower_bound(cont.begin(), cont.end(), value); +} + +template +inline typename Container::iterator lower_bound(Container &cont, const T &value, Predicate pred) +{ + return std::lower_bound(cont.begin(), cont.end(), value, pred); +} + +template +inline typename Container::const_iterator lower_bound(const Container &cont, const T &value, Predicate pred) +{ + return std::lower_bound(cont.begin(), cont.end(), value, pred); +} + +template +inline typename Container::iterator upper_bound(Container &cont, const T &value) +{ + return std::upper_bound(cont.begin(), cont.end(), value); +} + +template +inline typename Container::const_iterator upper_bound(const Container &cont, const T &value) +{ + return std::upper_bound(cont.begin(), cont.end(), value); +} + +template +inline typename Container::iterator upper_bound(Container &cont, const T &value, Predicate pred) +{ + return std::upper_bound(cont.begin(), cont.end(), value, pred); +} + +template +inline typename Container::const_iterator upper_bound(const Container &cont, const T &value, Predicate pred) +{ + return std::upper_bound(cont.begin(), cont.end(), value, pred); +} + template inline void sort(Container &cont) {