Skip to content

Commit cc17eb0

Browse files
authored
Replace 'T[Multi]Set' to 'std::[multi]set' (ydb-platform#57) (ydb-platform#248)
1 parent c0cf10a commit cc17eb0

File tree

19 files changed

+74
-516
lines changed

19 files changed

+74
-516
lines changed

include/ydb-cpp-sdk/util/generic/fwd.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ template <class TValue, class TCmp>
3737
class TRbTree;
3838

3939
//containers
40-
template <class K, class L = TLess<K>, class A = std::allocator<K>>
41-
class TSet;
42-
43-
template <class K, class L = TLess<K>, class A = std::allocator<K>>
44-
class TMultiSet;
45-
4640
template <class T, class S = std::deque<T>>
4741
class TStack;
4842

include/ydb-cpp-sdk/util/ysaveload.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,6 @@ template <class T1, class T2, class T3, class T4, class T5>
598598
class TSerializer<std::unordered_multimap<T1, T2, T3, T4, T5>>: public TMapSerializer<std::unordered_multimap<T1, T2, T3, T4, T5>, false> {
599599
};
600600

601-
template <class K, class C, class A>
602-
class TSerializer<TSet<K, C, A>>: public TSetSerializer<TSet<K, C, A>, true> {
603-
};
604-
605601
template <class K, class C, class A>
606602
class TSerializer<std::set<K, C, A>>: public TSetSerializer<std::set<K, C, A>, true> {
607603
};

src/library/cache/cache.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#pragma once
22

3+
#include <ydb-cpp-sdk/util/str_stl.h>
34
#include <ydb-cpp-sdk/util/generic/algorithm.h>
45
#include <ydb-cpp-sdk/util/generic/ptr.h>
5-
#include <src/util/generic/intrlist.h>
66
#include <ydb-cpp-sdk/util/generic/yexception.h>
7+
8+
#include <src/util/generic/intrlist.h>
9+
710
#include <utility>
811
#include <unordered_set>
912

@@ -346,8 +349,8 @@ class TLWList {
346349
}
347350
};
348351

