* Replaced the useless InitCheck() method in {Open,Multi}HashTable (it

always returned B_OK) by a Init() method, which sets the initial size
  and returns an error, if that fails.
* Adjusted code using the classes accordingly. Replaced a few
  InitCheck() methods in the network code by Init().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26127 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-06-24 22:23:57 +00:00
parent 55c692b304
commit 276aa463ef
12 changed files with 47 additions and 43 deletions
+15 -9
View File
@@ -31,14 +31,16 @@ public:
typedef typename Definition::KeyType KeyType;
typedef typename Definition::ValueType ValueType;
MultiHashTable(size_t initialSize = HashTable::kMinimumSize)
: HashTable(initialSize) {}
MultiHashTable()
: HashTable() {}
MultiHashTable(const Definition& definition,
size_t initialSize = HashTable::kMinimumSize)
: HashTable(definition, initialSize) {}
MultiHashTable(const Definition& definition)
: HashTable(definition) {}
status_t InitCheck() const { return HashTable::InitCheck(); }
status_t Init(size_t initialSize = HashTable::kMinimumSize)
{
return HashTable::Init(initialSize);
}
void Insert(ValueType *value)
{
@@ -103,9 +105,13 @@ public:
ValueIterator Lookup(const KeyType &key) const
{
size_t index = HashTable::fDefinition.HashKey(key)
& (HashTable::fTableSize - 1);
ValueType *slot = HashTable::fTable[index];
size_t index = 0;
ValueType *slot = NULL;
if (HashTable::fTableSize > 0) {
index = HashTable::fDefinition.HashKey(key)
& (HashTable::fTableSize - 1);
slot = HashTable::fTable[index];
}
while (slot) {
if (HashTable::fDefinition.Compare(key, slot))