The second element of the iterator is really an offset, not a link

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4196 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-10-16 01:43:11 +00:00
parent 641e1c252d
commit ff5feedf28
3 changed files with 21 additions and 17 deletions

View File

@ -17,42 +17,44 @@
class DSNodeIterator : public forward_iterator<DSNode, ptrdiff_t> {
friend class DSNode;
DSNode * const Node;
unsigned Link;
unsigned Offset;
typedef DSNodeIterator _Self;
DSNodeIterator(DSNode *N) : Node(N), Link(0) {} // begin iterator
DSNodeIterator(DSNode *N) : Node(N), Offset(0) {} // begin iterator
DSNodeIterator(DSNode *N, bool) // Create end iterator
: Node(N), Link(N->getSize()) {
: Node(N), Offset(N->getSize()) {
}
public:
DSNodeIterator(const DSNodeHandle &NH)
: Node(NH.getNode()), Offset(NH.getOffset()) {}
bool operator==(const _Self& x) const {
return Link == x.Link;
return Offset == x.Offset;
}
bool operator!=(const _Self& x) const { return !operator==(x); }
const _Self &operator=(const _Self &I) {
assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
Link = I.Link;
Offset = I.Offset;
return *this;
}
pointer operator*() const {
DSNodeHandle *NH = Node->getLink(Link);
DSNodeHandle *NH = Node->getLink(Offset);
return NH ? NH->getNode() : 0;
}
pointer operator->() const { return operator*(); }
_Self& operator++() { // Preincrement
++Link;
++Offset;
return *this;
}
_Self operator++(int) { // Postincrement
_Self tmp = *this; ++*this; return tmp;
}
unsigned getLink() const { return Link; }
unsigned getOffset() const { return Offset; }
DSNode *getNode() const { return Node; }
};

View File

@ -17,42 +17,44 @@
class DSNodeIterator : public forward_iterator<DSNode, ptrdiff_t> {
friend class DSNode;
DSNode * const Node;
unsigned Link;
unsigned Offset;
typedef DSNodeIterator _Self;
DSNodeIterator(DSNode *N) : Node(N), Link(0) {} // begin iterator
DSNodeIterator(DSNode *N) : Node(N), Offset(0) {} // begin iterator
DSNodeIterator(DSNode *N, bool) // Create end iterator
: Node(N), Link(N->getSize()) {
: Node(N), Offset(N->getSize()) {
}
public:
DSNodeIterator(const DSNodeHandle &NH)
: Node(NH.getNode()), Offset(NH.getOffset()) {}
bool operator==(const _Self& x) const {
return Link == x.Link;
return Offset == x.Offset;
}
bool operator!=(const _Self& x) const { return !operator==(x); }
const _Self &operator=(const _Self &I) {
assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
Link = I.Link;
Offset = I.Offset;
return *this;
}
pointer operator*() const {
DSNodeHandle *NH = Node->getLink(Link);
DSNodeHandle *NH = Node->getLink(Offset);
return NH ? NH->getNode() : 0;
}
pointer operator->() const { return operator*(); }
_Self& operator++() { // Preincrement
++Link;
++Offset;
return *this;
}
_Self operator++(int) { // Postincrement
_Self tmp = *this; ++*this; return tmp;
}
unsigned getLink() const { return Link; }
unsigned getOffset() const { return Offset; }
DSNode *getNode() const { return Node; }
};

View File

@ -192,7 +192,7 @@ struct DOTGraphTraits<DSGraph*> : public DefaultDOTGraphTraits {
static int getEdgeSourceLabel(DSNode *Node, DSNode::iterator I) {
assert(Node == I.getNode() && "Iterator not for this node!");
return Node->getMergeMapLabel(I.getLink());
return Node->getMergeMapLabel(I.getOffset());
}
};