349-
struct TEqualTo {
350-
using is_transparent = void;
352+
struct TEqualTo {
353+
using is_transparent = void;
351354
bool operator()(const TItem& lhs, const TItem& rhs) const {
352355
return lhs.Key == rhs.Key;
353356
}

src/library/dbg_output/dumpers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <list>
88
#include <map>
9+
#include <set>
910
#include <span>
1011
#include <string>
1112
#include <string_view>
@@ -126,11 +127,11 @@ struct TDumper<std::multimap<K, V, P, A>>: public TAssocDumper {
126127
};
127128

128129
template <class T, class P, class A>
129-
struct TDumper<TSet<T, P, A>>: public TAssocDumper {
130+
struct TDumper<std::set<T, P, A>>: public TAssocDumper {
130131
};
131132

132133
template <class T, class P, class A>
133-
struct TDumper<TMultiSet<T, P, A>>: public TAssocDumper {
134+
struct TDumper<std::multiset<T, P, A>>: public TAssocDumper {
134135
};
135136

136137
template <class K, class V, class H, class P, class A>

src/library/http/io/headers_ut.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#include <src/util/generic/set.h>
1+
#include <ydb-cpp-sdk/library/http/io/headers.h>
2+
3+
#include <src/library/testing/unittest/registar.h>
4+
5+
#include <set>
26
#include <string>
37
#include <string_view>
48
#include <utility>
59

6-
#include <src/library/http/io/headers.h>
7-
#include <src/library/testing/unittest/registar.h>
8-
910
namespace {
1011
class THeadersExistence {
1112
public:
@@ -29,7 +30,7 @@ namespace {
2930
}
3031

3132
private:
32-
typedef TMultiSet<std::pair<std::string, std::string>> TImpl;
33+
using TImpl = std::multiset<std::pair<std::string, std::string>>;
3334
TImpl Impl;
3435
};
3536
}
@@ -53,8 +54,8 @@ class THttpHeadersTest: public TTestBase {
5354
UNIT_TEST_SUITE_END();
5455

5556
private:
56-
typedef void (*TAddHeaderFunction)(THttpHeaders&, std::string_view name, std::string_view value);
57-
typedef void (*TAddOrReplaceHeaderFunction)(THttpHeaders&, std::string_view name, std::string_view value);
57+
using TAddHeaderFunction = void (*)(THttpHeaders&, std::string_view name, std::string_view value);
58+
using TAddOrReplaceHeaderFunction = void (*)(THttpHeaders&, std::string_view name, std::string_view value);
5859

5960
public:
6061
void TestAddOperation1Arg();

src/library/monlib/encode/json/json_ut.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#include <ydb-cpp-sdk/library/monlib/encode/json/json.h>
22

3-
#include <src/library/monlib/encode/protobuf/protobuf.h>
43
#include <ydb-cpp-sdk/library/monlib/metrics/labels.h>
54

65
#include <ydb-cpp-sdk/library/json/json_reader.h>
76
#include <ydb-cpp-sdk/library/resource/resource.h>
8-
#include <src/library/testing/unittest/registar.h>
97

108
#include <ydb-cpp-sdk/util/stream/str.h>
119
#include <ydb-cpp-sdk/util/string/builder.h>
1210

11+
#include <src/library/monlib/encode/protobuf/protobuf.h>
12+
#include <src/library/testing/unittest/registar.h>
13+
1314
#include <iostream>
1415
#include <limits>
1516

@@ -25,8 +26,8 @@ namespace {
2526
void AssertLabels(const NProto::TMultiSample& actual, const TLabels& expected) {
2627
UNIT_ASSERT_EQUAL(actual.LabelsSize(), expected.Size());
2728

28-
TSet<TLabel> actualSet;
29-
TSet<TLabel> expectedSet;
29+
std::set<TLabel> actualSet;
30+
std::set<TLabel> expectedSet;
3031
Transform(expected.begin(), expected.end(), std::inserter(expectedSet, expectedSet.end()), [] (auto&& l) {
3132
return TLabel{l.Name(), l.Value()};
3233
});

src/library/object_factory/object_factory.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include <ydb-cpp-sdk/util/system/guard.h>
44
#include <ydb-cpp-sdk/util/system/rwlock.h>
5-
#include <src/util/generic/set.h>
65
#include <ydb-cpp-sdk/util/generic/singleton.h>
76
#include <ydb-cpp-sdk/util/generic/yexception.h>
87

98
#include <algorithm>
9+
#include <set>
1010
#include <map>
1111

1212
namespace NObjectFactory {
@@ -51,8 +51,8 @@ namespace NObjectFactory {
5151
template <class P, class K, class... TArgs>
5252
class IObjectFactory {
5353
public:
54-
typedef P TProduct;
55-
typedef K TKey;
54+
using TProduct = P;
55+
using TKey = K;
5656

5757
public:
5858
template <class TDerivedProduct>
@@ -70,7 +70,7 @@ namespace NObjectFactory {
7070
Register<TDerivedProduct>(key, new TFactoryObjectCreator<TProduct, TDerivedProduct, TArgs...>);
7171
}
7272

73-
void GetKeys(TSet<TKey>& keys) const {
73+
void GetKeys(std::set<TKey>& keys) const {
7474
TReadGuard guard(CreatorsLock);
7575
keys.clear();
7676
for (typename ICreators::const_iterator i = Creators.begin(), e = Creators.end(); i != e; ++i) {
@@ -93,8 +93,8 @@ namespace NObjectFactory {
9393
}
9494

9595
private:
96-
typedef TSimpleSharedPtr<IFactoryObjectCreator<TProduct, TArgs...>> ICreatorPtr;
97-
typedef std::map<TKey, ICreatorPtr> ICreators;
96+
using ICreatorPtr = TSimpleSharedPtr<IFactoryObjectCreator<TProduct, TArgs...>>;
97+
using ICreators = std::map<TKey, ICreatorPtr>;
9898
ICreators Creators;
9999
TRWMutex CreatorsLock;
100100
};
@@ -139,20 +139,20 @@ namespace NObjectFactory {
139139
return THolder<TProduct>(Construct(std::forward<Args>(args)...));
140140
}
141141

142-
static void GetRegisteredKeys(TSet<TKey>& keys) {
142+
static void GetRegisteredKeys(std::set<TKey>& keys) {
143143
return Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->GetKeys(keys);
144144
}
145145

146-
static TSet<TKey> GetRegisteredKeys() {
147-
TSet<TKey> keys;
146+
static std::set<TKey> GetRegisteredKeys() {
147+
std::set<TKey> keys;
148148
Singleton<TParametrizedObjectFactory<TProduct, TKey, TArgs...>>()->GetKeys(keys);
149149
return keys;
150150
}
151151

152152
template <class TDerivedProduct>
153-
static TSet<TKey> GetRegisteredKeys() {
154-
TSet<TKey> registeredKeys(GetRegisteredKeys());
155-
TSet<TKey> fileredKeys;
153+
static std::set<TKey> GetRegisteredKeys() {
154+
std::set<TKey> registeredKeys(GetRegisteredKeys());
155+
std::set<TKey> fileredKeys;
156156
std::copy_if(registeredKeys.begin(), registeredKeys.end(), std::inserter(fileredKeys, fileredKeys.end()), [](const TKey& key) {
157157
THolder<TProduct> objectHolder(Construct(key));
158158
return !!dynamic_cast<const TDerivedProduct*>(objectHolder.Get());

src/library/testing/unittest/registar.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#include "registar.h"
22

3-
#include <src/library/diff/diff.h>
4-
#include <src/library/colorizer/colors.h>
5-
63
#include <ydb-cpp-sdk/util/generic/bt_exception.h>
7-
#include <src/util/random/fast.h>
84
#include <ydb-cpp-sdk/util/system/backtrace.h>
95
#include <ydb-cpp-sdk/util/system/guard.h>
10-
#include <src/util/system/tls.h>
116
#include <ydb-cpp-sdk/util/system/error.h>
127
#include <ydb-cpp-sdk/util/string/cast.h>
138

9+
#include <src/util/random/fast.h>
10+
#include <src/util/system/tls.h>
11+
12+
#include <src/library/diff/diff.h>
13+
#include <src/library/colorizer/colors.h>
14+
15+
#include <set>
1416
#include <mutex>
1517

1618
using namespace std::string_literals;
@@ -472,7 +474,7 @@ unsigned NUnitTest::TTestFactory::Execute() {
472474
Items_.QuickSort(TCmp());
473475
Processor_->Start();
474476

475-
TSet<std::string> types;
477+
std::set<std::string> types;
476478
size_t cnt = 0;
477479

478480
for (TIntrusiveList<ITestBaseFactory>::TIterator factory = Items_.Begin(); factory != Items_.End(); ++factory) {

src/library/testing/unittest/registar.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#pragma once
22

3-
#include <src/library/dbg_output/dump.h>
4-
53
#include <ydb-cpp-sdk/util/generic/bt_exception.h>
6-
#include <src/util/generic/intrlist.h>
74
#include <ydb-cpp-sdk/util/generic/ptr.h>
8-
#include <src/util/generic/scope.h>
9-
#include <src/util/generic/set.h>
105
#include <ydb-cpp-sdk/util/generic/typetraits.h>
11-
126
#include <ydb-cpp-sdk/util/generic/yexception.h>
137

148
#include <ydb-cpp-sdk/util/string/builder.h>
@@ -19,8 +13,13 @@
1913
#include <ydb-cpp-sdk/util/system/spinlock.h>
2014
#include <ydb-cpp-sdk/util/system/src_location.h>
2115

16+
#include <src/util/generic/intrlist.h>
17+
#include <src/util/generic/scope.h>
18+
2219
#include <src/util/system/rusage.h>
2320

21+
#include <src/library/dbg_output/dump.h>
22+
2423
#include <cmath>
2524
#include <span>
2625
#include <cstdio>
@@ -266,7 +265,7 @@ namespace NUnitTest {
266265
};
267266

268267
#define UNIT_TEST_SUITE(N) \
269-
typedef N TThisUnitTestSuite; \
268+
using TThisUnitTestSuite = N; \
270269
\
271270
public: \
272271
static std::string StaticName() noexcept { \
@@ -282,7 +281,7 @@ private: \
282281
this->AtStart();
283282

284283
#define UNIT_TEST_SUITE_DEMANGLE(N) \
285-
typedef N TThisUnitTestSuite; \
284+
using TThisUnitTestSuite = N; \
286285
\
287286
public: \
288287
static std::string StaticName() noexcept { \
@@ -1022,8 +1021,8 @@ public: \
10221021
}; \
10231022
class TCurrentTest: public T { \
10241023
private: \
1025-
typedef std::function<THolder<NUnitTest::TBaseTestCase>()> TTestCaseFactory; \
1026-
typedef std::vector<TTestCaseFactory> TTests; \
1024+
using TTestCaseFactory = std::function<THolder<NUnitTest::TBaseTestCase>()>; \
1025+
using TTests = std::vector<TTestCaseFactory>; \
10271026
\
10281027
static TTests& Tests() { \
10291028
static TTests tests; \

src/library/threading/chunk_queue/queue_ut.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <src/library/testing/unittest/registar.h>
44

5-
#include <src/util/generic/set.h>
5+
#include <set>
66

77
namespace NThreading {
88
////////////////////////////////////////////////////////////////////////////////
@@ -136,7 +136,7 @@ UNIT_ASSERT(!queue.Dequeue(result));
136136
}
137137

138138
Y_UNIT_TEST(ShouldReturnEntries) {
139-
TSet<int> items = {1, 2, 3};
139+
std::set<int> items = {1, 2, 3};
140140

141141
TRelaxedManyOneQueue<int> queue;
142142
for (int item : items) {
@@ -173,7 +173,7 @@ UNIT_ASSERT(!queue.Dequeue(result));
173173
}
174174

175175
Y_UNIT_TEST(ShouldReturnEntries) {
176-
TSet<int> items = {1, 2, 3};
176+
std::set<int> items = {1, 2, 3};
177177

178178
TRelaxedManyManyQueue<int> queue;
179179
for (int item : items) {

src/util/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ target_joined_source(yutil
7575
${YDB_SDK_SOURCE_DIR}/src/util/generic/ptr.cpp
7676
${YDB_SDK_SOURCE_DIR}/src/util/generic/refcount.cpp
7777
${YDB_SDK_SOURCE_DIR}/src/util/generic/scope.cpp
78-
${YDB_SDK_SOURCE_DIR}/src/util/generic/set.cpp
7978
${YDB_SDK_SOURCE_DIR}/src/util/generic/singleton.cpp
8079
${YDB_SDK_SOURCE_DIR}/src/util/generic/size_literals.cpp
8180
${YDB_SDK_SOURCE_DIR}/src/util/generic/stack.cpp

src/util/generic/algorithm_ut.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <ydb-cpp-sdk/util/generic/algorithm.h>
44

5+
#include <set>
6+
57
static auto isOne = [](char c) { return c == '1'; };
68

79
Y_UNIT_TEST_SUITE(TAlgorithm) {
@@ -289,13 +291,13 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
289291
EraseNodesIf(multiMap, [](auto p) { return p.first >= 2; });
290292
UNIT_ASSERT_EQUAL(multiMap, expectedMultiMap);
291293

292-
TSet<int> set{1, 2, 3, 4, 5, 6, 7};
293-
TSet<int> expectedSet{1, 3, 5, 7};
294+
std::set<int> set{1, 2, 3, 4, 5, 6, 7};
295+
std::set<int> expectedSet{1, 3, 5, 7};
294296
EraseNodesIf(set, [](int i) { return i % 2 == 0; });
295297
UNIT_ASSERT_EQUAL(set, expectedSet);
296298

297-
TMultiSet<int> multiSet{1, 1, 2, 3, 4, 4, 4, 5, 5, 5, 6, 7};
298-
TMultiSet<int> expectedMultiSet{1, 1, 3, 5, 5, 5, 7};
299+
std::multiset<int> multiSet{1, 1, 2, 3, 4, 4, 4, 5, 5, 5, 6, 7};
300+
std::multiset<int> expectedMultiSet{1, 1, 3, 5, 5, 5, 7};
299301
EraseNodesIf(multiSet, [](int i) { return i % 2 == 0; });
300302
UNIT_ASSERT_EQUAL(multiSet, expectedMultiSet);
301303

src/util/generic/is_in_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Y_UNIT_TEST_SUITE(TIsIn) {
3838
TestIsInWithCont<std::unordered_map<std::string, std::string>>(std::make_pair("found", "1"));
3939
TestIsInWithCont<std::unordered_multimap<std::string, std::string>>(std::make_pair("found", "1"));
4040

41-
TestIsInWithCont<TSet<std::string>>("found");
42-
TestIsInWithCont<TMultiSet<std::string>>("found");
41+
TestIsInWithCont<std::set<std::string>>("found");
42+
TestIsInWithCont<std::multiset<std::string>>("found");
4343
TestIsInWithCont<std::unordered_set<std::string>>("found");
4444
TestIsInWithCont<std::unordered_multiset<std::string>>("found");
4545

src/util/generic/set.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)