llvm.org GIT mirror llvm / 3c6255c
Added iterator and profiling (i.e. FoldingSetNodeID) support to ImmutableMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45503 91177308-0d34-0410-b5e6-96231b3b80d8 Ted Kremenek 12 years ago
1 changed file(s) with 41 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
153153 //===--------------------------------------------------===//
154154
155155 void verify() const { if (Root) Root->verify(); }
156 unsigned getHeight() const { return Root ? Root->getHeight() : 0; }
157
156
157 //===--------------------------------------------------===//
158 // Iterators.
159 //===--------------------------------------------------===//
160
161 class iterator {
162 typename TreeTy::iterator itr;
163
164 iterator() {}
165 iterator(TreeTy* t) : itr(t) {}
166 friend class ImmutableSet;
167
168 public:
169 inline value_type_ref operator*() const { return itr->getValue(); }
170 inline key_type_ref getKey() const { return itr->getValue().first; }
171 inline data_type_ref getData() const { return itr->getValue().second; }
172
173 inline iterator& operator++() { ++itr; return *this; }
174 inline iterator operator++(int) { iterator tmp(*this); ++itr; return tmp; }
175 inline iterator& operator--() { --itr; return *this; }
176 inline iterator operator--(int) { iterator tmp(*this); --itr; return tmp; }
177 inline bool operator==(const iterator& RHS) const { return RHS.itr == itr; }
178 inline bool operator!=(const iterator& RHS) const { return RHS.itr != itr; }
179 };
180
181 iterator begin() const { return iterator(Root); }
182 iterator end() const { return iterator(); }
183
184 //===--------------------------------------------------===//
185 // Utility methods.
186 //===--------------------------------------------------===//
187
188 inline unsigned getHeight() const { return Root ? Root->getHeight() : 0; }
189
190 static inline void Profile(const ImmutableMap& M, FoldingSetNodeID& ID) {
191 ID.AddPointer(M.Root);
192 }
193
194 inline void Profile(FoldingSetNodeID& ID) const {
195 return Profile(*this,ID);
196 }
158197 };
159198
160199 } // end namespace llvm