[llvm-commits] [llvm] r45756 - /llvm/trunk/include/llvm/ADT/ImmutableMap.h

Ted Kremenek kremenek at apple.com
Tue Jan 8 13:05:59 PST 2008


Author: kremenek
Date: Tue Jan  8 15:05:59 2008
New Revision: 45756

URL: http://llvm.org/viewvc/llvm-project?rev=45756&view=rev
Log:
Added "getRoot()" to ImmutableMap.
Made the ctor for ImmutableMap to construct a map from an AVL tree public.

Modified:
    llvm/trunk/include/llvm/ADT/ImmutableMap.h

Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableMap.h?rev=45756&r1=45755&r2=45756&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableMap.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableMap.h Tue Jan  8 15:05:59 2008
@@ -52,20 +52,24 @@
 template <typename KeyT, typename ValT, 
           typename ValInfo = ImutKeyValueInfo<KeyT,ValT> >
 class ImmutableMap {
+public:
   typedef typename ValInfo::value_type      value_type;
   typedef typename ValInfo::value_type_ref  value_type_ref;
   typedef typename ValInfo::key_type        key_type;
   typedef typename ValInfo::key_type_ref    key_type_ref;
   typedef typename ValInfo::data_type       data_type;
   typedef typename ValInfo::data_type_ref   data_type_ref;
+  typedef ImutAVLTree<ValInfo>              TreeTy;
   
-private:  
-  typedef ImutAVLTree<ValInfo> TreeTy;
+private:
   TreeTy* Root;
-  
-  ImmutableMap(TreeTy* R) : Root(R) {}
-  
+    
 public:
+  /// Constructs a map from a pointer to a tree root.  In general one
+  /// should use a Factory object to create maps instead of directly
+  /// invoking the constructor, but there are cases where make this
+  /// constructor public is useful.
+  explicit ImmutableMap(TreeTy* R) : Root(R) {}
   
   class Factory {
     typename TreeTy::Factory F;
@@ -112,6 +116,8 @@
     return Root && RHS.Root ? Root->isNotEqual(*RHS.Root) : Root != RHS.Root;
   }
   
+  TreeTy* getRoot() const { return Root; }
+  
   bool isEmpty() const { return !Root; }
 
   //===--------------------------------------------------===//    





More information about the llvm-commits mailing list