Added GetIterator() version that takes a key and returns an iterator to the
respective element (if in the table). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34977 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d746188719
commit
db28a227c4
@ -314,7 +314,30 @@ public:
|
||||
ValueType* fNext;
|
||||
};
|
||||
|
||||
Iterator GetIterator() const { return Iterator(this); }
|
||||
Iterator GetIterator() const
|
||||
{
|
||||
return Iterator(this);
|
||||
}
|
||||
|
||||
Iterator GetIterator(const KeyType& key) const
|
||||
{
|
||||
if (fTableSize == 0)
|
||||
return Iterator(this, fTableSize, NULL);
|
||||
|
||||
size_t index = fDefinition.HashKey(key) & (fTableSize - 1);
|
||||
ValueType* slot = fTable[index];
|
||||
|
||||
while (slot) {
|
||||
if (fDefinition.Compare(key, slot))
|
||||
break;
|
||||
slot = _Link(slot);
|
||||
}
|
||||
|
||||
if (slot == NULL)
|
||||
return Iterator(this, fTableSize, NULL);
|
||||
|
||||
return Iterator(this, index + 1, slot);
|
||||
}
|
||||
|
||||
protected:
|
||||
// for g++ 2.95
|
||||
|
Loading…
Reference in New Issue
Block a user