Skip to content

Commit

Permalink
Recommit simplification first attempted in r232309 (fixed a bit in r2…
Browse files Browse the repository at this point in the history
…32312, with fixes in r232314)

Messed it up because I didn't realize there were two different iterators
here (& clearly didn't build any of this... ) - still seems easier to
just use the injected class name than introduce a self typedef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232462 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dwblaikie committed Mar 17, 2015
1 parent df08543 commit c57441f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions include/llvm/ADT/ImmutableSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ class ImutAVLTreeGenericIterator
Flags=0x3 };

typedef ImutAVLTree<ImutInfo> TreeTy;
typedef ImutAVLTreeGenericIterator<ImutInfo> SelfTy;

ImutAVLTreeGenericIterator() {}
ImutAVLTreeGenericIterator(const TreeTy *Root) {
Expand Down Expand Up @@ -696,11 +695,15 @@ class ImutAVLTreeGenericIterator
}
}

bool operator==(const SelfTy &x) const { return stack == x.stack; }
bool operator==(const ImutAVLTreeGenericIterator &x) const {
return stack == x.stack;
}

bool operator!=(const SelfTy &x) const { return !operator==(x); }
bool operator!=(const ImutAVLTreeGenericIterator &x) const {
return !(*this == x);
}

SelfTy &operator++() {
ImutAVLTreeGenericIterator &operator++() {
assert(!stack.empty());
TreeTy* Current = reinterpret_cast<TreeTy*>(stack.back() & ~Flags);
assert(Current);
Expand All @@ -726,7 +729,7 @@ class ImutAVLTreeGenericIterator
return *this;
}

SelfTy &operator--() {
ImutAVLTreeGenericIterator &operator--() {
assert(!stack.empty());
TreeTy* Current = reinterpret_cast<TreeTy*>(stack.back() & ~Flags);
assert(Current);
Expand Down Expand Up @@ -761,7 +764,6 @@ class ImutAVLTreeInOrderIterator

public:
typedef ImutAVLTree<ImutInfo> TreeTy;
typedef ImutAVLTreeInOrderIterator<ImutInfo> SelfTy;

ImutAVLTreeInOrderIterator(const TreeTy* Root) : InternalItr(Root) {
if (Root)
Expand All @@ -770,24 +772,26 @@ class ImutAVLTreeInOrderIterator

ImutAVLTreeInOrderIterator() : InternalItr() {}

bool operator==(const SelfTy &x) const {
bool operator==(const ImutAVLTreeInOrderIterator &x) const {
return InternalItr == x.InternalItr;
}

bool operator!=(const SelfTy &x) const { return !(*this == x); }
bool operator!=(const ImutAVLTreeInOrderIterator &x) const {
return !(*this == x);
}

TreeTy &operator*() const { return *InternalItr; }
TreeTy *operator->() const { return &*InternalItr; }

SelfTy &operator++() {
ImutAVLTreeInOrderIterator &operator++() {
do ++InternalItr;
while (!InternalItr.atEnd() &&
InternalItr.getVisitState() != InternalIteratorTy::VisitedLeft);

return *this;
}

SelfTy &operator--() {
ImutAVLTreeInOrderIterator &operator--() {
do --InternalItr;
while (!InternalItr.atBeginning() &&
InternalItr.getVisitState() != InternalIteratorTy::VisitedLeft);
Expand Down

0 comments on commit c57441f

Please sign in to comment.