aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-11 00:14:49 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-11 00:14:49 +0000
commitbdc2154986f6f302ef59b506013b73f82a7a5ee5 (patch)
tree55f09226d00e53cd49e50059418d947ae95a18f1
parent37474bce024c4a1e85dd777a8b489af60eb4c699 (diff)
Added iterators to ImmutableSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42851 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/ImmutableSet.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h
index a0a28df2a3..30815751de 100644
--- a/include/llvm/ADT/ImmutableSet.h
+++ b/include/llvm/ADT/ImmutableSet.h
@@ -633,8 +633,8 @@ public:
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 @@ public:
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 @@ public:
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.