98 virtual void PrintOn(ostream & strm)
const;
105 PINLINE operator PINDEX()
const;
155 virtual ~PHashTableInfo() { Destruct(); }
156 virtual void DestroyContents();
253 virtual const PObject & AbstractGetKeyAt(
271 virtual PObject & AbstractGetDataAt(
311 virtual PINDEX Append(
327 virtual PINDEX Insert(
344 virtual PINDEX InsertAt(
410 virtual PINDEX GetObjectsIndex(
422 virtual PINDEX GetValuesIndex(
430 const PAbstractSet &
set 436 static bool Intersection(
437 const PAbstractSet & set1,
438 const PAbstractSet & set2,
439 PAbstractSet * intersection = NULL
470 :
PAbstractSet() { AllowDeleteObjects(initialDeleteObjects); }
506 ) { Append(obj.Clone());
return *
this; }
528 ) { RemoveAt(GetValuesIndex(obj));
return *
this; }
540 )
const {
return AbstractContains(key); }
552 )
const {
return AbstractContains(key); }
568 {
return (
const T &)AbstractGetKeyAt(index); }
590 #define PSET(cls, T) typedef PSet<T> cls 604 #define PDECLARE_SET(cls, T, initDelObj) \ 605 class cls : public PSet<T> { \ 606 typedef PSet<T> BaseClass; PCLASSINFO(cls, BaseClass) \ 608 cls(int dummy, const cls * c) \ 609 : BaseClass(dummy, c) { } \ 611 cls(PBoolean initialDeleteObjects = initDelObj) \ 612 : BaseClass(initialDeleteObjects) { } \ 613 virtual PObject * Clone() const \ 614 { return PNEW cls(0, this); } \ 663 virtual PINDEX Insert(
674 virtual PINDEX InsertAt(
726 virtual PINDEX GetObjectsIndex(
738 virtual PINDEX GetValuesIndex(
794 virtual PObject * AbstractGetAt(
800 virtual void AbstractGetKeys(
806 PINLINE PAbstractDictionary(
int dummy,
const PAbstractDictionary * c);
814 virtual PINDEX Append(
884 {
return (D &)GetRefAt(key); }
896 )
const {
return AbstractContains(key); }
912 D * obj = GetAt(key); AbstractSetAt(key, NULL);
913 return reference->deleteObjects ? (obj ? (D *)-1 : NULL) : obj;
930 ) {
return AbstractSetAt(key, obj); }
940 )
const {
return (D *)AbstractGetAt(key); }
956 {
return (
const K &)AbstractGetKeyAt(index); }
972 {
return (D &)AbstractGetDataAt(index); }
979 AbstractGetKeys(keys);
1004 #define PDICTIONARY(cls, K, D) typedef PDictionary<K, D> cls 1019 #define PDECLARE_DICTIONARY(cls, K, D) \ 1020 PDICTIONARY(cls##_PTemplate, K, D); \ 1021 PDECLARE_CLASS(cls, cls##_PTemplate) \ 1023 cls(int dummy, const cls * c) \ 1024 : cls##_PTemplate(dummy, c) { } \ 1027 : cls##_PTemplate() { } \ 1028 virtual PObject * Clone() const \ 1029 { return PNEW cls(0, this); } \ 1093 )
const {
return AbstractContains(key); }
1097 )
const {
return (
POrdinalKey *)AbstractGetAt(key); }
1144 ) { PINDEX ord = *GetAt(key); AbstractSetAt(key, NULL);
return ord; }
1160 {
return (
const K &)AbstractGetKeyAt(index); }
1176 {
return (
POrdinalKey &)AbstractGetDataAt(index); }
1197 #define PORDINAL_DICTIONARY(cls, K) typedef POrdinalDictionary<K> cls 1214 #define PDECLARE_ORDINAL_DICTIONARY(cls, K) \ 1215 PORDINAL_DICTIONARY(cls##_PTemplate, K); \ 1216 PDECLARE_CLASS(cls, POrdinalDictionary<K>) \ 1218 cls(int dummy, const cls * c) \ 1219 : cls##_PTemplate(dummy, c) { } \ 1222 : cls##_PTemplate() { } \ 1223 virtual PObject * Clone() const \ 1224 { return PNEW cls(0, this); } \ 1227 #endif // PTLIB_DICT_H virtual const T & GetKeyAt(PINDEX index) const
Get the key in the set at the ordinal index position.
Definition: dict.h:565
virtual POrdinalKey * GetAt(const K &key) const
Definition: dict.h:1095
void Include(const T *obj)
Include the specified object into the set.
Definition: dict.h:493
const K & GetKeyAt(PINDEX index) const
Get the key in the dictionary at the ordinal index position.
Definition: dict.h:1157
PINDEX GetElementsIndex(const PObject *obj, PBoolean byVal, PBoolean keys) const
An array of objects.
Definition: array.h:813
D & operator[](const K &key) const
Get the object contained in the dictionary at the key position.
Definition: dict.h:881
virtual PBoolean SetAt(const K &key, PINDEX ordinal)
Add a new object to the collection.
Definition: dict.h:1129
virtual PINDEX RemoveAt(const K &key)
Remove an object at the specified key.
Definition: dict.h:1142
PObject * data
Definition: dict.h:143
PSet(int dummy, const PSet *c)
Definition: dict.h:573
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PBoolean SetLastElementAt(PINDEX index, PHashTableElement *&lastElement)
virtual Comparison Compare(const PObject &obj) const
Compare the two objects and return their relative rank.
PBoolean Contains(const K &key) const
Determine if the value of the object is contained in the hash table.
Definition: dict.h:1091
POrdinalDictionary()
Create a new, empty, dictionary.
Definition: dict.h:1052
virtual PObject * Clone() const
Make a complete duplicate of the dictionary.
Definition: dict.h:1062
friend class PHashTable
Definition: dict.h:167
PINLINE POrdinalKey(PINDEX newKey=0)
Create a new key for ordinal index values.
This template class maps the PAbstractDictionary to a specific key and data types.
Definition: dict.h:842
virtual PINDEX HashFunction() const
This function calculates a hash table index value for the implementation of PSet and PDictionary clas...
PHashTableElement * prev
Definition: dict.h:145
#define PINLINE
Definition: object.h:127
PINDEX AppendElement(PObject *key, PObject *data)
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
An abstract dictionary container.
Definition: dict.h:626
PINLINE PINDEX operator--()
Operator to pre-decrement the ordinal.
PINLINE POrdinalKey & operator-=(PINDEX)
Operator to subtract from the ordinal.
PHashTableElement Element
Definition: dict.h:166
PINDEX operator[](const K &key) const
Get the object contained in the dictionary at the key position.
Definition: dict.h:1078
PHashTableElement Element
Definition: dict.h:277
PHashTableInfo Table
Definition: dict.h:278
PBoolean Contains(const T &key) const
Determine if the value of the object is contained in the set.
Definition: dict.h:538
BOOL PBoolean
Definition: object.h:102
PObject * key
Definition: dict.h:142
POrdinalDictionary(int dummy, const POrdinalDictionary *c)
Definition: dict.h:1180
PBoolean operator[](const T &key) const
Determine if the value of the object is contained in the set.
Definition: dict.h:550
virtual PObject * Clone() const
Make a complete duplicate of the set.
Definition: dict.h:478
PDictionary(int dummy, const PDictionary *c)
Definition: dict.h:987
virtual void PrintOn(ostream &strm) const
Output the ordinal index to the specified stream.
Abstract set of PObjects.
Definition: dict.h:287
#define PDECLARE_POOL_ALLOCATOR()
Definition: object.h:1025
virtual PBoolean SetDataAt(PINDEX index, PObject *obj)
Set the data at the specified ordinal index position in the dictionary.
D & GetDataAt(PINDEX index) const
Get the data in the dictionary at the ordinal index position.
Definition: dict.h:969
PINLINE PINDEX operator++()
Operator to pre-increment the ordinal.
PBoolean Contains(const K &key) const
Determine if the value of the object is contained in the hash table.
Definition: dict.h:894
#define PDECLARE_BASEARRAY(cls, T)
Begin a declaration of an array of base types.
Definition: array.h:474
This template class maps the PAbstractSet to a specific object type.
Definition: dict.h:455
#define PDECLARE_SET(cls, T, initDelObj)
Begin declaration of a set class.
Definition: dict.h:604
friend class PAbstractSet
Definition: dict.h:168
virtual D * GetAt(const K &key) const
Get the object at the specified key position.
Definition: dict.h:938
The hash table class is the basis for implementing the PSet and PDictionary classes.
Definition: dict.h:182
bool deleteObjects
Definition: contain.h:72
#define PCONTAINERINFO(cls, par)
Macro to declare funtions required in a container.
Definition: contain.h:343
PSet & operator+=(const T &obj)
Include the specified objects value into the set.
Definition: dict.h:504
std::pair< K, D * > value_type
Definition: dict.h:984
void Exclude(const T *obj)
Remove the object from the set.
Definition: dict.h:515
PSet & operator-=(const T &obj)
Remove the objects value from the set.
Definition: dict.h:526
virtual PObject * Clone() const
Create a duplicate of the POrdinalKey.
PSet(PBoolean initialDeleteObjects=false)
Create a new, empty, dictionary.
Definition: dict.h:469
PBoolean deleteKeys
Definition: dict.h:164
PHashTableElement * GetElementAt(const PObject &key)
PINLINE POrdinalKey & operator+=(PINDEX)
Operator to add the ordinal.
virtual PBoolean SetAt(const K &key, D *obj)
Add a new object to the collection.
Definition: dict.h:927
This template class maps the PArrayObjects to a specific object type.
Definition: array.h:1024
const K & GetKeyAt(PINDEX index) const
Get the key in the dictionary at the ordinal index position.
Definition: dict.h:953
PINLINE POrdinalKey & operator=(PINDEX)
Operator to assign the ordinal.
virtual PBoolean SetDataAt(PINDEX index, PINDEX ordinal)
Set the data at the specified ordinal index position in the dictionary.
Definition: dict.h:1113
virtual D * RemoveAt(const K &key)
Remove an object at the specified key.
Definition: dict.h:909
PINDEX GetDataAt(PINDEX index) const
Get the data in the dictionary at the ordinal index position.
Definition: dict.h:1173
PContainerReference * reference
Definition: contain.h:291
PObject * RemoveElement(const PObject &key)
This template class maps the PAbstractDictionary to a specific key type and a POrdinalKey data type...
Definition: dict.h:1039
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
A collection is a container that collects together descendents of the PObject class.
Definition: contain.h:395
virtual PObject * Clone() const
Make a complete duplicate of the dictionary.
Definition: dict.h:865
PDictionary()
Create a new, empty, dictionary.
Definition: dict.h:855
PHashTableElement * next
Definition: dict.h:144
PArray< K > GetKeys() const
Get an array containing all the keys for the dictionary.
Definition: dict.h:976
PHashTableInfo * hashTable
Definition: dict.h:279
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:890
This class is used when an ordinal index value is the key for PSet and PDictionary classes...
Definition: dict.h:50