The iterator was broken.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5006 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a5589a93b1
commit
da69f27233
@ -68,7 +68,7 @@ class List {
|
|||||||
|
|
||||||
IteratorType Iterator()
|
IteratorType Iterator()
|
||||||
{
|
{
|
||||||
return IteratorType(*this);
|
return IteratorType(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsEmpty()
|
bool IsEmpty()
|
||||||
@ -93,6 +93,7 @@ class List {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class IteratorType;
|
||||||
Link fLink;
|
Link fLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -102,11 +103,11 @@ class Iterator {
|
|||||||
typedef List<Item, LinkMember> ListType;
|
typedef List<Item, LinkMember> ListType;
|
||||||
|
|
||||||
Iterator() : fCurrent(NULL) {}
|
Iterator() : fCurrent(NULL) {}
|
||||||
Iterator(ListType &list) : fCurrent(list.Head()) {}
|
Iterator(ListType *list) : fList(list), fCurrent(list->Head()) {}
|
||||||
|
|
||||||
Item *Next()
|
Item *Next()
|
||||||
{
|
{
|
||||||
if (fCurrent->next == NULL)
|
if (fCurrent == &fList->fLink)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Link *current = fCurrent;
|
Link *current = fCurrent;
|
||||||
@ -116,6 +117,7 @@ class Iterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ListType *fList;
|
||||||
Link *fCurrent;
|
Link *fCurrent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user