#include <pstring.h>
Inheritance diagram for PStringDictionary< K >:
Public Member Functions | |
Overrides from class PObject | |
virtual PObject * | Clone () const |
New functions for class | |
const PString & | operator[] (const K &key) const |
PString | operator() (const K &key, const char *dflt="") const |
PBoolean | Contains (const K &key) const |
virtual PString * | RemoveAt (const K &key) |
virtual PString * | GetAt (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 |
PString & | GetDataAt (PINDEX index) const |
Protected Member Functions | |
PStringDictionary (int dummy, const PStringDictionary *c) |
Note that if templates are not used the PDECLARE_STRING_DICTIONARY# macro will simulate the template instantiation.
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.
PStringDictionary< K >::PStringDictionary | ( | int | dummy, | |
const PStringDictionary< K > * | c | |||
) | [inline, protected] |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.