template<class K> class POrdinalDictionary

This template class maps the PAbstractDictionary to a specific key type and a POrdinalKey data type.

Inheritance:


Public Methods

[more] Construction
[more] Overrides from class PObject
[more] New functions for class


Inherited from PAbstractDictionary:

Public Methods

Overrides from class PCollection


Inherited from PHashTable:

Protected Methods

Overrides from class PContainer


Inherited from PCollection:

Public Methods

Common functions for collections


Inherited from PContainer:

Public Methods

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 Methods

Run Time Type functions

I/O functions

Miscellaneous functions

Public Members

Comparison functions


Documentation

This template class maps the PAbstractDictionary to a specific key type and a POrdinalKey data type. The functions in this class primarily do all the appropriate casting of types.

Note that if templates are not used the PDECLARE_ORDINAL_DICTIONARY macro will simulate the template instantiation.

o Construction

o POrdinalDictionary()
Create a new, empty, dictionary.

Note that by default, objects placed into the dictionary will be deleted when removed or when all references to the dictionary are destroyed.

o Overrides from class PObject

ovirtual PObject* Clone() const
Make a complete duplicate of the dictionary. Note that all objects in the array are also cloned, so this will make a complete copy of the dictionary.

o New functions for class

oPINDEX operator[]( const K & key ) const
Get the object contained in the dictionary at the key position. The hash table is used to locate the data quickly via the hash function provided by the key.

The last key/data pair is remembered by the class so that subseqent access is very fast.

Returns:
reference to the object indexed by the key.

oBOOL Contains( const K & 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.

Parameters:
- key Key to look for in the dictionary.
Returns:
TRUE if the object value is in the dictionary.

ovirtual BOOL SetDataAt( PINDEX index, PINDEX ordinal )
Set the data at the specified ordinal index position in the dictionary.

The ordinal position in the dictionary is determined by the hash values of the keys and the order of insertion.

Parameters:
index - Ordinal index in the dictionary.
ordinal - New ordinal value to put into the dictionary.
Returns:
TRUE if the new object could be placed into the dictionary.

ovirtual BOOL SetAt( const K & key, PINDEX ordinal )
Add a new object to the collection. If the objects value is already in the dictionary then the object is overrides the previous value. If the AllowDeleteObjects option is set then the old object is also deleted.

The object is placed in the an ordinal position dependent on the keys hash function. Subsequent searches use the has function to speed access to the data item.

Parameters:
- key Key for position in dictionary to add object.
ordinal - New ordinal value to put into the dictionary.
Returns:
TRUE if the object was successfully added.

ovirtual PINDEX RemoveAt( const K & key )
Remove an object at the specified key. The returned pointer is then removed using the SetAt() function to set that key value to NULL. If the AllowDeleteObjects option is set then the object is also deleted.

Parameters:
- key Key for position in dictionary to get object.
Returns:
pointer to the object being removed, or NULL if it was deleted.

oconst K& GetKeyAt( PINDEX index ) const
Get the key in the dictionary at the ordinal index position.

The ordinal position in the dictionary 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.

Parameters:
index - Ordinal position in dictionary for key.
Returns:
reference to key at the index position.

oPINDEX GetDataAt( PINDEX index ) const
Get the data in the dictionary at the ordinal index position.

The ordinal position in the dictionary 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.

Parameters:
index - Ordinal position in dictionary for data.
Returns:
reference to data at the index position.


Direct child classes:
PStringToOrdinal

Alphabetic index HTML hierarchy of classes or Java



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