PStringDictionary< K > Class Template Reference

#include <pstring.h>

Inheritance diagram for PStringDictionary< K >:

PAbstractDictionary PHashTable PCollection PContainer PObject POrdinalToString PStringToString PMIMEInfo List of all members.

Public Member Functions

Overrides from class PObject
virtual PObjectClone () const
New functions for class
const PStringoperator[] (const K &key) const
PString operator() (const K &key, const char *dflt="") const
PBoolean Contains (const K &key) const
virtual PStringRemoveAt (const K &key)
virtual PStringGetAt (const K &key) const
virtual PBoolean SetDataAt (PINDEX index, const PString &str)
virtual PBoolean SetAt (const K &key, const PString &str)
const K & GetKeyAt (PINDEX index) const
PStringGetDataAt (PINDEX index) const

Protected Member Functions

 PStringDictionary (int dummy, const PStringDictionary *c)

Detailed Description

template<class K>
class PStringDictionary< K >

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

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


Constructor & Destructor Documentation

template<class K>
PStringDictionary< K >::PStringDictionary (  )  [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>
PStringDictionary< K >::PStringDictionary ( int  dummy,
const PStringDictionary< K > *  c 
) [inline, protected]

template<class K>
PStringDictionary< K >::PStringDictionary (  )  [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* PStringDictionary< 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>
const PString& PStringDictionary< K >::operator[] ( const K &  key  )  const [inline]

Get the string 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.

This function asserts if there is no data at the key position.

Returns:
reference to the object indexed by the key.

template<class K>
PString PStringDictionary< K >::operator() ( const K &  key,
const char *  dflt = "" 
) const [inline]

Get the string 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.

This function returns the dflt# value if there is no data at the key position.

Returns:
reference to the object indexed by the key.

template<class K>
PBoolean PStringDictionary< 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.

template<class K>
virtual PString* PStringDictionary< 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 the key was not present in the dictionary. If the dictionary is set to delete objects upon removal, the value -1 is returned if the key existed prior to removal rather than returning an illegal pointer

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

Get the object at the specified key position. If the key was not in the collection then NULL is returned.

Returns:
pointer to object at the specified key.

template<class K>
virtual PBoolean PStringDictionary< K >::SetDataAt ( PINDEX  index,
const PString str 
) [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.

template<class K>
virtual PBoolean PStringDictionary< K >::SetAt ( const K &  key,
const PString str 
) [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.

template<class K>
const K& PStringDictionary< 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.

template<class K>
PString& PStringDictionary< 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.


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