PHashTable Class Reference

#include <dict.h>

Inheritance diagram for PHashTable:

PCollection PContainer PObject PAbstractDictionary PAbstractSet PDictionary< K, D > POrdinalDictionary< K > PStringDictionary< K > PSet< T > PStringToOrdinal POrdinalToString PStringToString PStringSet PMIMEInfo List of all members.

Public Member Functions

Construction
 PHashTable ()
 Create a new, empty, hash table.
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 PObjectAbstractGetKeyAt (PINDEX index) const
virtual PObjectAbstractGetDataAt (PINDEX index) const

Protected Attributes

PHashTableInfo * hashTable

Detailed Description

The hash table class is the basis for implementing the PSet and PDictionary classes.

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.


Member Typedef Documentation

typedef PHashTableElement PHashTable::Element [protected]

typedef PHashTableInfo PHashTable::Table [protected]


Constructor & Destructor Documentation

PHashTable::PHashTable (  ) 

Create a new, empty, hash table.


Member Function Documentation

PINLINE PBoolean PHashTable::AbstractContains ( const PObject key  )  const [protected]

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.

Returns:
PTrue if the object value is in the set.
Parameters:
key  Key to look for in the set.

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.

Returns:
reference to key at the index position.
Parameters:
index  Ordinal position in the hash table.

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.

Returns:
reference to key at the index position.
Parameters:
index  Ordinal position in the 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.

Returns:
comparison of the two objects, EqualTo if the same reference and GreaterThan if not.
Parameters:
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.

Returns:
Always PTrue.
Parameters:
newSize  New size for the hash table, this is ignored.

Implements PContainer.


Member Data Documentation

PHashTableInfo* PHashTable::hashTable [protected]


The documentation for this class was generated from the following files:
Generated on Thu May 27 01:36:48 2010 for PTLib by  doxygen 1.4.7