Made it a bit nicer to use.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6866 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6f3a136e47
commit
8e623d69b5
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <util/kernel_cpp.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -49,7 +50,7 @@ class List {
|
|||||||
fLink.prev = &(item->*LinkMember);
|
fLink.prev = &(item->*LinkMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(Item *item)
|
static void Remove(Item *item)
|
||||||
{
|
{
|
||||||
(item->*LinkMember).next->prev = (item->*LinkMember).prev;
|
(item->*LinkMember).next->prev = (item->*LinkMember).prev;
|
||||||
(item->*LinkMember).prev->next = (item->*LinkMember).next;
|
(item->*LinkMember).prev->next = (item->*LinkMember).next;
|
||||||
@ -103,11 +104,11 @@ class Iterator {
|
|||||||
typedef List<Item, LinkMember> ListType;
|
typedef List<Item, LinkMember> ListType;
|
||||||
|
|
||||||
Iterator() : fCurrent(NULL) {}
|
Iterator() : fCurrent(NULL) {}
|
||||||
Iterator(ListType *list) : fList(list), fCurrent(list->Head()) {}
|
Iterator(ListType &list) : fList(list), fCurrent(list.Head()) {}
|
||||||
|
|
||||||
Item *Next()
|
Item *Next()
|
||||||
{
|
{
|
||||||
if (fCurrent == &fList->fLink)
|
if (fCurrent == &fList.fLink)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Link *current = fCurrent;
|
Link *current = fCurrent;
|
||||||
@ -117,8 +118,8 @@ class Iterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ListType *fList;
|
ListType &fList;
|
||||||
Link *fCurrent;
|
Link *fCurrent;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace DoublyLinked
|
} // namespace DoublyLinked
|
||||||
|
Loading…
Reference in New Issue
Block a user