aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorsukhoi <sukhoi@yandex-team.ru>2022-02-10 16:51:35 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:51:35 +0300
commit01b069525b0643380d885e1549f9d1f1ecdfbb24 (patch)
treef857c21c9a7251b69e4a6898cc87c652895ce110 /util/generic
parente81e6b392d3d3c42324819910b7af32119e85a11 (diff)
downloadydb-01b069525b0643380d885e1549f9d1f1ecdfbb24.tar.gz
Restoring authorship annotation for <sukhoi@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/algorithm.h20
-rw-r--r--util/generic/algorithm_ut.cpp28
2 files changed, 24 insertions, 24 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index badfb88993..aa700a7c04 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -313,18 +313,18 @@ 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());
+template <class C>
+void SortUnique(C& c) {
+ Sort(c.begin(), c.end());
c.erase(Unique(c.begin(), c.end()), c.end());
-}
-
-template <class C, class Cmp>
-void SortUnique(C& c, Cmp cmp) {
- Sort(c.begin(), c.end(), cmp);
+}
+
+template <class C, class Cmp>
+void SortUnique(C& c, Cmp cmp) {
+ Sort(c.begin(), c.end(), 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);
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 8d732fcc0c..1b6f8595dc 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -224,7 +224,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
TVector<int> empty;
UNIT_ASSERT_EQUAL(NPOS, FindIndex(empty, 0));
}
-
+
Y_UNIT_TEST(FindIndexIfTest) {
TVectorNoCopy v;
v.push_back(1);
@@ -248,23 +248,23 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(SortUniqueTest) {
- {
+ {
TVector<TString> v;
- SortUnique(v);
+ SortUnique(v);
UNIT_ASSERT_EQUAL(v, TVector<TString>());
- }
-
- {
- const char* ar[] = {"345", "3", "123", "2", "23", "3", "2"};
+ }
+
+ {
+ const char* ar[] = {"345", "3", "123", "2", "23", "3", "2"};
TVector<TString> v(ar, ar + Y_ARRAY_SIZE(ar));
- SortUnique(v);
-
- const char* suAr[] = {"123", "2", "23", "3", "345"};
+ SortUnique(v);
+
+ const char* suAr[] = {"123", "2", "23", "3", "345"};
TVector<TString> suV(suAr, suAr + Y_ARRAY_SIZE(suAr));
-
- UNIT_ASSERT_EQUAL(v, suV);
- }
- }
+
+ UNIT_ASSERT_EQUAL(v, suV);
+ }
+ }
Y_UNIT_TEST(EraseTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};