14#ifndef LLVM_ADT_IMMUTABLEMAP_H
15#define LLVM_ADT_IMMUTABLEMAP_H
27template <
typename T,
typename S>
61template <
typename KeyT,
typename ValT,
62 typename ValInfo = ImutKeyValueInfo<KeyT,ValT>>
85 const bool Canonicalize;
88 Factory(
bool canonicalize =
true) : Canonicalize(canonicalize) {}
91 :
F(
Alloc), Canonicalize(canonicalize) {}
100 TreeTy *
T =
F.add(Old.
Root.get(), std::pair<key_type, data_type>(K,
D));
115 return Root ?
Root->contains(K) :
false;
172 if (
T)
return &
T->getValue().second;
182 return Root ? &(
Root->getMaxElement()->getValue()) :
nullptr;
192 ID.AddPointer(M.Root.get());
201template <
typename KeyT,
typename ValT,
202typename ValInfo = ImutKeyValueInfo<KeyT,ValT>>
228 :
Root(
X.getRootWithoutRetain()),
Factory(
F.getTreeFactory()) {}
244 Factory->add(
Root.get(), std::pair<key_type, data_type>(K,
D));
254 return Root ?
Root->contains(K) :
false;
302 if (
T)
return &
T->getValue().second;
312 return Root ? &(
Root->getMaxElement()->getValue()) :
nullptr;
322 ID.AddPointer(M.Root.get());
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file defines a hash set that can be used to remove duplication of nodes in a graph.
This file defines the ImutAVLTree and ImmutableSet classes.
Allocate memory in an ever growing pool, as if by bump-pointer.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
key_type_ref getKey() const
data_type_ref getData() const
unsigned getHeight() const
ImmutableMap< KeyT, ValT > asImmutableMap() const
static ImmutableMapRef getEmptyMap(FactoryTy *F)
void Profile(FoldingSetNodeID &ID) const
bool operator!=(const ImmutableMapRef &RHS) const
bool contains(key_type_ref K) const
static void Profile(FoldingSetNodeID &ID, const ImmutableMapRef &M)
typename ValInfo::data_type data_type
typename ValInfo::data_type_ref data_type_ref
typename ValInfo::key_type key_type
IntrusiveRefCntPtr< TreeTy > Root
typename ValInfo::value_type_ref value_type_ref
bool operator==(const ImmutableMapRef &RHS) const
ImmutableMapRef remove(key_type_ref K) const
typename ValInfo::key_type_ref key_type_ref
value_type * getMaxElement() const
getMaxElement - Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ...
ImmutableMapRef add(key_type_ref K, data_type_ref D) const
typename ValInfo::value_type value_type
ImmutableMapRef(const TreeTy *R, FactoryTy *F)
Constructs a map from a pointer to a tree root.
data_type * lookup(key_type_ref K) const
ImmutableMapRef(const ImmutableMap< KeyT, ValT > &X, typename ImmutableMap< KeyT, ValT >::Factory &F)
typename TreeTy::Factory FactoryTy
ImmutableMap getEmptyMap()
ImmutableMap add(ImmutableMap Old, key_type_ref K, data_type_ref D)
Factory(bool canonicalize=true)
TreeTy::Factory * getTreeFactory() const
Factory(const Factory &)=delete
Factory(BumpPtrAllocator &Alloc, bool canonicalize=true)
Factory & operator=(const Factory &)=delete
ImmutableMap remove(ImmutableMap Old, key_type_ref K)
key_type_ref getKey() const
data_type_ref getData() const
bool operator==(const ImmutableMap &RHS) const
typename ValInfo::data_type data_type
typename ValInfo::value_type value_type
ImmutableMap(const TreeTy *R)
Constructs a map from a pointer to a tree root.
IntrusiveRefCntPtr< TreeTy > Root
typename ValInfo::key_type key_type
unsigned getHeight() const
static void Profile(FoldingSetNodeID &ID, const ImmutableMap &M)
bool contains(key_type_ref K) const
data_type * lookup(key_type_ref K) const
TreeTy * getRootWithoutRetain() const
typename ValInfo::key_type_ref key_type_ref
void Profile(FoldingSetNodeID &ID) const
bool operator!=(const ImmutableMap &RHS) const
typename ValInfo::data_type_ref data_type_ref
typename ValInfo::value_type_ref value_type_ref
value_type * getMaxElement() const
getMaxElement - Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ...
ImutAVLFactory< ImutInfo > Factory
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is an optimization pass for GlobalISel generic memory operations.
Generic iterator that wraps a T::TreeTy::iterator and exposes iterator::getValue() on dereference.
static bool isLess(key_type_ref LHS, key_type_ref RHS)
static bool isEqual(key_type_ref LHS, key_type_ref RHS)
ImutKeyValueInfo -Traits class used by ImmutableMap.
const value_type & value_type_ref
static void Profile(FoldingSetNodeID &ID, value_type_ref V)
static bool isLess(key_type_ref L, key_type_ref R)
static key_type_ref KeyOfValue(value_type_ref V)
const std::pair< T, S > value_type
static data_type_ref DataOfValue(value_type_ref V)
static bool isDataEqual(data_type_ref L, data_type_ref R)
static bool isEqual(key_type_ref L, key_type_ref R)
static void Profile(FoldingSetNodeID &ID, value_type_ref X)