POrdinalDictionary< K > Class Template Reference

#include <dict.h>

Inheritance diagram for POrdinalDictionary< K >:

PAbstractDictionary PHashTable PCollection PContainer PObject PStringToOrdinal List of all members.

Public Member Functions

Overrides from class PObject
virtual PObjectClone () const
New functions for class
PINDEX operator[] (const K &key) const
PBoolean Contains (const K &key) const
virtual POrdinalKeyGetAt (const K &key) const
virtual PBoolean SetDataAt (PINDEX index, PINDEX ordinal)
virtual PBoolean SetAt (const K &key, PINDEX ordinal)
virtual PINDEX RemoveAt (const K &key)
const K & GetKeyAt (PINDEX index) const
PINDEX GetDataAt (PINDEX index) const

Protected Member Functions

 POrdinalDictionary (int dummy, const POrdinalDictionary *c)

Detailed Description

template<class K>
class POrdinalDictionary< K >

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.


Constructor & Destructor Documentation

template<class K>
POrdinalDictionary< K >::POrdinalDictionary (  )  [inline]

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.

template<class K>
POrdinalDictionary< K >::POrdinalDictionary ( int  dummy,
const POrdinalDictionary< K > *  c 
) [inline, protected]

template<class K>
POrdinalDictionary< K >::POrdinalDictionary (  )  [inline]

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.


Member Function Documentation

template<class K>
virtual PObject* POrdinalDictionary< K >::Clone (  )  const [inline, virtual]

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.

Reimplemented from PObject.

template<class K>
PINDEX POrdinalDictionary< K >::operator[] ( const K &  key  )  const [inline]

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.

template<class K>
PBoolean POrdinalDictionary< K >::Contains ( const K &  key  )  const [inline]

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 dictionary.
Parameters:
key  Key to look for in the dictionary.

template<class K>
virtual POrdinalKey* POrdinalDictionary< K >::GetAt ( const K &  key  )  const [inline, virtual]

Parameters:
key  Key for position in dictionary to get object.

template<class K>
virtual PBoolean POrdinalDictionary< K >::SetDataAt ( PINDEX  index,
PINDEX  ordinal 
) [inline, virtual]

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.

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

template<class K>
virtual PBoolean POrdinalDictionary< K >::SetAt ( const K &  key,
PINDEX  ordinal 
) [inline, virtual]

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.

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

template<class K>
virtual PINDEX POrdinalDictionary< K >::RemoveAt ( const K &  key  )  [inline, virtual]

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.

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

template<class K>
const K& POrdinalDictionary< K >::GetKeyAt ( PINDEX  index  )  const [inline]

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.

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

template<class K>
PINDEX POrdinalDictionary< K >::GetDataAt ( PINDEX  index  )  const [inline]

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.

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


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 01:21:38 2008 for PTLib by  doxygen 1.5.1