#include <dict.h>
Inheritance diagram for PHashTable:
Public Member Functions | |
Overrides from class PObject | |
virtual Comparison | Compare (const PObject &obj) const |
Protected Types | |
typedef PHashTableElement | Element |
typedef PHashTableInfo | Table |
Protected Member Functions | |
Overrides from class PContainer | |
virtual PBoolean | SetSize (PINDEX newSize) |
New functions for class | |
PINLINE PBoolean | AbstractContains (const PObject &key) const |
virtual const PObject & | AbstractGetKeyAt (PINDEX index) const |
virtual PObject & | AbstractGetDataAt (PINDEX index) const |
Protected Attributes | |
PHashTableInfo * | hashTable |
The hash table allows for very fast searches for an object based on a "hash function". This function yields an index into an array which is directly looked up to locate the object. When two key values have the same hash function value, then a linear search of a linked list is made to locate the object. Thus the efficiency of the hash table is highly dependent on the quality of the hash function for the data being used as keys.
typedef PHashTableElement PHashTable::Element [protected] |
typedef PHashTableInfo PHashTable::Table [protected] |
PHashTable::PHashTable | ( | ) |
Create a new, empty, hash table.
PHashTable::PHashTable | ( | ) |
Create a new, empty, hash table.
virtual Comparison PHashTable::Compare | ( | const PObject & | obj | ) | const [virtual] |
Get the relative rank of the two hash tables. Actally ranking hash tables is really meaningless, so only equality is returned by the comparison. Equality is only achieved if the two instances reference the same hash table.
obj | Other PHashTable to compare against. |
Reimplemented from PObject.
virtual PBoolean PHashTable::SetSize | ( | PINDEX | newSize | ) | [protected, virtual] |
This function is meaningless for hash table. The size of the collection is determined by the addition and removal of objects. The size cannot be set in any other way.
newSize | New size for the hash table, this is ignored. |
Implements PContainer.
Determine if the value of the object is contained in the hash table. The object values are compared, not the pointers. So the objects in the collection must correctly implement the PObject::Compare()# function. The hash table is used to locate the entry.
key | Key to look for in the set. |
virtual const PObject& PHashTable::AbstractGetKeyAt | ( | PINDEX | index | ) | const [protected, virtual] |
Get the key in the hash table at the ordinal index position.
The ordinal position in the hash table is determined by the hash values of the keys and the order of insertion.
The last key/data pair is remembered by the class so that subseqent access is very fast.
This function is primarily used by the descendent template classes, or macro, with the appropriate type conversion.
index | Ordinal position in the hash table. |
virtual PObject& PHashTable::AbstractGetDataAt | ( | PINDEX | index | ) | const [protected, virtual] |
Get the data in the hash table at the ordinal index position.
The ordinal position in the hash table is determined by the hash values of the keys and the order of insertion.
The last key/data pair is remembered by the class so that subseqent access is very fast.
This function is primarily used by the descendent template classes, or macro, with the appropriate type conversion.
index | Ordinal position in the hash table. |
PHashTableInfo* PHashTable::hashTable [protected] |