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