diff options
| author | Ruslan Kovalev <[email protected]> | 2022-02-10 16:46:45 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:46:45 +0300 | 
| commit | 9123176b341b6f2658cff5132482b8237c1416c8 (patch) | |
| tree | 49e222ea1c5804306084bb3ae065bb702625360f /util/generic/algorithm.h | |
| parent | 59e19371de37995fcb36beb16cd6ec030af960bc (diff) | |
Restoring authorship annotation for Ruslan Kovalev <[email protected]>. Commit 2 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 3d73275c311..badfb889933 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()); | 
