14 #ifndef LLVM_ADT_IMMUTABLEMAP_H
15 #define LLVM_ADT_IMMUTABLEMAP_H
27 template <
typename T,
typename S>
61 template <
typename KeyT,
typename ValT,
62 typename ValInfo = ImutKeyValueInfo<KeyT,ValT>>
104 const bool Canonicalize;
107 Factory(
bool canonicalize =
true) : Canonicalize(canonicalize) {}
110 : F(Alloc), Canonicalize(canonicalize) {}
166 template <
typename Callback>
172 template <
typename Callback>
173 struct CBWrapperRef {
175 CBWrapperRef(Callback& c) :
C(c) {}
181 template <
typename Callback>
182 void foreach(Callback&
C) {
184 CBWrapperRef<Callback> CB(C);
189 template <
typename Callback>
192 CBWrapper<Callback> CB;
224 if (T)
return &T->
getValue().second;
253 template <
typename KeyT,
typename ValT,
254 typename ValInfo = ImutKeyValueInfo<KeyT,ValT>>
284 :
Root(X.getRootWithoutRetain()),
384 if (T)
return &T->
getValue().second;
412 #endif // LLVM_ADT_IMMUTABLEMAP_H
Generic iterator that wraps a T::TreeTy::iterator and exposes iterator::getValue() on dereference...
unsigned getHeight() const
getHeight - Returns the height of the tree.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
TreeTy::Factory FactoryTy
void Profile(FoldingSetNodeID &ID) const
ValInfo::key_type key_type
ImmutableMap & operator=(const ImmutableMap &X)
ImmutableMap< KeyT, ValT > asImmutableMap() const
TreeTy * add(TreeTy *T, value_type_ref V)
static key_type_ref KeyOfValue(value_type_ref V)
ImutAVLTree< ValInfo > TreeTy
bool isNotEqual(const ImutAVLTree &RHS) const
isNotEqual - Compares two trees for structural inequality.
ValInfo::key_type key_type
ImmutableMap(const TreeTy *R)
Constructs a map from a pointer to a tree root.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
ValInfo::data_type data_type
data_type_ref getData() const
ImutAVLTree * getMaxElement()
getMaxElement - Find the subtree associated with the highest ranged key value.
key_type_ref getKey() const
bool contains(key_type_ref K) const
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
InstrProfLookupTrait::data_type data_type
data_type * lookup(key_type_ref K) const
bool contains(key_type_ref K) const
const std::pair< T, S > value_type
ValInfo::data_type_ref data_type_ref
ImmutableMap getEmptyMap()
const value_type & value_type_ref
void foreach(Callback &C)
foreach - A member template the accepts invokes operator() on a functor object (specifed by Callback)...
ImmutableMapRef add(key_type_ref K, data_type_ref D) const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
TreeTy * getEmptyTree() const
TreeTy * remove(TreeTy *T, key_type_ref V)
Allocate memory in an ever growing pool, as if by bump-pointer.
ValInfo::key_type_ref key_type_ref
ValInfo::value_type_ref value_type_ref
ImutAVLTree * find(key_type_ref K)
find - Finds the subtree associated with the specified key value.
static ImmutableMapRef getEmptyMap(FactoryTy *F)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
value_type * getMaxElement() const
getMaxElement - Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ...
static bool isEqual(key_type_ref LHS, key_type_ref RHS)
data_type_ref getData() const
ImmutableMap add(ImmutableMap Old, key_type_ref K, data_type_ref D)
TreeTy::Factory * getTreeFactory() const
bool contains(key_type_ref K)
contains - Returns true if this tree contains a subtree (node) that has an data element that matches ...
bool operator==(const ImmutableMapRef &RHS) const
static void Profile(FoldingSetNodeID &ID, value_type_ref V)
ValInfo::data_type data_type
ValInfo::key_type_ref key_type_ref
ImmutableMap(const ImmutableMap &X)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
ImutAVLTree< ValInfo > TreeTy
ImmutableMapRef(const ImmutableMapRef &X)
TreeTy * getCanonicalTree(TreeTy *TNew)
ValInfo::value_type_ref value_type_ref
ImmutableMapRef(const TreeTy *R, FactoryTy *F)
Constructs a map from a pointer to a tree root.
Factory(bool canonicalize=true)
data_type * lookup(key_type_ref K) const
bool operator==(const ImmutableMap &RHS) const
static void Profile(FoldingSetNodeID &ID, const ImmutableMapRef &M)
unsigned getHeight() const
const value_type & getValue() const
getValue - Returns the data value associated with the tree node.
ValInfo::value_type value_type
ImmutableMapRef(const ImmutableMap< KeyT, ValT > &X, typename ImmutableMap< KeyT, ValT >::Factory &F)
static bool isDataEqual(data_type_ref L, data_type_ref R)
void Profile(FoldingSetNodeID &ID) const
static bool isLess(key_type_ref L, key_type_ref R)
static bool isLess(key_type_ref LHS, key_type_ref RHS)
unsigned getHeight() const
static void Profile(FoldingSetNodeID &ID, value_type_ref X)
ImmutableMapRef & operator=(const ImmutableMapRef &X)
ImutKeyValueInfo -Traits class used by ImmutableMap.
ValInfo::value_type value_type
Factory & operator=(const Factory &)=delete
static void Profile(FoldingSetNodeID &ID, const ImmutableMap &M)
bool isEqual(const ImutAVLTree &RHS) const
isEqual - Compares two trees for structural equality and returns true if they are equal...
TreeTy * getRootWithoutRetain() const
value_type * getMaxElement() const
getMaxElement - Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ...
Factory(BumpPtrAllocator &Alloc, bool canonicalize=true)
key_type_ref getKey() const
bool operator!=(const ImmutableMapRef &RHS) const
static data_type_ref DataOfValue(value_type_ref V)
ValInfo::data_type_ref data_type_ref
static bool isEqual(key_type_ref L, key_type_ref R)
bool operator!=(const ImmutableMap &RHS) const