Ptex
|
A lightweight hash table. More...
#include <PtexHashMap.h>
Classes | |
struct | Entry |
class | iterator |
Internal class used to provide iteration through the hash table. More... | |
struct | value_type |
Public Types | |
typedef KeyType | key_type |
typedef DataType | data_type |
typedef HashFn | hash_fn |
Public Member Functions | |
iterator | begin () const |
Returns an iterator referencing the beginning of the table. More... | |
iterator | end () const |
Returns an iteraot referencing the location just beyond the table. More... | |
PtexHashMap () | |
Default contructor initializes the hash table. More... | |
~PtexHashMap () | |
Non-Virtual destructor by design, clears the entries in the hash table. More... | |
DataType & | operator[] (const KeyType &key) |
Locates an entry, creating a new one if necessary. More... | |
iterator | find (const KeyType &key) const |
Locates an entry, without creating a new one. More... | |
bool | erase (const KeyType &key) |
Will remove an entry. It will return TRUE if an entry was found. More... | |
iterator | erase (iterator iter) |
Will remove an entry. It will return a iterator to the next element. More... | |
void | clear () |
clear will remove all entries and free the table More... | |
int | size () const |
number of entries in the hash More... | |
Private Member Functions | |
PtexHashMap (const PtexHashMap &) | |
Copy constructor prohibited by design. More... | |
bool | operator= (const PtexHashMap &) |
Assignment operator prohibited by design. More... | |
Entry ** | locate (const KeyType &key) const |
Returns a pointer to the desired entry, based on the key. More... | |
void | grow () |
Used to increase the size of the table if necessary. More... | |
Private Attributes | |
int | _numEntries |
int | _numBuckets |
int | _bucketMask |
Entry ** | _buckets |
HashFn | hash |
Friends | |
class | iterator |
A lightweight hash table.
The hash table automatically doubles in size when it is more than 50% full.
The interface is mostely compatible with std::hash_map<>, though not all methods are provided. Methods provided:
Definition at line 85 of file PtexHashMap.h.
typedef DataType PtexHashMap< KeyType, DataType, HashFn >::data_type |
Definition at line 91 of file PtexHashMap.h.
typedef HashFn PtexHashMap< KeyType, DataType, HashFn >::hash_fn |
Definition at line 92 of file PtexHashMap.h.
typedef KeyType PtexHashMap< KeyType, DataType, HashFn >::key_type |
Definition at line 87 of file PtexHashMap.h.
|
inline |
Default contructor initializes the hash table.
Definition at line 158 of file PtexHashMap.h.
|
inline |
Non-Virtual destructor by design, clears the entries in the hash table.
Definition at line 160 of file PtexHashMap.h.
|
private |
Copy constructor prohibited by design.
|
inline |
Returns an iterator referencing the beginning of the table.
Definition at line 136 of file PtexHashMap.h.
Referenced by PtexHashMap< KeyType, DataType, HashFn >::clear(), and PtexReader::~PtexReader().
void PtexHashMap< KeyType, DataType, HashFn >::clear | ( | ) |
clear will remove all entries and free the table
Definition at line 336 of file PtexHashMap.h.
References PtexHashMap< KeyType, DataType, HashFn >::_buckets, PtexHashMap< KeyType, DataType, HashFn >::_numBuckets, PtexHashMap< KeyType, DataType, HashFn >::_numEntries, PtexHashMap< KeyType, DataType, HashFn >::begin(), PtexHashMap< KeyType, DataType, HashFn >::end(), and PtexHashMap< KeyType, DataType, HashFn >::erase().
Referenced by PtexHashMap< ReductionKey, FaceData *, ReductionKey::Hasher >::~PtexHashMap().
|
inline |
Returns an iteraot referencing the location just beyond the table.
Definition at line 149 of file PtexHashMap.h.
Referenced by PtexHashMap< KeyType, DataType, HashFn >::clear(), PtexHashMap< KeyType, DataType, HashFn >::erase(), PtexHashMap< KeyType, DataType, HashFn >::find(), and PtexReader::~PtexReader().
bool PtexHashMap< KeyType, DataType, HashFn >::erase | ( | const KeyType & | key | ) |
Will remove an entry. It will return TRUE if an entry was found.
Definition at line 303 of file PtexHashMap.h.
References PtexHashMap< KeyType, DataType, HashFn >::end(), and PtexHashMap< KeyType, DataType, HashFn >::find().
Referenced by PtexHashMap< KeyType, DataType, HashFn >::clear().
PtexHashMap< KeyType, DataType, HashFn >::iterator PtexHashMap< KeyType, DataType, HashFn >::erase | ( | iterator | iter | ) |
Will remove an entry. It will return a iterator to the next element.
Definition at line 314 of file PtexHashMap.h.
References PtexHashMap< KeyType, DataType, HashFn >::_numEntries, PtexHashMap< KeyType, DataType, HashFn >::iterator::e, and PtexHashMap< KeyType, DataType, HashFn >::Entry::next.
PtexHashMap< KeyType, DataType, HashFn >::iterator PtexHashMap< KeyType, DataType, HashFn >::find | ( | const KeyType & | key | ) | const |
Locates an entry, without creating a new one.
find will locate an entry, but won't create a new one. The result is returned as a pair of key and value. The returned key points to the internal key string and will remain valid until the entry is deleted. If the key is not found, both the returned key and value pointers will be NULL.
Definition at line 246 of file PtexHashMap.h.
References PtexHashMap< KeyType, DataType, HashFn >::_bucketMask, PtexHashMap< KeyType, DataType, HashFn >::iterator::b, PtexHashMap< KeyType, DataType, HashFn >::iterator::e, PtexHashMap< KeyType, DataType, HashFn >::end(), PtexHashMap< KeyType, DataType, HashFn >::iterator::h, PtexHashMap< KeyType, DataType, HashFn >::hash, and PtexHashMap< KeyType, DataType, HashFn >::locate().
Referenced by PtexHashMap< KeyType, DataType, HashFn >::erase().
|
private |
Used to increase the size of the table if necessary.
Definition at line 277 of file PtexHashMap.h.
References PtexHashMap< KeyType, DataType, HashFn >::_bucketMask, PtexHashMap< KeyType, DataType, HashFn >::_buckets, PtexHashMap< KeyType, DataType, HashFn >::_numBuckets, PtexHashMap< KeyType, DataType, HashFn >::hash, and PtexHashMap< KeyType, DataType, HashFn >::Entry::next.
Referenced by PtexHashMap< KeyType, DataType, HashFn >::operator[]().
|
inlineprivate |
Returns a pointer to the desired entry, based on the key.
Definition at line 204 of file PtexHashMap.h.
Referenced by PtexHashMap< KeyType, DataType, HashFn >::find(), and PtexHashMap< KeyType, DataType, HashFn >::operator[]().
|
private |
Assignment operator prohibited by design.
DataType & PtexHashMap< KeyType, DataType, HashFn >::operator[] | ( | const KeyType & | key | ) |
Locates an entry, creating a new one if necessary.
operator[] will look up an entry and return the value. A new entry will be created (using the default ctor for DataType) if one doesn't exist.
Definition at line 259 of file PtexHashMap.h.
References PtexHashMap< KeyType, DataType, HashFn >::_bucketMask, PtexHashMap< KeyType, DataType, HashFn >::_buckets, PtexHashMap< KeyType, DataType, HashFn >::_numBuckets, PtexHashMap< KeyType, DataType, HashFn >::_numEntries, PtexHashMap< KeyType, DataType, HashFn >::grow(), PtexHashMap< KeyType, DataType, HashFn >::hash, if(), PtexHashMap< KeyType, DataType, HashFn >::Entry::key, PtexHashMap< KeyType, DataType, HashFn >::locate(), PtexHashMap< KeyType, DataType, HashFn >::Entry::next, and PtexHashMap< KeyType, DataType, HashFn >::Entry::val.
|
inline |
number of entries in the hash
Definition at line 186 of file PtexHashMap.h.
|
friend |
Definition at line 194 of file PtexHashMap.h.
Referenced by PtexHashMap< ReductionKey, FaceData *, ReductionKey::Hasher >::begin(), and PtexHashMap< ReductionKey, FaceData *, ReductionKey::Hasher >::end().
|
private |
|
private |
Definition at line 219 of file PtexHashMap.h.
Referenced by PtexHashMap< ReductionKey, FaceData *, ReductionKey::Hasher >::begin(), PtexHashMap< KeyType, DataType, HashFn >::clear(), PtexHashMap< KeyType, DataType, HashFn >::grow(), PtexHashMap< ReductionKey, FaceData *, ReductionKey::Hasher >::locate(), PtexHashMap< KeyType, DataType, HashFn >::iterator::operator++(), and PtexHashMap< KeyType, DataType, HashFn >::operator[]().
|
private |
Definition at line 217 of file PtexHashMap.h.
Referenced by PtexHashMap< ReductionKey, FaceData *, ReductionKey::Hasher >::begin(), PtexHashMap< KeyType, DataType, HashFn >::clear(), PtexHashMap< KeyType, DataType, HashFn >::grow(), PtexHashMap< KeyType, DataType, HashFn >::iterator::operator++(), and PtexHashMap< KeyType, DataType, HashFn >::operator[]().
|
private |
|
private |