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:
Axel Dörfler 2003-10-13 03:19:21 +00:00
parent a5589a93b1
commit da69f27233

View File

@ -68,7 +68,7 @@ class List {
IteratorType Iterator()
{
return IteratorType(*this);
return IteratorType(this);
}
bool IsEmpty()
@ -93,6 +93,7 @@ class List {
}
private:
friend class IteratorType;
Link fLink;
};
@ -102,11 +103,11 @@ class Iterator {
typedef List<Item, LinkMember> ListType;
Iterator() : fCurrent(NULL) {}
Iterator(ListType &list) : fCurrent(list.Head()) {}
Iterator(ListType *list) : fList(list), fCurrent(list->Head()) {}
Item *Next()
{
if (fCurrent->next == NULL)
if (fCurrent == &fList->fLink)
return NULL;
Link *current = fCurrent;
@ -116,6 +117,7 @@ class Iterator {
}
private:
ListType *fList;
Link *fCurrent;
};