class PHashTable: public PCollection

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

Inheritance:


Public

[more] Construction
[more] Overrides from class PObject

Protected

[more] Overrides from class PContainer
[more] New functions for class


Inherited from PCollection:

Public

Common functions for collections


Inherited from PContainer:

Public

Common functions for containers

Protected Methods

ovirtual void DestroyContents()
ovirtual void AssignContents(const PContainer & c)
ovoid CopyContents(const PContainer & c)
ovoid CloneContents(const PContainer * src)
ovoid Destruct()


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions

Miscellaneous functions


Documentation

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.

o Construction

o PHashTable()
Create a new, empty, hash table.

o Overrides from class PObject

ovirtual Comparison Compare( const PObject & obj ) const
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.

o Overrides from class PContainer

ovirtual BOOL SetSize( PINDEX newSize )
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 TRUE.
Parameters:
newSize - New size for the hash table, this is ignored.

o New functions for class

oPINLINE BOOL AbstractContains( const PObject & key ) const
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:
TRUE if the object value is in the set.
Parameters:
key - Key to look for in the set.

ovirtual const PObject& AbstractGetKeyAt( PINDEX index ) const
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.

ovirtual PObject& AbstractGetDataAt( PINDEX index ) const
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.


Direct child classes:
PAbstractSet
PAbstractDictionary

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.