[llvm-commits] [llvm] r42851 - /llvm/trunk/include/llvm/ADT/ImmutableSet.h
Ted Kremenek
kremenek at apple.com
Wed Oct 10 17:14:49 PDT 2007
Author: kremenek
Date: Wed Oct 10 19:14:49 2007
New Revision: 42851
URL: http://llvm.org/viewvc/llvm-project?rev=42851&view=rev
Log:
Added iterators to ImmutableSet.
Modified:
llvm/trunk/include/llvm/ADT/ImmutableSet.h
Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=42851&r1=42850&r2=42851&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Wed Oct 10 19:14:49 2007
@@ -633,8 +633,8 @@
inline bool operator!=(const _Self& x) const { return !operator==(x); }
- inline TreeTy* operator*() { return *InternalItr; }
- inline TreeTy* operator->() { return *InternalItr; }
+ inline TreeTy* operator*() const { return *InternalItr; }
+ inline TreeTy* operator->() const { return *InternalItr; }
inline _Self& operator++() {
do ++InternalItr;
@@ -821,7 +821,7 @@
void operator=(const Factory& RHS) {};
};
- friend class Factory;
+ friend class Factory;
/// contains - Returns true if the set contains the specified value.
bool contains(const value_type_ref V) const {
@@ -844,6 +844,27 @@
template <typename Callback>
void foreach() { if (Root) { Callback C; Root->foreach(C); } }
+
+ //===--------------------------------------------------===//
+ // Iterators.
+ //===--------------------------------------------------===//
+
+ class iterator {
+ typename TreeTy::iterator itr;
+
+ iterator() {}
+ iterator(TreeTy* t) : itr(t) {}
+ friend class ImmutableSet<ValT,ValInfo>;
+ public:
+ inline value_type_ref operator*() const { return itr->getValue(); }
+ inline iterator& operator++() { ++itr; return *this; }
+ inline iterator& operator--() { --itr; return *this; }
+ inline bool operator==(const iterator& RHS) const { return RHS.itr == itr; }
+ inline bool operator!=(const iterator& RHS) const { return RHS.itr != itr; }
+ };
+
+ iterator begin() const { return iterator(Root); }
+ iterator end() const { return iterator(); }
//===--------------------------------------------------===//
// For testing.
More information about the llvm-commits
mailing list