Skip to content

Commit 48cb5a5

Browse files
SvRgK11010Jlucblu
authored andcommitted
59 Replace THashSet to std::unordered_set (#96)
1 parent f2d50f5 commit 48cb5a5

38 files changed

+84
-672
lines changed

client/ydb_persqueue_core/ut/read_session_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,8 @@ Y_UNIT_TEST_SUITE(ReadSessionImplTest) {
13201320
std::cerr << "Compressed message data size: " << compressedMessageData.size() << std::endl;
13211321
ui64 offset = 1;
13221322
ui64 seqNo = 42;
1323-
THashSet<ui64> committedCookies;
1324-
THashSet<ui64> committedOffsets;
1323+
std::unordered_set<ui64> committedCookies;
1324+
std::unordered_set<ui64> committedOffsets;
13251325
EXPECT_CALL(*setup.MockProcessor, OnCommitRequest(_))
13261326
.WillRepeatedly(Invoke([&committedCookies, &committedOffsets](const Ydb::PersQueue::V1::MigrationStreamingReadClientMessage::Commit& req) {
13271327
for (const auto& commit : req.cookies()) {

client/ydb_persqueue_core/ut/ut_utils/test_server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class TTestServer {
136136

137137
if (killPq)
138138
{
139-
THashSet<ui64> restartedTablets;
139+
std::unordered_set<ui64> restartedTablets;
140140
for (const auto& p : persQueueGroup.GetPartitions())
141141
if (restartedTablets.insert(p.GetTabletId()).second)
142142
{

client/ydb_persqueue_core/ut/ut_utils/ut_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace NYdb::NPersQueue::NTests {
44

55
void WaitMessagesAcked(std::shared_ptr<IWriteSession> writer, ui64 startSeqNo, ui64 endSeqNo) {
6-
THashSet<ui64> ackedSeqNo;
6+
std::unordered_set<ui64> ackedSeqNo;
77
while (ackedSeqNo.size() < endSeqNo - startSeqNo + 1) {
88
auto event = *writer->GetEvent(true);
99
if (std::holds_alternative<TWriteSessionEvent::TReadyToAcceptEvent>(event)) {

library/cpp/cache/cache.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include <util/generic/algorithm.h>
44
#include <util/generic/ptr.h>
55
#include <util/generic/intrlist.h>
6-
#include <util/generic/hash_set.h>
76
#include <util/generic/yexception.h>
87
#include <utility>
8+
#include <unordered_set>
99

1010
template <class TValue>
1111
struct TUniformSizeProvider {
@@ -67,6 +67,7 @@ class TLRUList {
6767
TValue Value;
6868

6969
struct THash {
70+
using is_transparent = void;
7071
size_t operator()(const TItem& item) const {
7172
return ::THash<TKey>()(item.Key);
7273
}
@@ -76,6 +77,7 @@ class TLRUList {
7677
};
7778

7879
struct TEqualTo {
80+
using is_transparent = void;
7981
bool operator()(const TItem& lhs, const TItem& rhs) const {
8082
return lhs.Key == rhs.Key;
8183
}
@@ -203,6 +205,7 @@ class TLFUList {
203205
size_t Counter;
204206

205207
struct THash {
208+
using is_transparent = void;
206209
size_t operator()(const TItem& item) const {
207210
return ::THash<TKey>()(item.Key);
208211
}
@@ -212,6 +215,7 @@ class TLFUList {
212215
};
213216

214217
struct TEqualTo {
218+
using is_transparent = void;
215219
bool operator()(const TItem& lhs, const TItem& rhs) const {
216220
return lhs.Key == rhs.Key;
217221
}
@@ -333,6 +337,7 @@ class TLWList {
333337
TWeight Weight;
334338

335339
struct THash {
340+
using is_transparent = void;
336341
size_t operator()(const TItem& item) const {
337342
return ::THash<TKey>()(item.Key);
338343
}
@@ -341,7 +346,8 @@ class TLWList {
341346
}
342347
};
343348

344-
struct TEqualTo {
349+
struct TEqualTo {
350+
using is_transparent = void;
345351
bool operator()(const TItem& lhs, const TItem& rhs) const {
346352
return lhs.Key == rhs.Key;
347353
}
@@ -446,17 +452,17 @@ class TLWList {
446452

447453
private:
448454
std::vector<TItem*> Heap;
449-
THashSet<TItem*> Removed;
455+
std::unordered_set<TItem*> Removed;
450456

451457
size_t Size;
452458
size_t MaxSize;
453459
};
454460

455-
template <typename TKey, typename TValue, typename TListType, typename TDeleter, typename TAllocator = std::allocator<void>>
461+
template <typename TKey, typename TValue, typename TListType, typename TDeleter, typename TAllocator = std::allocator<typename TListType::TItem>>
456462
class TCache {
457463
typedef typename TListType::TItem TItem;
458464
typedef typename TItem::THash THash;
459-
typedef THashMultiSet<TItem, THash, typename TItem::TEqualTo, TAllocator> TIndex;
465+
typedef std::unordered_multiset<TItem, THash, typename TItem::TEqualTo, TAllocator> TIndex;
460466
typedef typename TIndex::iterator TIndexIterator;
461467
typedef typename TIndex::const_iterator TIndexConstIterator;
462468

@@ -657,7 +663,7 @@ class TCache {
657663
Index.reserve(hint);
658664
}
659665

660-
typedef typename TIndex::node_allocator_type TNodeAllocatorType;
666+
typedef typename std::allocator_traits<typename TIndex::allocator_type>::template rebind_alloc<typename TIndex::value_type> TNodeAllocatorType;
661667
TNodeAllocatorType& GetNodeAllocator() {
662668
return Index.GetNodeAllocator();
663669
}
@@ -691,7 +697,7 @@ struct TNoopDelete {
691697
}
692698
};
693699

694-
template <typename TKey, typename TValue, typename TDeleter = TNoopDelete, class TSizeProvider = TUniformSizeProvider<TValue>, typename TAllocator = std::allocator<void>>
700+
template <typename TKey, typename TValue, typename TDeleter = TNoopDelete, class TSizeProvider = TUniformSizeProvider<TValue>, typename TAllocator = std::allocator<typename TLRUList<TKey, TValue, TSizeProvider>::TItem>>
695701
class TLRUCache: public TCache<TKey, TValue, TLRUList<TKey, TValue, TSizeProvider>, TDeleter, TAllocator> {
696702
using TListType = TLRUList<TKey, TValue, TSizeProvider>;
697703
typedef TCache<TKey, TValue, TListType, TDeleter, TAllocator> TBase;

library/cpp/charset/codepage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#include <util/generic/hash.h>
1010
#include <string>
1111

12-
#include <util/generic/hash_set.h>
1312
#include <util/generic/singleton.h>
1413
#include <util/generic/yexception.h>
1514
#include <util/memory/pool.h>
1615

1716
#include <cstring>
17+
#include <unordered_set>
1818

1919
#include <ctype.h>
2020

@@ -202,7 +202,7 @@ ECharset CharsetByNameOrDie(std::string_view name) {
202202
}
203203

204204
namespace {
205-
class THashSetType: public THashSet<std::string> {
205+
class THashSetType: public std::unordered_set<std::string> {
206206
public:
207207
inline void Add(const std::string& s) {
208208
insert(s);

library/cpp/charset/wide_ut.cpp

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

77
#include <util/charset/utf8.h>
88
#include <util/digest/numeric.h>
9-
#include <util/generic/hash_set.h>
109

1110
#include <algorithm>
11+
#include <unordered_set>
1212

1313
namespace {
1414
//! three UTF8 encoded russian letters (A, B, V)
@@ -346,7 +346,7 @@ void TConversionTest::TestRecode() {
346346
if (!SingleByteCodepage(enc))
347347
continue;
348348

349-
using THash = THashSet<char>;
349+
using THash = std::unordered_set<char>;
350350
THash hash;
351351

352352
for (int i = 0; i != 256; ++i) {

library/cpp/cppparser/parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <util/generic/hash.h>
22
#include <util/string/cast.h>
3-
#include <util/generic/hash_set.h>
43
#include <util/generic/yexception.h>
4+
#include <unordered_set>
55

66
#include "parser.h"
77

@@ -558,7 +558,7 @@ void TCppSimpleSax::DoCode(const TText& text) {
558558
}
559559

560560
class TCppFullSax::TImpl {
561-
typedef THashSet<std::string> TKeyWords;
561+
typedef std::unordered_set<std::string> TKeyWords;
562562

563563
class TRegExp {
564564
public:

library/cpp/dbg_output/dump.h

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

88
#include <util/stream/format.h>
99
#include <util/system/type_name.h>
10-
#include <util/generic/hash_set.h>
1110
#include <utility>
11+
#include <unordered_set>
1212

1313
/*
1414
* std::cout << DbgDump(any) << std::endl;
@@ -59,7 +59,7 @@ namespace NPrivate {
5959
}
6060
}
6161

62-
THashSet<size_t> Visited;
62+
std::unordered_set<size_t> Visited;
6363
};
6464
};
6565

library/cpp/dbg_output/dumpers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <map>
99
#include <string>
1010
#include <string_view>
11+
#include <unordered_set>
1112

1213
//smart pointers
1314
template <class T, class D>
@@ -139,11 +140,11 @@ struct TDumper<THashMultiMap<K, V, H, P, A>>: public TAssocDumper {
139140
};
140141

141142
template <class T, class H, class P, class A>
142-
struct TDumper<THashSet<T, H, P, A>>: public TAssocDumper {
143+
struct TDumper<std::unordered_set<T, H, P, A>>: public TAssocDumper {
143144
};
144145

145146
template <class T, class H, class P, class A>
146-
struct TDumper<THashMultiSet<T, H, P, A>>: public TAssocDumper {
147+
struct TDumper<std::unordered_multiset<T, H, P, A>>: public TAssocDumper {
147148
};
148149

149150
//strings

library/cpp/getopt/small/completion_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ namespace NLastGetopt {
246246
void TZshCompletionGenerator::GenerateOptCompletion(TFormattedOutput& out, const TOpts& opts, const TOpt& opt, NComp::TCompleterManager& manager) {
247247
auto& line = L;
248248

249-
THashSet<std::string> disableOptions;
249+
std::unordered_set<std::string> disableOptions;
250250
if (opt.DisableCompletionForOptions_) {
251251
disableOptions.insert("-");
252252
} else {

0 commit comments

Comments
 (0)