From fa87d901ba9fa075e51637608902b7fbdd71f896 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 2 Apr 2021 14:05:04 +0300 Subject: [PATCH] Add wrappers for lower_bound and upper_bound --- source/core/algorithm.h | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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) { -- 2.45.2