diff options
author | Ruslan Kovalev <ruslan.a.kovalev@gmail.com> | 2022-02-10 16:46:44 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:44 +0300 |
commit | 59e19371de37995fcb36beb16cd6ec030af960bc (patch) | |
tree | fa68e36093ebff8b805462e9e6d331fe9d348214 /util/generic/algorithm.h | |
parent | 89db6fe2fe2c32d2a832ddfeb04e8d078e301084 (diff) | |
download | ydb-59e19371de37995fcb36beb16cd6ec030af960bc.tar.gz |
Restoring authorship annotation for Ruslan Kovalev <ruslan.a.kovalev@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/generic/algorithm.h')
-rw-r--r-- | util/generic/algorithm.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index badfb88993..3d73275c31 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "is_in.h" #include "utility.h" @@ -308,11 +308,11 @@ static inline T Unique(T f, T l, P p) { return std::unique(f, l, p); } -template <class T, class TGetKey> -static inline T UniqueBy(T f, T l, const TGetKey& getKey) { - return Unique(f, l, [&](auto&& left, auto&& right) { return getKey(left) == getKey(right); }); -} - +template <class T, class TGetKey> +static inline T UniqueBy(T f, T l, const TGetKey& getKey) { + return Unique(f, l, [&](auto&& left, auto&& right) { return getKey(left) == getKey(right); }); +} + template <class C> void SortUnique(C& c) { Sort(c.begin(), c.end()); @@ -325,18 +325,18 @@ void SortUnique(C& c, Cmp cmp) { c.erase(Unique(c.begin(), c.end()), c.end()); } -template <class C, class TGetKey> -void SortUniqueBy(C& c, const TGetKey& getKey) { - SortBy(c, getKey); +template <class C, class TGetKey> +void SortUniqueBy(C& c, const TGetKey& getKey) { + SortBy(c, getKey); c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); -} - -template <class C, class TGetKey> -void StableSortUniqueBy(C& c, const TGetKey& getKey) { - StableSortBy(c, getKey); +} + +template <class C, class TGetKey> +void StableSortUniqueBy(C& c, const TGetKey& getKey) { + StableSortBy(c, getKey); c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end()); -} - +} + template <class C, class TValue> void Erase(C& c, const TValue& value) { c.erase(std::remove(c.begin(), c.end(), value), c.end()); |