65 { this->m_key = newKey;
return *
this; }
84 return Compare2(this->m_key, dynamic_cast<const my_type &>(obj).m_key);
96 return std::abs((PINDEX)this->m_key)%23;
98 return ((PINDEX)this->m_key)%23;
108 virtual void PrintOn(ostream & strm)
const { strm << this->m_key; }
180 __inline std::ostream & operator<<(std::ostream & strm, const
PHashTableList & hash) {
return strm << (
void *)hash.m_head; }
483 const PAbstractSet & set
490 const PAbstractSet & set1,
491 const PAbstractSet & set2,
492 PAbstractSet * intersection = NULL
559 ) { this->
Append(obj.Clone());
return *
this; }
581 ) { this->
erase(this->
find(obj));
return *
this; }
629 class const_iterator;
638 ,
element(t->GetElementAt((PINDEX)0))
678 iterator
end() {
return iterator(); }
702 const_iterator
end()
const {
return const_iterator(); }
703 const_iterator
find(
const T & k)
const {
return const_iterator(this->
hashTable, k); }
727 #define PSET(cls, T) typedef PSet<T> cls
741 #define PDECLARE_SET(cls, T, initDelObj) \
742 class cls : public PSet<T> { \
743 typedef PSet<T> BaseClass; PCLASSINFO(cls, BaseClass) \
745 cls(int dummy, const cls * c) \
746 : BaseClass(dummy, c) { } \
748 cls(PBoolean initialDeleteObjects = initDelObj) \
749 : BaseClass(initialDeleteObjects) { } \
750 virtual PObject * Clone() const \
751 { return PNEW cls(0, this); } \
950 virtual PINDEX Append(
1023 )
const {
return dynamic_cast<const D &
>(this->
GetRefAt(key)); }
1026 ) {
return dynamic_cast<D &
>(this->
GetRefAt(key)); }
1051 ) {
return dynamic_cast<D *
>(this->
AbstractSetAt(key, NULL)); }
1077 )
const {
return dynamic_cast<D *
>(this->
AbstractGetAt(key)); }
1128 class const_iterator;
1160 if (element != NULL) {
1180 template<
class CK,
class CD>
1210 iterator
begin() {
return iterator(
this); }
1211 iterator
end() {
return iterator(); }
1212 iterator
find(
const K & key) {
return iterator(
this, key); }
1236 const_iterator
begin()
const {
return const_iterator(
this); }
1237 const_iterator
end()
const {
return const_iterator(); }
1238 const_iterator
find(
const K & k)
const {
return const_iterator(
this, k); }
1262 #define PDICTIONARY(cls, K, D) typedef PDictionary<K, D> cls
1277 #define PDECLARE_DICTIONARY(cls, K, D) \
1278 PDICTIONARY(cls##_PTemplate, K, D); \
1279 PDECLARE_CLASS(cls, cls##_PTemplate) \
1281 cls(int dummy, const cls * c) \
1282 : cls##_PTemplate(dummy, c) { } \
1285 : cls##_PTemplate() { } \
1286 virtual PObject * Clone() const \
1287 { return PNEW cls(0, this); } \
1434 #define PORDINAL_DICTIONARY(cls, K) typedef POrdinalDictionary<K> cls
1451 #define PDECLARE_ORDINAL_DICTIONARY(cls, K) \
1452 PORDINAL_DICTIONARY(cls##_PTemplate, K); \
1453 PDECLARE_CLASS(cls, POrdinalDictionary<K>) \
1455 cls(int dummy, const cls * c) \
1456 : cls##_PTemplate(dummy, c) { } \
1459 : cls##_PTemplate() { } \
1460 virtual PObject * Clone() const \
1461 { return PNEW cls(0, this); } \
1464 #endif // PTLIB_DICT_H
PINLINE PBoolean AbstractContains(const PObject &key) const
Determine if the value of the object is contained in the hash table.
PINLINE value_type operator--(int)
Operator to post-decrement the ordinal.
Definition: dict.h:131
virtual const T & GetKeyAt(PINDEX index) const
Get the key in the set at the ordinal index position.
Definition: dict.h:620
PDictionary< K, D > dict_type
Definition: dict.h:985
const_iterator()
Definition: dict.h:688
iterator(PHashTableInfo *t, const T &k)
Definition: dict.h:661
PObject * RemoveElement(const PObject &key)
void Next()
Definition: dict.h:648
virtual PINDEX GetObjectsIndex(const PObject *obj) const
Search the collection for the specific instance of the object.
PKey< PINDEX > POrdinalKey
Definition: dict.h:146
void Include(const T *obj)
Include the specified object into the set.
Definition: dict.h:546
iterator_pair< K, D > pair
Definition: dict.h:1203
PHashTable()
Create a new, empty, hash table.
virtual PBoolean SetAt(PINDEX index, PObject *val)
Set the object at the specified index to the new value.
T * operator->() const
Definition: dict.h:671
iterator operator++()
Definition: dict.h:666
T * Ptr() const
Definition: dict.h:651
bool Union(const PAbstractSet &set)
Calculate union of sets.
iterator end()
Definition: dict.h:678
const D & operator[](const K &key) const
Get the object contained in the dictionary at the key position.
Definition: dict.h:1021
iterator_base(PHashTableInfo *t, const T &k)
Definition: dict.h:640
iterator end()
Definition: dict.h:1211
const K & GetKeyAt(PINDEX index) const
Get the key in the dictionary at the ordinal index position.
Definition: dict.h:1389
virtual void PrintOn(ostream &strm) const
Output the contents of the object to the stream.
virtual P_DEPRECATED PBoolean SetDataAt(PINDEX index, PObject *obj)
Set the data at the specified ordinal index position in the dictionary.
iterator find(const T &k)
Definition: dict.h:679
An array of objects.
Definition: array.h:714
void Destruct()
Internal function called from container destructors.
CD & second
Definition: dict.h:1184
virtual PINDEX InsertAt(PINDEX index, PObject *obj)
Add a new object to the collection.
virtual PBoolean SetAt(const K &key, PINDEX ordinal)
Add a new object to the collection.
Definition: dict.h:1371
PINLINE value_type operator++(int)
Operator to post-increment the ordinal.
Definition: dict.h:123
iterator operator--()
Definition: dict.h:1199
Array of characters.
Definition: array.h:552
PINDEX GetElementsIndex(const PObject *obj, PBoolean byVal, PBoolean keys) const
PSet(int dummy, const PSet *c)
Definition: dict.h:710
iterator begin()
Definition: dict.h:677
D * m_internal_second
Definition: dict.h:1132
const_iterator(PHashTableInfo *t, const T &k)
Definition: dict.h:685
T value_type
Definition: dict.h:51
PINLINE PKey & operator+=(value_type add)
Operator to add the ordinal.
Definition: dict.h:135
iterator operator++()
Definition: dict.h:1198
virtual PBoolean SetAt(PINDEX index, PObject *val)
Add a new object to the collection.
iterator(PHashTableInfo *t)
Definition: dict.h:660
This template class maps the PAbstractArray to a specific element type.
Definition: array.h:276
PHashTableElement * m_next
Definition: dict.h:156
PINLINE void AllowDeleteObjects(PBoolean yes=true)
Allow or disallow the deletion of the objects contained in the collection.
virtual PINDEX GetValuesIndex(const PObject &obj) const
Search the collection for the specified value of the object.
#define PTRACE_PARAM(...)
Definition: object.h:935
POrdinalDictionary()
Create a new, empty, dictionary.
Definition: dict.h:1311
virtual PObject * Clone() const
Make a complete duplicate of the dictionary.
Definition: dict.h:1321
PHashTableInfo * m_table
Definition: dict.h:1134
const_iterator operator--()
Definition: dict.h:1225
PHashTableElement * m_tail
Definition: dict.h:174
This template class maps the PAbstractDictionary to a specific key and data types.
Definition: dict.h:978
iterator operator--(int)
Definition: dict.h:1201
const_iterator operator++()
Definition: dict.h:690
#define PINLINE
Definition: object.h:194
void Prev()
Definition: dict.h:1172
iterator operator--()
Definition: dict.h:667
K key_type
Definition: dict.h:983
PKey< T > my_type
Definition: dict.h:52
const T * operator->() const
Definition: dict.h:695
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
PINLINE value_type operator--()
Operator to pre-decrement the ordinal.
Definition: dict.h:127
const_iterator operator++(int)
Definition: dict.h:692
virtual PINDEX GetObjectsIndex(const PObject *obj) const
Search the collection for the specific instance of the object.
const_iterator operator++(int)
Definition: dict.h:1226
iterator(dict_type *dict)
Definition: dict.h:1192
virtual PINDEX Append(PObject *obj)
Add a new object to the collection.
PINLINE PAbstractDictionary()
Create a new, empty, dictionary.
A set of ordinal integers.
Definition: dict.h:762
const_iterator(const dict_type *dict, const K &key)
Definition: dict.h:1218
virtual PObject * AbstractSetAt(const PObject &key, PObject *obj)
Add a new object to the collection.
iterator operator--(int)
Definition: dict.h:669
const_iterator()
Definition: dict.h:1221
PHashTableElement * m_head
Definition: dict.h:173
const_iterator operator--(int)
Definition: dict.h:693
#define P_POP_MSVC_WARNINGS()
Definition: object.h:154
void Next()
Definition: dict.h:1171
iterator_base(PHashTableInfo *t)
Definition: dict.h:636
iterator operator++(int)
Definition: dict.h:668
const_iterator begin() const
Definition: dict.h:701
virtual PObject * GetAt(PINDEX index) const
This function is the same as PHashTable::AbstractGetKeyAt().
const pair * operator->() const
Definition: dict.h:1230
void erase(const const_iterator &it)
Definition: dict.h:1241
virtual PObject * Clone() const
Clone the object.
Definition: dict.h:194
PINDEX operator[](const K &key) const
Get the object contained in the dictionary at the key position.
Definition: dict.h:1337
virtual void AbstractGetKeys(PArrayObjects &keys) const
Get an array containing all the keys for the dictionary.
virtual PINDEX GetValuesIndex(const PObject &obj) const
Search the collection for the specified value of the object.
K * m_internal_first
Definition: dict.h:1131
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two hash tables.
void SetElement(PHashTableElement *element)
Definition: dict.h:1157
T & operator*() const
Definition: dict.h:672
iterator_base(const dict_type *dict, const K &key)
Definition: dict.h:1151
bool operator!=(const iterator_base &it) const
Definition: dict.h:655
bool deleteKeys
Definition: dict.h:206
PBoolean Contains(const T &key) const
Determine if the value of the object is contained in the set.
Definition: dict.h:591
const_iterator begin() const
Definition: dict.h:1236
virtual void PrintOn(ostream &strm) const
Output the ordinal index to the specified stream.
Definition: dict.h:108
virtual PBoolean SetSize(PINDEX newSize)
This function is meaningless for hash table.
virtual PINDEX HashFunction() const
This function calculates a hash table index value for the implementation of PSet and PDictionary clas...
Definition: dict.h:93
PDECLARE_POOL_ALLOCATOR(PHashTableElement)
POrdinalDictionary(int dummy, const POrdinalDictionary *c)
Definition: dict.h:1417
PBoolean operator[](const T &key) const
Determine if the value of the object is contained in the set.
Definition: dict.h:603
PHashTableList()
Definition: dict.h:166
virtual PObject * Clone() const
Make a complete duplicate of the set.
Definition: dict.h:531
PDictionary(int dummy, const PDictionary *c)
Definition: dict.h:1245
PINLINE PKey & operator=(value_type newKey)
Operator to assign the ordinal.
Definition: dict.h:64
iterator_base()
Definition: dict.h:632
PHashTableInfo(PINDEX initialSize=0)
Definition: dict.h:190
Abstract set of PObjects.
Definition: dict.h:330
virtual Comparison Compare(const PObject &obj) const
Compare the two objects and return their relative rank.
Definition: dict.h:82
virtual PObject * AbstractGetAt(const PObject &key) const
Get the object at the specified key position.
iterator find(const K &key)
Definition: dict.h:1212
iterator()
Definition: dict.h:1196
const_iterator find(const T &k) const
Definition: dict.h:703
void Prev()
Definition: dict.h:649
This class is used when an ordinal index value is the key for PSet and PDictionary classes...
Definition: dict.h:47
PINDEX m_bucket
Definition: dict.h:158
const_iterator operator--(int)
Definition: dict.h:1227
D & GetDataAt(PINDEX index) const
Get the data in the dictionary at the ordinal index position.
Definition: dict.h:1110
#define PAssertNULL(ptr)
This macro is used to assert that a pointer must be non-null.
Definition: object.h:428
bool operator!=(const iterator_base &it) const
Definition: dict.h:1177
void erase(const iterator &it)
Definition: dict.h:1240
virtual PINDEX GetSize() const
Get the current size of the container.
PBoolean Contains(const K &key) const
Determine if the value of the object is contained in the hash table.
Definition: dict.h:1036
bool PBoolean
Definition: object.h:174
const pair & operator*() const
Definition: dict.h:1205
iterator operator++(int)
Definition: dict.h:1200
PHashTableElement * PrevElement(PHashTableElement *element) const
const_iterator end() const
Definition: dict.h:702
This template class maps the PAbstractSet to a specific object type.
Definition: dict.h:508
bool operator==(const iterator_base &it) const
Definition: dict.h:654
virtual ~PHashTableInfo()
Definition: dict.h:195
#define PDECLARE_SET(cls, T, initDelObj)
Begin declaration of a set class.
Definition: dict.h:741
void erase(const const_iterator &it)
Definition: dict.h:706
PHashTableElement * m_element
Definition: dict.h:1135
#define P_PUSH_MSVC_WARNINGS(warnings)
Definition: object.h:153
const pair & operator*() const
Definition: dict.h:1231
virtual D * GetAt(const K &key) const
Get the object at the specified key position.
Definition: dict.h:1075
virtual PINDEX Insert(const PObject &before, PObject *obj)
Add a new object to the collection.
void AppendElement(PObject *key, PObject *data PTRACE_PARAM(, PHashTable *owner))
The hash table class is the basis for implementing the PSet and PDictionary classes.
Definition: dict.h:224
bool deleteObjects
Definition: contain.h:67
PObject * m_key
Definition: dict.h:154
const_iterator end() const
Definition: dict.h:1237
iterator_base(const dict_type *dict)
Definition: dict.h:1145
PSet & operator+=(const T &obj)
Include the specified objects value into the set.
Definition: dict.h:557
iterator_pair< const K, const D > pair
Definition: dict.h:1229
virtual PINDEX Insert(const PObject &key, PObject *obj)
Insert a new object into the dictionary.
virtual PObject * RemoveAt(PINDEX index)
Remove an object at the specified index.
static bool Intersection(const PAbstractSet &set1, const PAbstractSet &set2, PAbstractSet *intersection=NULL)
Calculate intersection of sets.
virtual PINDEX InsertAt(PINDEX index, PObject *obj)
Insert a new object at the specified index.
PHashTableInfo(PHashTableList const *buffer, PINDEX length, PBoolean dynamic=true)
Definition: dict.h:192
iterator()
Definition: dict.h:664
virtual PObject * GetAt(PINDEX index) const
Get the object at the specified index position.
PHashTableElement * GetElementAt(PINDEX index)
const_iterator operator--()
Definition: dict.h:691
iterator(dict_type *dict, const K &key)
Definition: dict.h:1193
void Exclude(const T *obj)
Remove the object from the set.
Definition: dict.h:568
PSet & operator-=(const T &obj)
Remove the objects value from the set.
Definition: dict.h:579
static Comparison Compare2(T v1, T v2)
Compare two types, returning Comparison type.
Definition: object.h:2258
PINLINE PKey(value_type newKey=0)
Create a new key for ordinal index values.
Definition: dict.h:58
PSet(PBoolean initialDeleteObjects=false)
Create a new, empty, dictionary.
Definition: dict.h:522
PTRACE_THROTTLE(m_throttlePoorHashFunction, 1)
virtual void DestroyContents()
Destroy the container contents.
const_iterator find(const K &k) const
Definition: dict.h:1238
virtual PObject & GetRefAt(const PObject &key) const
Get the object at the specified key position.
virtual const PObject & AbstractGetKeyAt(PINDEX index) const
Get the key in the hash table at the ordinal index position.
PINLINE PKey & operator-=(value_type minus)
Operator to subtract from the ordinal.
Definition: dict.h:139
D & operator[](const K &key)
Definition: dict.h:1024
PHashTableElement * NextElement(PHashTableElement *element) const
virtual PBoolean SetAt(const K &key, D *obj)
Add a new object to the collection.
Definition: dict.h:1064
iterator_base()
Definition: dict.h:1137
const T & operator*() const
Definition: dict.h:696
const K & GetKeyAt(PINDEX index) const
Get the key in the dictionary at the ordinal index position.
Definition: dict.h:1092
const_iterator(const dict_type *dict)
Definition: dict.h:1217
#define P_DEPRECATED
Definition: object.h:141
virtual PObject * RemoveAt(PINDEX index)
Remove an object at the specified index.
virtual PBoolean SetDataAt(PINDEX index, PINDEX ordinal)
Set the data at the specified ordinal index position in the dictionary.
Definition: dict.h:1355
virtual PObject * Clone() const
Create a duplicate of the PKey.
Definition: dict.h:71
const_iterator(iterator it)
Definition: dict.h:1222
CK & first
Definition: dict.h:1183
void erase(const iterator &it)
Definition: dict.h:705
PINLINE value_type operator++()
Operator to pre-increment the ordinal.
Definition: dict.h:119
virtual D * RemoveAt(const K &key)
Remove an object at the specified key.
Definition: dict.h:1049
PHashTableInfo * table
Definition: dict.h:645
virtual PBoolean Remove(const PObject *obj)
Remove the object from the collection.
PINLINE PAbstractSet()
Create a new, empty, set.
PINDEX GetDataAt(PINDEX index) const
Get the data in the dictionary at the ordinal index position.
Definition: dict.h:1410
PContainerReference * reference
Definition: contain.h:288
virtual PObject & AbstractGetDataAt(PINDEX index) const
Get the data in the hash table at the ordinal index position.
iterator begin()
Definition: dict.h:1210
const_iterator operator++()
Definition: dict.h:1224
This template class maps the PAbstractDictionary to a specific key type and a POrdinalKey data type...
Definition: dict.h:1297
PHashTableElement * element
Definition: dict.h:646
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
A collection is a container that collects together descendents of the PObject class.
Definition: contain.h:392
virtual PObject * Clone() const
Make a complete duplicate of the dictionary.
Definition: dict.h:1005
D data_type
Definition: dict.h:984
PDictionary()
Create a new, empty, dictionary.
Definition: dict.h:995
const_iterator(PHashTableInfo *t)
Definition: dict.h:684
#define PTRACING
Definition: object.h:482
PObject * m_data
Definition: dict.h:155
PArray< K > GetKeys() const
Get an array containing all the keys for the dictionary.
Definition: dict.h:1117
PHashTableInfo * hashTable
Definition: dict.h:322
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:1896
PHashTableElement * m_prev
Definition: dict.h:157
const pair * operator->() const
Definition: dict.h:1204