version 1.26.4.1, 2008/04/24 18:41:36
|
version 1.26.4.2, 2008/04/25 22:23:40
|
|
|
| |
V& getValue() { return _value; } | V& getValue() { return _value; } |
| |
void putValue(const V& value) {_value = value;} |
|
|
|
private: | private: |
| |
K _key; | K _key; |
|
|
public: | public: |
| |
typedef _HashTableIterator<K, V, E> Iterator; | typedef _HashTableIterator<K, V, E> Iterator; |
typedef _Bucket<K, V, E> Bucket; |
|
| |
/* By default, we create this many chains initially */ | /* By default, we create this many chains initially */ |
enum { DEFAULT_NUM_CHAINS = 32 }; | enum { DEFAULT_NUM_CHAINS = 32 }; |
|
|
*/ | */ |
Boolean lookup(const K& key, V& value) const; | Boolean lookup(const K& key, V& value) const; |
| |
|
/** Looks up the entry with the given key and returns a pointer to the |
|
value. Note that this pointer may become invalid when the HashTable |
|
is updated. |
|
@param key key of entry to be located. |
|
@param value Output pointer to the value. |
|
@return true if found; false otherwise. |
|
*/ |
|
Boolean lookupReference(const K& key, V*& value); |
|
|
/** Removes the entry with the given key. | /** Removes the entry with the given key. |
@param key key of entry to be removed. | @param key key of entry to be removed. |
@return true on success; false otherwise. | @return true on success; false otherwise. |
|
|
_rep.getChains(), _rep.getChains() + _rep.getNumChains()); | _rep.getChains(), _rep.getChains() + _rep.getNumChains()); |
} | } |
| |
/** Gets the entry pointer with the given key. |
|
@param key key of entry to be located. |
|
@param bucket output - pointer to entry with that key |
|
@return true if entry found; false otherwise. |
|
*/ |
|
Boolean getBucket(const K& key, _Bucket<K, V, E>*& bucket) const; |
|
|
|
private: | private: |
| |
_HashTableRep _rep; | _HashTableRep _rep; |
|
|
} | } |
| |
template<class K, class V, class E, class H> | template<class K, class V, class E, class H> |
inline Boolean HashTable<K, V, E, H>::getBucket( |
inline Boolean HashTable<K, V, E, H>::lookupReference(const K& key, V*& value) |
const K& key, _Bucket<K, V, E>*& bucket) const |
|
{ | { |
bucket = (_Bucket<K, V, E>*)_rep.lookup(H::hash(key), &key); |
_Bucket<K, V, E>* bucket = |
|
(_Bucket<K, V, E>*)_rep.lookup(H::hash(key), &key); |
| |
if (bucket) | if (bucket) |
{ | { |
|
value = &bucket->getValue(); |
return true; | return true; |
} | } |
| |
return false; | return false; |
} | } |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_HashTable_h */ | #endif /* Pegasus_HashTable_h */ |