14 #ifndef LLVM_ADT_IMMUTABLEMAP_H 15 #define LLVM_ADT_IMMUTABLEMAP_H 27 template <
typename T,
typename S>
61 template <
typename KeyT,
typename ValT,
82 if (Root) { Root->
retain(); }
86 if (Root) { Root->
retain(); }
104 const bool Canonicalize;
134 return Root ? Root->
contains(K) :
false;
146 if (Root) { Root->
retain(); }
167 template <
typename Callback>
174 template <
typename Callback>
175 struct CBWrapperRef {
178 CBWrapperRef(Callback& c) :
C(c) {}
184 template <
typename Callback>
185 void foreach(Callback&
C) {
187 CBWrapperRef<Callback> CB(C);
192 template <
typename Callback>
195 CBWrapper<Callback> CB;
204 void verify()
const {
if (Root) Root->verify(); }
227 if (T)
return &T->
getValue().second;
256 template <
typename KeyT,
typename ValT,
279 : Root(const_cast<
TreeTy *>(R)), Factory(F) {
287 : Root(X.getRootWithoutRetain()),
288 Factory(F.getTreeFactory()) {
289 if (Root) { Root->
retain(); }
304 if (Root != X.
Root) {
330 TreeTy *NewT = Factory->add(Root, std::pair<key_type, data_type>(K, D));
335 TreeTy *NewT = Factory->remove(Root, K);
340 return Root ? Root->
contains(K) :
false;
387 if (T)
return &T->
getValue().second;
415 #endif // LLVM_ADT_IMMUTABLEMAP_H unsigned getHeight() const
Generic iterator that wraps a T::TreeTy::iterator and exposes iterator::getValue() on dereference...
typename ValInfo::value_type_ref value_type_ref
unsigned getHeight() const
getHeight - Returns the height of the tree.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
ImmutableMapRef add(key_type_ref K, data_type_ref D) const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
data_type_ref getData() const
bool operator!=(const ImmutableMapRef &RHS) const
unsigned getHeight() const
void Profile(FoldingSetNodeID &ID) const
This class represents lattice values for constants.
ImmutableMap & operator=(const ImmutableMap &X)
TreeTy * add(TreeTy *T, value_type_ref V)
typename ValInfo::value_type value_type
static key_type_ref KeyOfValue(value_type_ref V)
typename TreeTy::Factory FactoryTy
value_type * getMaxElement() const
getMaxElement - Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ...
bool operator!=(const ImmutableMap &RHS) const
typename ValInfo::key_type key_type
ImmutableMap(const TreeTy *R)
Constructs a map from a pointer to a tree root.
bool isNotEqual(const ImutAVLTree &RHS) const
isNotEqual - Compares two trees for structural inequality.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
ImutAVLTree * getMaxElement()
getMaxElement - Find the subtree associated with the highest ranged key value.
key_type_ref getKey() const
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
bool isEqual(const ImutAVLTree &RHS) const
isEqual - Compares two trees for structural equality and returns true if they are equal...
LLVM_NODISCARD ImmutableMap add(ImmutableMap Old, key_type_ref K, data_type_ref D)
typename ValInfo::data_type data_type
typename ValInfo::data_type_ref data_type_ref
TreeTy * getRootWithoutRetain() const
const std::pair< T, S > value_type
ImmutableMap getEmptyMap()
typename ValInfo::value_type_ref value_type_ref
void foreach(Callback &C)
foreach - A member template the accepts invokes operator() on a functor object (specifed by Callback)...
data_type_ref getData() const
TreeTy::Factory * getTreeFactory() const
bool contains(key_type_ref K) const
typename ValInfo::key_type key_type
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
data_type * lookup(key_type_ref K) const
InstrProfLookupTrait::data_type data_type
data_type * lookup(key_type_ref K) const
TreeTy * getEmptyTree() const
typename ValInfo::data_type_ref data_type_ref
TreeTy * remove(TreeTy *T, key_type_ref V)
Allocate memory in an ever growing pool, as if by bump-pointer.
ImutAVLTree * find(key_type_ref K)
find - Finds the subtree associated with the specified key value.
static ImmutableMapRef getEmptyMap(FactoryTy *F)
static bool isEqual(key_type_ref LHS, key_type_ref RHS)
bool contains(key_type_ref K)
contains - Returns true if this tree contains a subtree (node) that has an data element that matches ...
key_type_ref getKey() const
static void Profile(FoldingSetNodeID &ID, value_type_ref V)
const value_type & getValue() const
getValue - Returns the data value associated with the tree node.
value_type * getMaxElement() const
getMaxElement - Returns the <key,value> pair in the ImmutableMap for which key is the highest in the ...
ImmutableMap(const ImmutableMap &X)
typename ValInfo::data_type data_type
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
ImmutableMapRef(const ImmutableMapRef &X)
TreeTy * getCanonicalTree(TreeTy *TNew)
ImmutableMapRef(const TreeTy *R, FactoryTy *F)
Constructs a map from a pointer to a tree root.
Factory(bool canonicalize=true)
void Profile(FoldingSetNodeID &ID) const
bool contains(key_type_ref K) const
static void Profile(FoldingSetNodeID &ID, const ImmutableMapRef &M)
const value_type & value_type_ref
bool operator==(const ImmutableMapRef &RHS) const
ImmutableMapRef(const ImmutableMap< KeyT, ValT > &X, typename ImmutableMap< KeyT, ValT >::Factory &F)
static bool isDataEqual(data_type_ref L, data_type_ref R)
static bool isLess(key_type_ref L, key_type_ref R)
static bool isLess(key_type_ref LHS, key_type_ref RHS)
ImmutableMap< KeyT, ValT > asImmutableMap() const
static void Profile(FoldingSetNodeID &ID, value_type_ref X)
ImmutableMapRef & operator=(const ImmutableMapRef &X)
typename ValInfo::value_type value_type
ImutKeyValueInfo -Traits class used by ImmutableMap.
static void Profile(FoldingSetNodeID &ID, const ImmutableMap &M)
bool operator==(const ImmutableMap &RHS) const
typename ValInfo::key_type_ref key_type_ref
typename ValInfo::key_type_ref key_type_ref
Factory(BumpPtrAllocator &Alloc, bool canonicalize=true)
static data_type_ref DataOfValue(value_type_ref V)
static bool isEqual(key_type_ref L, key_type_ref R)