set ValueIterator's fIndex to the next slot so OpenHashTable's Iterator properly gets it.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20974 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Hugo Santos
2007-05-02 14:08:55 +00:00
parent cc70cbe297
commit f6cfc5af19
3 changed files with 22 additions and 23 deletions
+18 -20
View File
@@ -114,16 +114,8 @@ public:
void InsertUnchecked(ValueType *value)
{
if (CheckDuplicates) {
for (size_t i = 0; i < fTableSize; i++) {
ValueType *bucket = fTable[i];
while (bucket) {
if (bucket == value)
panic("Hash Table: value already in table.");
bucket = _Link(bucket)->fNext;
}
}
}
if (CheckDuplicates && _ExaustiveSearch(value))
panic("Hash Table: value already in table.");
_Insert(fTable, fTableSize, value);
fItemCount++;
@@ -164,16 +156,8 @@ public:
if (slot == NULL)
return false;
if (CheckDuplicates) {
for (size_t i = 0; i < fTableSize; i++) {
ValueType *bucket = fTable[i];
while (bucket) {
if (bucket == value)
panic("Hash Table: duplicate detected.");
bucket = _Link(bucket)->fNext;
}
}
}
if (CheckDuplicates && _ExaustiveSearch(value))
panic("Hash Table: duplicate detected.");
fItemCount--;
return true;
@@ -270,6 +254,20 @@ protected:
return fDefinition.GetLink(bucket);
}
bool _ExaustiveSearch(ValueType *value) const
{
for (size_t i = 0; i < fTableSize; i++) {
ValueType *bucket = fTable[i];
while (bucket) {
if (bucket == value)
return true;
bucket = _Link(bucket)->fNext;
}
}
return false;
}
Definition fDefinition;
size_t fTableSize, fItemCount;
ValueType **fTable;