14#ifndef LLVM_ADT_STRINGMAP_H
15#define LLVM_ADT_STRINGMAP_H
21#include <initializer_list>
26template <
typename ValueTy>
class StringMapConstIterator;
27template <
typename ValueTy>
class StringMapIterator;
28template <
typename ValueTy>
class StringMapKeyIterator;
49 RHS.TheTable =
nullptr;
52 RHS.NumTombstones = 0;
84 static_cast<uintptr_t
>(-1)
109template <
typename ValueTy,
typename AllocatorTy = MallocAllocator>
160 static_cast<MapEntryTy *
>(Bucket)->getValue());
161 HashTable[
I] = RHSHashTable[
I];
243 auto Iter = this->
find(std::move(Val));
244 assert(Iter != this->
end() &&
"StringMap::at failed due to a missing key");
258 template <
typename InputTy>
268 for (
const auto &KeyValue : *
this) {
269 auto FindInRHS =
RHS.find(KeyValue.getKey());
271 if (FindInRHS ==
RHS.end())
274 if (!(KeyValue.getValue() == FindInRHS->getValue()))
306 std::pair<iterator, bool>
insert(std::pair<StringRef, ValueTy> KV) {
307 return try_emplace(KV.first, std::move(KV.second));
313 template <
typename InputIt>
void insert(InputIt First, InputIt
Last) {
314 for (InputIt It = First; It !=
Last; ++It)
321 void insert(std::initializer_list<std::pair<StringRef, ValueTy>>
List) {
327 template <
typename V>
331 Ret.first->second = std::forward<V>(Val);
339 template <
typename... ArgsTy>
396template <
typename DerivedTy,
typename ValueTy>
407 bool NoAdvance =
false)
410 AdvancePastEmptyBuckets();
415 return static_cast<DerivedTy &
>(*this);
419 return LHS.Ptr ==
RHS.Ptr;
424 AdvancePastEmptyBuckets();
425 return static_cast<DerivedTy &
>(*this);
435 void AdvancePastEmptyBuckets() {
441template <
typename ValueTy>
444 const StringMapEntry<ValueTy>> {
451 bool NoAdvance =
false)
452 :
base(Bucket, NoAdvance) {}
459template <
typename ValueTy>
461 StringMapEntry<ValueTy>> {
468 bool NoAdvance =
false)
469 :
base(Bucket, NoAdvance) {}
480template <
typename ValueTy>
483 StringMapConstIterator<ValueTy>,
484 std::forward_iterator_tag, StringRef> {
This file defines the StringMapEntry class - it is intended to be a low dependency implementation det...
This file defines MallocAllocator.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringMapConstIterator()=default
StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
const StringMapEntry< ValueTy > & operator*() const
StringMapEntryBase - Shared base class of StringMapEntry instances.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
StringMapImpl - This is the base class of StringMap that is shared among all of its instantiations.
void swap(StringMapImpl &Other)
static StringMapEntryBase * getTombstoneVal()
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
StringMapEntryBase ** TheTable
unsigned getNumBuckets() const
StringMapImpl(unsigned itemSize)
void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
unsigned getNumItems() const
static constexpr uintptr_t TombstoneIntVal
StringMapImpl(StringMapImpl &&RHS)
StringMapEntryBase ** Ptr
DerivedTy operator++(int)
DerivedTy & operator=(const DerivedTy &Other)
StringMapIterBase(StringMapEntryBase **Bucket, bool NoAdvance=false)
friend bool operator==(const DerivedTy &LHS, const DerivedTy &RHS)
StringMapIterBase()=default
StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
StringMapEntry< ValueTy > & operator*() const
StringMapIterator()=default
StringRef operator*() const
StringMapKeyIterator()=default
StringMapKeyIterator(StringMapConstIterator< ValueTy > Iter)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
size_type count(const StringMapEntry< InputTy > &MapEntry) const
StringMapConstIterator< ValueTy > const_iterator
StringMap(StringMap &&RHS)
bool erase(StringRef Key)
StringMap(std::initializer_list< std::pair< StringRef, ValueTy > > List)
bool operator!=(const StringMap &RHS) const
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
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.
iterator find(StringRef Key)
const_iterator end() const
StringMap(const StringMap &RHS)
const ValueTy & at(StringRef Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
StringMapIterator< ValueTy > iterator
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.
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
const_iterator find(StringRef Key) const
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
StringMap & operator=(StringMap RHS)
void insert(InputIt First, InputIt Last)
Inserts elements from range [first, last).
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
const_iterator begin() const
StringMap(unsigned InitialSize)
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.
StringMap(unsigned InitialSize, AllocatorTy A)
ValueTy & operator[](StringRef Key)
Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
CRTP base class for adapting an iterator to a different type.
const StringMapConstIterator< ValueTy > & wrapped() const
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...