aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/algorithm.h
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-06-02 01:34:52 +0300
committerswarmer <swarmer@yandex-team.ru>2022-06-02 01:34:52 +0300
commitdec29e24bcc1d4208ad6f72e60c5b70037a4748d (patch)
treeaf1575eae3f3b2b78f0f657e69a2e8244f2df390 /util/generic/algorithm.h
parente673b301b03ea16c0bdc9537de9501f1c9b4cf28 (diff)
downloadydb-dec29e24bcc1d4208ad6f72e60c5b70037a4748d.tar.gz
[util] IsSortedBy for containers
ref:6c01516241e312227b7654b6b0260add648c8609
Diffstat (limited to 'util/generic/algorithm.h')
-rw-r--r--util/generic/algorithm.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index f910c79b1a..bce242679f 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -729,6 +729,13 @@ constexpr bool IsSortedBy(TIterator begin, TIterator end, const TGetKey& getKey)
return IsSorted(begin, end, [&](auto&& left, auto&& right) { return getKey(left) < getKey(right); });
}
+template <class TContainer, typename TGetKey>
+constexpr bool IsSortedBy(const TContainer& c, const TGetKey& getKey) {
+ using std::begin;
+ using std::end;
+ return IsSortedBy(begin(c), end(c), getKey);
+}
+
template <class It, class Val>
constexpr void Iota(It begin, It end, Val val) {
std::iota(begin, end, val);