From a0a2881b1e13c8a06304697fbd9ee7bccdcceb5c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 8 Jan 2008 21:05:59 +0000 Subject: [PATCH] Added "getRoot()" to ImmutableMap. Made the ctor for ImmutableMap to construct a map from an AVL tree public. llvm-svn: 45756 --- llvm/include/llvm/ADT/ImmutableMap.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/ADT/ImmutableMap.h b/llvm/include/llvm/ADT/ImmutableMap.h index ac4f1651b3ef..24aef7ccfdc1 100644 --- a/llvm/include/llvm/ADT/ImmutableMap.h +++ b/llvm/include/llvm/ADT/ImmutableMap.h @@ -52,20 +52,24 @@ struct ImutKeyValueInfo { template > 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 TreeTy; -private: - typedef ImutAVLTree 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 @@ public: return Root && RHS.Root ? Root->isNotEqual(*RHS.Root) : Root != RHS.Root; } + TreeTy* getRoot() const { return Root; } + bool isEmpty() const { return !Root; } //===--------------------------------------------------===//