LLVM 22.0.0git
StringMap.h
Go to the documentation of this file.
1//===- StringMap.h - String Hash table map interface ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the StringMap class.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ADT_STRINGMAP_H
15#define LLVM_ADT_STRINGMAP_H
16
18#include "llvm/ADT/iterator.h"
22#include <initializer_list>
23#include <iterator>
24
25namespace llvm {
26
27template <typename ValueTy> class StringMapConstIterator;
28template <typename ValueTy> class StringMapIterator;
29template <typename ValueTy> class StringMapKeyIterator;
30
31/// StringMapImpl - This is the base class of StringMap that is shared among
32/// all of its instantiations.
34protected:
35 // Array of NumBuckets pointers to entries, null pointers are holes.
36 // TheTable[NumBuckets] contains a sentinel value for easy iteration. Followed
37 // by an array of the actual hash values as unsigned integers.
39 unsigned NumBuckets = 0;
40 unsigned NumItems = 0;
41 unsigned NumTombstones = 0;
42 unsigned ItemSize;
43
44protected:
45 explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {}
50 RHS.TheTable = nullptr;
51 RHS.NumBuckets = 0;
52 RHS.NumItems = 0;
53 RHS.NumTombstones = 0;
54 }
55
56 LLVM_ABI StringMapImpl(unsigned InitSize, unsigned ItemSize);
58 LLVM_ABI unsigned RehashTable(unsigned BucketNo = 0);
59
60 /// LookupBucketFor - Look up the bucket that the specified string should end
61 /// up in. If it already exists as a key in the map, the Item pointer for the
62 /// specified bucket will be non-null. Otherwise, it will be null. In either
63 /// case, the FullHashValue field of the bucket will be set to the hash value
64 /// of the string.
65 unsigned LookupBucketFor(StringRef Key) {
66 return LookupBucketFor(Key, hash(Key));
67 }
68
69 /// Overload that explicitly takes precomputed hash(Key).
70 LLVM_ABI unsigned LookupBucketFor(StringRef Key, uint32_t FullHashValue);
71
72 /// FindKey - Look up the bucket that contains the specified key. If it exists
73 /// in the map, return the bucket number of the key. Otherwise return -1.
74 /// This does not modify the map.
75 int FindKey(StringRef Key) const { return FindKey(Key, hash(Key)); }
76
77 /// Overload that explicitly takes precomputed hash(Key).
78 LLVM_ABI int FindKey(StringRef Key, uint32_t FullHashValue) const;
79
80 /// RemoveKey - Remove the specified StringMapEntry from the table, but do not
81 /// delete it. This aborts if the value isn't in the table.
83
84 /// RemoveKey - Remove the StringMapEntry for the specified key from the
85 /// table, returning it. If the key is not in the table, this returns null.
87
88 /// Allocate the table with the specified number of buckets and otherwise
89 /// setup the map as empty.
90 LLVM_ABI void init(unsigned Size);
91
94 }
95
96public:
97 static constexpr uintptr_t TombstoneIntVal =
98 static_cast<uintptr_t>(-1)
100
102 return reinterpret_cast<StringMapEntryBase *>(TombstoneIntVal);
103 }
104
105 unsigned getNumBuckets() const { return NumBuckets; }
106 unsigned getNumItems() const { return NumItems; }
107
108 bool empty() const { return NumItems == 0; }
109 unsigned size() const { return NumItems; }
110
111 /// Returns the hash value that will be used for the given string.
112 /// This allows precomputing the value and passing it explicitly
113 /// to some of the functions.
114 /// The implementation of this function is not guaranteed to be stable
115 /// and may change.
116 LLVM_ABI static uint32_t hash(StringRef Key);
117
119 std::swap(TheTable, Other.TheTable);
120 std::swap(NumBuckets, Other.NumBuckets);
121 std::swap(NumItems, Other.NumItems);
122 std::swap(NumTombstones, Other.NumTombstones);
123 }
124};
125
126/// StringMap - This is an unconventional map that is specialized for handling
127/// keys that are "strings", which are basically ranges of bytes. This does some
128/// funky memory allocation and hashing things to make it extremely efficient,
129/// storing the string data *after* the value in the map.
130template <typename ValueTy, typename AllocatorTy = MallocAllocator>
132 : public StringMapImpl,
133 private detail::AllocatorHolder<AllocatorTy> {
135
136public:
138
139 StringMap() : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {}
140
141 explicit StringMap(unsigned InitialSize)
142 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))) {}
143
144 explicit StringMap(AllocatorTy A)
145 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))), AllocTy(A) {}
146
147 StringMap(unsigned InitialSize, AllocatorTy A)
148 : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
149 AllocTy(A) {}
150
151 StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
152 : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {
153 insert(List);
154 }
155
157 : StringMapImpl(std::move(RHS)), AllocTy(std::move(RHS.getAllocator())) {}
158
160 : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))),
161 AllocTy(RHS.getAllocator()) {
162 if (RHS.empty())
163 return;
164
165 // Allocate TheTable of the same size as RHS's TheTable, and set the
166 // sentinel appropriately (and NumBuckets).
167 init(RHS.NumBuckets);
168 unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1),
169 *RHSHashTable = (unsigned *)(RHS.TheTable + NumBuckets + 1);
170
171 NumItems = RHS.NumItems;
172 NumTombstones = RHS.NumTombstones;
173 for (unsigned I = 0, E = NumBuckets; I != E; ++I) {
174 StringMapEntryBase *Bucket = RHS.TheTable[I];
175 if (!Bucket || Bucket == getTombstoneVal()) {
176 TheTable[I] = Bucket;
177 continue;
178 }
179
180 TheTable[I] = MapEntryTy::create(
181 static_cast<MapEntryTy *>(Bucket)->getKey(), getAllocator(),
182 static_cast<MapEntryTy *>(Bucket)->getValue());
183 HashTable[I] = RHSHashTable[I];
184 }
185
186 // Note that here we've copied everything from the RHS into this object,
187 // tombstones included. We could, instead, have re-probed for each key to
188 // instantiate this new object without any tombstone buckets. The
189 // assumption here is that items are rarely deleted from most StringMaps,
190 // and so tombstones are rare, so the cost of re-probing for all inputs is
191 // not worthwhile.
192 }
193
195 StringMapImpl::swap(RHS);
196 std::swap(getAllocator(), RHS.getAllocator());
197 return *this;
198 }
199
201 // Delete all the elements in the map, but don't reset the elements
202 // to default values. This is a copy of clear(), but avoids unnecessary
203 // work not required in the destructor.
204 if (!empty()) {
205 for (StringMapEntryBase *Bucket : buckets()) {
206 if (Bucket && Bucket != getTombstoneVal()) {
207 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
208 }
209 }
210 }
211 }
212
213 using AllocTy::getAllocator;
214
215 using key_type = const char *;
216 using mapped_type = ValueTy;
218 using size_type = size_t;
219
222
223 iterator begin() { return iterator(TheTable, NumBuckets == 0); }
224 iterator end() { return iterator(TheTable + NumBuckets, true); }
226 return const_iterator(TheTable, NumBuckets == 0);
227 }
229 return const_iterator(TheTable + NumBuckets, true);
230 }
231
235 }
236
237 iterator find(StringRef Key) { return find(Key, hash(Key)); }
238
239 iterator find(StringRef Key, uint32_t FullHashValue) {
240 int Bucket = FindKey(Key, FullHashValue);
241 if (Bucket == -1)
242 return end();
243 return iterator(TheTable + Bucket, true);
244 }
245
246 const_iterator find(StringRef Key) const { return find(Key, hash(Key)); }
247
248 const_iterator find(StringRef Key, uint32_t FullHashValue) const {
249 int Bucket = FindKey(Key, FullHashValue);
250 if (Bucket == -1)
251 return end();
252 return const_iterator(TheTable + Bucket, true);
253 }
254
255 /// lookup - Return the entry for the specified key, or a default
256 /// constructed value if no such entry exists.
257 ValueTy lookup(StringRef Key) const {
258 const_iterator Iter = find(Key);
259 if (Iter != end())
260 return Iter->second;
261 return ValueTy();
262 }
263
264 /// at - Return the entry for the specified key, or abort if no such
265 /// entry exists.
266 const ValueTy &at(StringRef Val) const {
267 auto Iter = this->find(std::move(Val));
268 assert(Iter != this->end() && "StringMap::at failed due to a missing key");
269 return Iter->second;
270 }
271
272 /// Lookup the ValueTy for the \p Key, or create a default constructed value
273 /// if the key is not in the map.
274 ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
275
276 /// contains - Return true if the element is in the map, false otherwise.
277 bool contains(StringRef Key) const { return find(Key) != end(); }
278
279 /// count - Return 1 if the element is in the map, 0 otherwise.
280 size_type count(StringRef Key) const { return contains(Key) ? 1 : 0; }
281
282 template <typename InputTy>
283 size_type count(const StringMapEntry<InputTy> &MapEntry) const {
284 return count(MapEntry.getKey());
285 }
286
287 /// equal - check whether both of the containers are equal.
288 bool operator==(const StringMap &RHS) const {
289 if (size() != RHS.size())
290 return false;
291
292 for (const auto &KeyValue : *this) {
293 auto FindInRHS = RHS.find(KeyValue.getKey());
294
295 if (FindInRHS == RHS.end())
296 return false;
297
298 if constexpr (!std::is_same_v<ValueTy, std::nullopt_t>) {
299 if (!(KeyValue.getValue() == FindInRHS->getValue()))
300 return false;
301 }
302 }
303
304 return true;
305 }
306
307 bool operator!=(const StringMap &RHS) const { return !(*this == RHS); }
308
309 /// insert - Insert the specified key/value pair into the map. If the key
310 /// already exists in the map, return false and ignore the request, otherwise
311 /// insert it and return true.
312 bool insert(MapEntryTy *KeyValue) {
313 unsigned BucketNo = LookupBucketFor(KeyValue->getKey());
314 StringMapEntryBase *&Bucket = TheTable[BucketNo];
315 if (Bucket && Bucket != getTombstoneVal())
316 return false; // Already exists in map.
317
318 if (Bucket == getTombstoneVal())
319 --NumTombstones;
320 Bucket = KeyValue;
321 ++NumItems;
322 assert(NumItems + NumTombstones <= NumBuckets);
323
324 RehashTable();
325 return true;
326 }
327
328 /// insert - Inserts the specified key/value pair into the map if the key
329 /// isn't already in the map. The bool component of the returned pair is true
330 /// if and only if the insertion takes place, and the iterator component of
331 /// the pair points to the element with key equivalent to the key of the pair.
332 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV) {
333 return try_emplace_with_hash(KV.first, hash(KV.first),
334 std::move(KV.second));
335 }
336
337 std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV,
338 uint32_t FullHashValue) {
339 return try_emplace_with_hash(KV.first, FullHashValue, std::move(KV.second));
340 }
341
342 /// Inserts elements from range [first, last). If multiple elements in the
343 /// range have keys that compare equivalent, it is unspecified which element
344 /// is inserted .
345 template <typename InputIt> void insert(InputIt First, InputIt Last) {
346 for (InputIt It = First; It != Last; ++It)
347 insert(*It);
348 }
349
350 /// Inserts elements from initializer list ilist. If multiple elements in
351 /// the range have keys that compare equivalent, it is unspecified which
352 /// element is inserted
353 void insert(std::initializer_list<std::pair<StringRef, ValueTy>> List) {
354 insert(List.begin(), List.end());
355 }
356
357 /// Inserts an element or assigns to the current element if the key already
358 /// exists. The return type is the same as try_emplace.
359 template <typename V>
360 std::pair<iterator, bool> insert_or_assign(StringRef Key, V &&Val) {
361 auto Ret = try_emplace(Key, std::forward<V>(Val));
362 if (!Ret.second)
363 Ret.first->second = std::forward<V>(Val);
364 return Ret;
365 }
366
367 /// Emplace a new element for the specified key into the map if the key isn't
368 /// already in the map. The bool component of the returned pair is true
369 /// if and only if the insertion takes place, and the iterator component of
370 /// the pair points to the element with key equivalent to the key of the pair.
371 template <typename... ArgsTy>
372 std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
373 return try_emplace_with_hash(Key, hash(Key), std::forward<ArgsTy>(Args)...);
374 }
375
376 template <typename... ArgsTy>
377 std::pair<iterator, bool> try_emplace_with_hash(StringRef Key,
378 uint32_t FullHashValue,
379 ArgsTy &&...Args) {
380 unsigned BucketNo = LookupBucketFor(Key, FullHashValue);
381 StringMapEntryBase *&Bucket = TheTable[BucketNo];
382 if (Bucket && Bucket != getTombstoneVal())
383 return {iterator(TheTable + BucketNo, false),
384 false}; // Already exists in map.
385
386 if (Bucket == getTombstoneVal())
387 --NumTombstones;
388 Bucket =
389 MapEntryTy::create(Key, getAllocator(), std::forward<ArgsTy>(Args)...);
390 ++NumItems;
391 assert(NumItems + NumTombstones <= NumBuckets);
392
393 BucketNo = RehashTable(BucketNo);
394 return {iterator(TheTable + BucketNo, false), true};
395 }
396
397 // clear - Empties out the StringMap
398 void clear() {
399 if (empty())
400 return;
401
402 // Zap all values, resetting the keys back to non-present (not tombstone),
403 // which is safe because we're removing all elements.
404 for (StringMapEntryBase *&Bucket : buckets()) {
405 if (Bucket && Bucket != getTombstoneVal()) {
406 static_cast<MapEntryTy *>(Bucket)->Destroy(getAllocator());
407 }
408 Bucket = nullptr;
409 }
410
411 NumItems = 0;
412 NumTombstones = 0;
413 }
414
415 /// remove - Remove the specified key/value pair from the map, but do not
416 /// erase it. This aborts if the key is not in the map.
417 void remove(MapEntryTy *KeyValue) { RemoveKey(KeyValue); }
418
420 MapEntryTy &V = *I;
421 remove(&V);
422 V.Destroy(getAllocator());
423 }
424
425 bool erase(StringRef Key) {
426 iterator I = find(Key);
427 if (I == end())
428 return false;
429 erase(I);
430 return true;
431 }
432};
433
434template <typename DerivedTy, typename ValueTy>
436 : public iterator_facade_base<DerivedTy, std::forward_iterator_tag,
437 ValueTy> {
438protected:
440
441public:
442 StringMapIterBase() = default;
443
445 bool NoAdvance = false)
446 : Ptr(Bucket) {
447 if (!NoAdvance)
448 AdvancePastEmptyBuckets();
449 }
450
451 DerivedTy &operator=(const DerivedTy &Other) {
452 Ptr = Other.Ptr;
453 return static_cast<DerivedTy &>(*this);
454 }
455
456 friend bool operator==(const DerivedTy &LHS, const DerivedTy &RHS) {
457 return LHS.Ptr == RHS.Ptr;
458 }
459
460 DerivedTy &operator++() { // Preincrement
461 ++Ptr;
462 AdvancePastEmptyBuckets();
463 return static_cast<DerivedTy &>(*this);
464 }
465
466 DerivedTy operator++(int) { // Post-increment
467 DerivedTy Tmp(Ptr);
468 ++*this;
469 return Tmp;
470 }
471
472private:
473 void AdvancePastEmptyBuckets() {
474 while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
475 ++Ptr;
476 }
477};
478
479template <typename ValueTy>
481 : public StringMapIterBase<StringMapConstIterator<ValueTy>,
482 const StringMapEntry<ValueTy>> {
485
486public:
489 bool NoAdvance = false)
490 : base(Bucket, NoAdvance) {}
491
493 return *static_cast<const StringMapEntry<ValueTy> *>(*this->Ptr);
494 }
495};
496
497template <typename ValueTy>
498class StringMapIterator : public StringMapIterBase<StringMapIterator<ValueTy>,
499 StringMapEntry<ValueTy>> {
500 using base =
502
503public:
504 StringMapIterator() = default;
506 bool NoAdvance = false)
507 : base(Bucket, NoAdvance) {}
508
510 return *static_cast<StringMapEntry<ValueTy> *>(*this->Ptr);
511 }
512
514 return StringMapConstIterator<ValueTy>(this->Ptr, true);
515 }
516};
517
518template <typename ValueTy>
520 : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
521 StringMapConstIterator<ValueTy>,
522 std::forward_iterator_tag, StringRef> {
525 std::forward_iterator_tag, StringRef>;
526
527public:
530 : base(std::move(Iter)) {}
531
532 StringRef operator*() const { return this->wrapped()->getKey(); }
533};
534
535} // end namespace llvm
536
537#endif // LLVM_ADT_STRINGMAP_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMapEntry class - it is intended to be a low dependency implementation det...
This file defines MallocAllocator.
#define LLVM_ALLOCATORHOLDER_EMPTYBASE
Definition: AllocatorBase.h:25
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
uint64_t Size
#define I(x, y, z)
Definition: MD5.cpp:58
const NodeList & List
Definition: RDFGraph.cpp:200
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition: Value.cpp:480
static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)
Find KV in array using binary search.
Value * RHS
Value * LHS
StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
Definition: StringMap.h:488
const StringMapEntry< ValueTy > & operator*() const
Definition: StringMap.h:492
StringMapEntryBase - Shared base class of StringMapEntry instances.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef getKey() const
StringMapImpl - This is the base class of StringMap that is shared among all of its instantiations.
Definition: StringMap.h:33
iterator_range< StringMapEntryBase ** > buckets()
Definition: StringMap.h:92
void swap(StringMapImpl &Other)
Definition: StringMap.h:118
static StringMapEntryBase * getTombstoneVal()
Definition: StringMap.h:101
unsigned ItemSize
Definition: StringMap.h:42
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
Definition: StringMap.h:65
LLVM_ABI unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
Definition: StringMap.cpp:210
unsigned NumItems
Definition: StringMap.h:40
LLVM_ABI void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
Definition: StringMap.cpp:185
StringMapEntryBase ** TheTable
Definition: StringMap.h:38
unsigned getNumBuckets() const
Definition: StringMap.h:105
unsigned size() const
Definition: StringMap.h:109
StringMapImpl(unsigned itemSize)
Definition: StringMap.h:45
LLVM_ABI void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
Definition: StringMap.cpp:59
static LLVM_ABI uint32_t hash(StringRef Key)
Returns the hash value that will be used for the given string.
Definition: StringMap.cpp:46
unsigned getNumItems() const
Definition: StringMap.h:106
unsigned NumBuckets
Definition: StringMap.h:39
static constexpr uintptr_t TombstoneIntVal
Definition: StringMap.h:97
unsigned NumTombstones
Definition: StringMap.h:41
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
Definition: StringMap.h:75
bool empty() const
Definition: StringMap.h:108
StringMapImpl(StringMapImpl &&RHS)
Definition: StringMap.h:46
DerivedTy & operator++()
Definition: StringMap.h:460
StringMapEntryBase ** Ptr
Definition: StringMap.h:439
DerivedTy operator++(int)
Definition: StringMap.h:466
DerivedTy & operator=(const DerivedTy &Other)
Definition: StringMap.h:451
StringMapIterBase(StringMapEntryBase **Bucket, bool NoAdvance=false)
Definition: StringMap.h:444
friend bool operator==(const DerivedTy &LHS, const DerivedTy &RHS)
Definition: StringMap.h:456
StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
Definition: StringMap.h:505
StringMapEntry< ValueTy > & operator*() const
Definition: StringMap.h:509
StringRef operator*() const
Definition: StringMap.h:532
StringMapKeyIterator(StringMapConstIterator< ValueTy > Iter)
Definition: StringMap.h:529
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:133
size_type count(const StringMapEntry< InputTy > &MapEntry) const
Definition: StringMap.h:283
StringMap(StringMap &&RHS)
Definition: StringMap.h:156
bool erase(StringRef Key)
Definition: StringMap.h:425
iterator end()
Definition: StringMap.h:224
StringMap(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Definition: StringMap.h:151
bool operator!=(const StringMap &RHS) const
Definition: StringMap.h:307
iterator begin()
Definition: StringMap.h:223
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
Definition: StringMap.h:417
std::pair< iterator, bool > insert_or_assign(StringRef Key, V &&Val)
Inserts an element or assigns to the current element if the key already exists.
Definition: StringMap.h:360
iterator find(StringRef Key)
Definition: StringMap.h:237
const_iterator end() const
Definition: StringMap.h:228
StringMap(const StringMap &RHS)
Definition: StringMap.h:159
const ValueTy & at(StringRef Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
Definition: StringMap.h:266
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
Definition: StringMap.h:277
size_t size_type
Definition: StringMap.h:218
ValueTy mapped_type
Definition: StringMap.h:216
iterator find(StringRef Key, uint32_t FullHashValue)
Definition: StringMap.h:239
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV)
insert - Inserts the specified key/value pair into the map if the key isn't already in the map.
Definition: StringMap.h:332
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
Definition: StringMap.h:232
const_iterator find(StringRef Key) const
Definition: StringMap.h:246
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:280
StringMap(AllocatorTy A)
Definition: StringMap.h:144
StringMap & operator=(StringMap RHS)
Definition: StringMap.h:194
void insert(InputIt First, InputIt Last)
Inserts elements from range [first, last).
Definition: StringMap.h:345
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: StringMap.h:257
const_iterator find(StringRef Key, uint32_t FullHashValue) const
Definition: StringMap.h:248
const_iterator begin() const
Definition: StringMap.h:225
std::pair< iterator, bool > try_emplace_with_hash(StringRef Key, uint32_t FullHashValue, ArgsTy &&...Args)
Definition: StringMap.h:377
void erase(iterator I)
Definition: StringMap.h:419
StringMap(unsigned InitialSize)
Definition: StringMap.h:141
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
Definition: StringMap.h:372
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV, uint32_t FullHashValue)
Definition: StringMap.h:337
StringMap(unsigned InitialSize, AllocatorTy A)
Definition: StringMap.h:147
ValueTy & operator[](StringRef Key)
Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.
Definition: StringMap.h:274
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
Definition: StringMap.h:288
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
Definition: StringMap.h:353
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:312
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
CRTP base class for adapting an iterator to a different type.
Definition: iterator.h:237
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition: iterator.h:80
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1702
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
Definition: STLExtras.h:2147
@ Other
Any other memory.
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:1973
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:858
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...