|
|
// HashFunction(unsigned), HashFunction(void const *), HashFunction(char const *) | // HashFunction(unsigned), HashFunction(void const *), HashFunction(char const *) |
// you can disable the default hash functions by defining HT_NODEFAULTFNS | // you can disable the default hash functions by defining HT_NODEFAULTFNS |
| |
|
namespace IFF { |
|
class RegEntry; |
|
}; |
|
|
#ifndef HT_NODEFAULTFNS | #ifndef HT_NODEFAULTFNS |
// a hash function for integral (unsigned) values | // a hash function for integral (unsigned) values |
|
inline unsigned int HashFunction(const IFF::RegEntry& rEntry); |
inline unsigned HashFunction(unsigned const _i) | inline unsigned HashFunction(unsigned const _i) |
{ | { |
return _i ^ _i>>4 ^ _i>>9 ^ _i>>15 ^ _i>>22; | return _i ^ _i>>4 ^ _i>>9 ^ _i>>15 ^ _i>>22; |
|
|
}; | }; |
| |
// a _base_HashTable non-const iterator - can remove entry pointed to | // a _base_HashTable non-const iterator - can remove entry pointed to |
class Iterator : public ConstIterator |
class Iterator : public _base_HashTable::ConstIterator |
{ | { |
// Nested class functions apparently have to be declared here for MSVC compatability | // Nested class functions apparently have to be declared here for MSVC compatability |
public: | public: |
|
|
// remove the current entry pointed to, advancing to the next | // remove the current entry pointed to, advancing to the next |
void Remove() | void Remove() |
{ | { |
if (!nEntriesRemaining) |
if (!ConstIterator::nEntriesRemaining) |
{ | { |
HT_FAIL("HTT: Tried to Remove() via an iterator which was Done()"); | HT_FAIL("HTT: Tried to Remove() via an iterator which was Done()"); |
} | } |
Node * oldP = *nodePP; |
Node * oldP = *ConstIterator::nodePP; |
*nodePP = oldP->nextP; |
*ConstIterator::nodePP = oldP->nextP; |
delete oldP; | delete oldP; |
if (!*nodePP) |
if (!*ConstIterator::nodePP) |
{ | { |
do | do |
{ | { |
++ chainPP; |
++ ConstIterator::chainPP; |
-- nChainsRemaining; |
-- ConstIterator::nChainsRemaining; |
} | } |
while (nChainsRemaining && !*chainPP); |
while (ConstIterator::nChainsRemaining && !*ConstIterator::chainPP); |
nodePP = chainPP; |
ConstIterator::nodePP = ConstIterator::chainPP; |
} | } |
-- nEntriesRemaining; |
-- ConstIterator::nEntriesRemaining; |
-- *tableNEntriesP; | -- *tableNEntriesP; |
} | } |
| |
|
|
| |
| |
// for(HashTable<TYPE>::ConstIterator it(ht); !it.Done(); it.Next() ) | // for(HashTable<TYPE>::ConstIterator it(ht); !it.Done(); it.Next() ) |
for (_base_HashTable::ConstIterator it(ht); !it.Done(); it.Next() ) |
for (class _base_HashTable::ConstIterator it(ht); !it.Done(); it.Next() ) |
{ | { |
AddRegardless( it.Get() ); | AddRegardless( it.Get() ); |
} | } |