[llvm] r175097 - Fix iterator definitions for ImmutableSet and ImmutableMap.
Ryan Govostes
rzg at apple.com
Wed Feb 13 14:37:27 PST 2013
Author: rgov
Date: Wed Feb 13 16:37:27 2013
New Revision: 175097
URL: http://llvm.org/viewvc/llvm-project?rev=175097&view=rev
Log:
Fix iterator definitions for ImmutableSet and ImmutableMap.
Modified:
llvm/trunk/include/llvm/ADT/ImmutableMap.h
llvm/trunk/include/llvm/ADT/ImmutableSet.h
Modified: llvm/trunk/include/llvm/ADT/ImmutableMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableMap.h?rev=175097&r1=175096&r2=175097&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableMap.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableMap.h Wed Feb 13 16:37:27 2013
@@ -211,24 +211,24 @@ public:
friend class ImmutableMap;
public:
- value_type_ref operator*() const { return itr->getValue(); }
- value_type* operator->() const { return &itr->getValue(); }
+ typedef ImmutableMap<KeyT,ValT,ValInfo>::value_type value_type;
+ typedef ImmutableMap<KeyT,ValT,ValInfo>::value_type_ref reference;
+ typedef iterator::value_type *pointer;
+ typedef std::bidirectional_iterator_tag iterator_category;
+
+ iterator::reference operator*() const { return itr->getValue(); }
+ iterator::pointer operator->() const { return &itr->getValue(); }
key_type_ref getKey() const { return itr->getValue().first; }
data_type_ref getData() const { return itr->getValue().second; }
-
iterator& operator++() { ++itr; return *this; }
iterator operator++(int) { iterator tmp(*this); ++itr; return tmp; }
iterator& operator--() { --itr; return *this; }
iterator operator--(int) { iterator tmp(*this); --itr; return tmp; }
+
bool operator==(const iterator& RHS) const { return RHS.itr == itr; }
bool operator!=(const iterator& RHS) const { return RHS.itr != itr; }
-
- typedef ImmutableMap<KeyT,ValT,ValInfo>::value_type value_type;
- typedef value_type *pointer;
- typedef value_type &reference;
- typedef std::bidirectional_iterator_tag iterator_category;
};
iterator begin() const { return iterator(Root); }
Modified: llvm/trunk/include/llvm/ADT/ImmutableSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ImmutableSet.h?rev=175097&r1=175096&r2=175097&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ImmutableSet.h (original)
+++ llvm/trunk/include/llvm/ADT/ImmutableSet.h Wed Feb 13 16:37:27 2013
@@ -1054,23 +1054,27 @@ public:
class iterator {
typename TreeTy::iterator itr;
+
+ iterator() {}
iterator(TreeTy* t) : itr(t) {}
friend class ImmutableSet<ValT,ValInfo>;
- public:
- iterator() {}
- inline value_type_ref operator*() const { return itr->getValue(); }
- inline iterator& operator++() { ++itr; return *this; }
- inline iterator operator++(int) { iterator tmp(*this); ++itr; return tmp; }
- inline iterator& operator--() { --itr; return *this; }
- inline iterator operator--(int) { iterator tmp(*this); --itr; return tmp; }
- inline bool operator==(const iterator& RHS) const { return RHS.itr == itr; }
- inline bool operator!=(const iterator& RHS) const { return RHS.itr != itr; }
- inline value_type *operator->() const { return &(operator*()); }
+ public:
typedef ImmutableSet<ValT,ValInfo>::value_type value_type;
- typedef value_type *pointer;
- typedef value_type &reference;
+ typedef ImmutableSet<ValT,ValInfo>::value_type_ref reference;
+ typedef iterator::value_type *pointer;
typedef std::bidirectional_iterator_tag iterator_category;
+
+ iterator::reference operator*() const { return itr->getValue(); }
+ iterator::pointer operator->() const { return &(operator*()); }
+
+ iterator& operator++() { ++itr; return *this; }
+ iterator operator++(int) { iterator tmp(*this); ++itr; return tmp; }
+ iterator& operator--() { --itr; return *this; }
+ iterator operator--(int) { iterator tmp(*this); --itr; return tmp; }
+
+ bool operator==(const iterator& RHS) const { return RHS.itr == itr; }
+ bool operator!=(const iterator& RHS) const { return RHS.itr != itr; }
};
iterator begin() const { return iterator(Root); }
More information about the llvm-commits
mailing list