fixed OpenHashTable::Iterator, it wasn't working for a single item.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20862 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Hugo Santos
2007-04-27 14:47:34 +00:00
parent 87ac9f1d46
commit 01a10fc527
+6 -14
View File
@@ -169,7 +169,7 @@ public:
class Iterator {
public:
Iterator(const HashTable *table)
: fTable(table), fIndex(0), fCurrent(NULL), fNext(NULL)
: fTable(table)
{
Rewind();
}
@@ -178,8 +178,7 @@ public:
ValueType *Next()
{
ValueType *current = fCurrent;
fCurrent = fNext;
ValueType *current = fNext;
_GetNext();
return current;
}
@@ -188,22 +187,15 @@ public:
{
// get the first one
fIndex = 0;
fCurrent = NULL;
fNext = NULL;
_GetNext();
fCurrent = fNext;
// get the proper next one
if (fCurrent)
_GetNext();
}
private:
void _GetNext()
{
if (fCurrent) {
fNext = fTable->_Link(fCurrent)->fNext;
} else {
fNext = NULL;
}
if (fNext)
fNext = fTable->_Link(fNext)->fNext;
while (fNext == NULL && fIndex < fTable->fTableSize)
fNext = fTable->fTable[fIndex++];
@@ -211,7 +203,7 @@ public:
const HashTable *fTable;
size_t fIndex;
ValueType *fCurrent, *fNext;
ValueType *fNext;
};
Iterator GetIterator() const { return Iterator(this); }