Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dict.h

Go to the documentation of this file.
00001 /* 00002 * dict.h 00003 * 00004 * Dictionary (hash table) Container classes. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Log: dict.h,v $ 00030 * Revision 1.33 2004/04/09 03:42:34 csoutheren 00031 * Removed all usages of "virtual inline" and "inline virtual" 00032 * 00033 * Revision 1.32 2004/04/03 23:53:09 csoutheren 00034 * Added various changes to improce compatibility with the Sun Forte compiler 00035 * Thanks to Brian Cameron 00036 * Added detection of readdir_r version 00037 * 00038 * Revision 1.31 2003/09/17 01:18:02 csoutheren 00039 * Removed recursive include file system and removed all references 00040 * to deprecated coooperative threading support 00041 * 00042 * Revision 1.30 2003/03/31 01:23:56 robertj 00043 * Added ReadFrom functions for standard container classes such as 00044 * PIntArray and PStringList etc 00045 * 00046 * Revision 1.29 2002/10/04 01:47:29 robertj 00047 * Added various increment and decrement operators to POrdinalKey. 00048 * 00049 * Revision 1.28 2002/09/16 01:08:59 robertj 00050 * Added #define so can select if #pragma interface/implementation is used on 00051 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00052 * 00053 * Revision 1.27 2002/06/14 13:22:12 robertj 00054 * Fixed ability to remove elements from a PSet by value. 00055 * Added by value add and remove functions to a PSet. 00056 * Added a POrdinalSet class. 00057 * Fixed some documentation. 00058 * 00059 * Revision 1.26 2002/02/06 00:53:25 robertj 00060 * Fixed missing const on PSet::Contains and operator[], thanks Francisco Olarte Sanz 00061 * 00062 * Revision 1.25 1999/11/30 00:22:54 robertj 00063 * Updated documentation for doc++ 00064 * 00065 * Revision 1.24 1999/08/22 12:13:43 robertj 00066 * Fixed warning when using inlines on older GNU compiler 00067 * 00068 * Revision 1.23 1999/03/09 02:59:49 robertj 00069 * Changed comments to doc++ compatible documentation. 00070 * 00071 * Revision 1.22 1999/02/16 08:07:11 robertj 00072 * MSVC 6.0 compatibility changes. 00073 * 00074 * Revision 1.21 1998/09/23 06:20:27 robertj 00075 * Added open source copyright license. 00076 * 00077 * Revision 1.20 1998/01/05 10:39:34 robertj 00078 * Fixed "typesafe" templates/macros for dictionaries, especially on GNU. 00079 * 00080 * Revision 1.19 1997/12/11 10:27:16 robertj 00081 * Added type correct Contains() function to dictionaries. 00082 * 00083 * Revision 1.18 1997/07/08 13:15:05 robertj 00084 * DLL support. 00085 * 00086 * Revision 1.17 1997/06/08 04:49:11 robertj 00087 * Fixed non-template class descendent order. 00088 * 00089 * Revision 1.16 1996/08/17 10:00:22 robertj 00090 * Changes for Windows DLL support. 00091 * 00092 * Revision 1.15 1996/03/31 08:44:10 robertj 00093 * Added RemoveAt() function to remove entries from dictionaries. 00094 * 00095 * Revision 1.14 1996/02/08 11:50:01 robertj 00096 * Moved Contains function from PSet to PHashTable so available for dictionaries. 00097 * Added print for dictionaries key=data\n. 00098 * Added GetAt(PINDEX) to template classes to make identical to macro. 00099 * 00100 * Revision 1.13 1996/02/03 11:00:28 robertj 00101 * Temporary removal of SetAt() and GetAt() functions in dictionary macro. 00102 * 00103 * Revision 1.12 1996/01/24 14:43:11 robertj 00104 * Added initialisers to string dictionaries. 00105 * 00106 * Revision 1.11 1996/01/23 13:11:12 robertj 00107 * Mac Metrowerks compiler support. 00108 * 00109 * Revision 1.10 1995/06/17 11:12:29 robertj 00110 * Documentation update. 00111 * 00112 * Revision 1.9 1995/06/04 08:45:57 robertj 00113 * Better C++ compatibility (with BC++) 00114 * 00115 * Revision 1.8 1995/03/14 12:41:19 robertj 00116 * Updated documentation to use HTML codes. 00117 * 00118 * Revision 1.7 1995/02/22 10:50:29 robertj 00119 * Changes required for compiling release (optimised) version. 00120 * 00121 * Revision 1.6 1995/02/11 04:10:35 robertj 00122 * Fixed dictionary MACRO for templates. 00123 * 00124 * Revision 1.5 1995/02/05 00:48:03 robertj 00125 * Fixed template version. 00126 * 00127 * Revision 1.4 1995/01/09 12:35:31 robertj 00128 * Removed unnecesary return value from I/O functions. 00129 * Changes due to Mac port. 00130 * 00131 * Revision 1.3 1994/12/21 11:52:51 robertj 00132 * Documentation and variable normalisation. 00133 * 00134 * Revision 1.2 1994/12/17 01:36:57 robertj 00135 * Fixed memory leak in PStringSet 00136 * 00137 * Revision 1.1 1994/12/12 09:59:32 robertj 00138 * Initial revision 00139 * 00140 */ 00141 00142 #ifdef P_USE_PRAGMA 00143 #pragma interface 00144 #endif 00145 00146 00148 // PDictionary classes 00149 00153 class POrdinalKey : public PObject 00154 { 00155 PCLASSINFO(POrdinalKey, PObject); 00156 00157 public: 00162 PINLINE POrdinalKey( 00163 PINDEX newKey = 0 00164 ); 00165 00168 PINLINE POrdinalKey & operator=(PINDEX); 00170 00173 00174 virtual PObject * Clone() const; 00175 00176 /* Get the relative rank of the ordinal index. This is a simpel comparison 00177 of the objects PINDEX values. 00178 00179 @return 00180 comparison of the two objects, #EqualTo# for same, 00181 #LessThan# for #obj# logically less than the 00182 object and #GreaterThan# for #obj# logically 00183 greater than the object. 00184 */ 00185 virtual Comparison Compare(const PObject & obj) const; 00186 00193 virtual PINDEX HashFunction() const; 00194 00201 virtual void PrintOn(ostream & strm) const; 00203 00208 PINLINE operator PINDEX() const; 00209 00212 PINLINE PINDEX operator++(); 00213 00216 PINLINE PINDEX operator++(int); 00217 00220 PINLINE PINDEX operator--(); 00221 00224 PINLINE PINDEX operator--(int); 00225 00228 PINLINE POrdinalKey & operator+=(PINDEX); 00229 00232 PINLINE POrdinalKey & operator-=(PINDEX ); 00234 00235 private: 00236 PINDEX theKey; 00237 }; 00238 00239 00241 00252 class PHashTable : public PCollection 00253 { 00254 PCONTAINERINFO(PHashTable, PCollection); 00255 00256 public: 00259 00260 PHashTable(); 00262 00274 virtual Comparison Compare( 00275 const PObject & obj 00276 ) const; 00278 00279 00280 protected: 00290 virtual BOOL SetSize( 00291 PINDEX newSize 00292 ); 00294 00295 00306 PINLINE BOOL AbstractContains( 00307 const PObject & key 00308 ) const; 00309 00324 virtual const PObject & AbstractGetKeyAt( 00325 PINDEX index 00326 ) const; 00327 00342 virtual PObject & AbstractGetDataAt( 00343 PINDEX index 00344 ) const; 00346 00347 00348 // Member variables 00349 class Element { 00350 public: 00351 friend class Table; 00352 PObject * key; 00353 PObject * data; 00354 Element * next; 00355 Element * prev; 00356 }; 00357 00358 PDECLARE_BASEARRAY(Table, Element *) 00359 #ifdef DOC_PLUS_PLUS 00360 { 00361 #endif 00362 public: 00363 virtual ~Table() { Destruct(); } 00364 virtual void DestroyContents(); 00365 00366 PINDEX AppendElement(PObject * key, PObject * data); 00367 PObject * RemoveElement(const PObject & key); 00368 BOOL SetLastElementAt(PINDEX index); 00369 Element * GetElementAt(const PObject & key); 00370 PINDEX GetElementsIndex(const PObject*obj,BOOL byVal,BOOL keys) const; 00371 00372 PINDEX lastIndex; 00373 PINDEX lastBucket; 00374 Element * lastElement; 00375 00376 BOOL deleteKeys; 00377 00378 friend class PHashTable; 00379 friend class PAbstractSet; 00380 }; 00381 friend class Table; 00382 00383 00384 Table * hashTable; 00385 }; 00386 00387 00389 00392 class PAbstractSet : public PHashTable 00393 { 00394 PCONTAINERINFO(PAbstractSet, PHashTable); 00395 public: 00403 PINLINE PAbstractSet(); 00405 00416 virtual PINDEX Append( 00417 PObject * obj 00418 ); 00419 00432 virtual PINDEX Insert( 00433 const PObject & before, 00434 PObject * obj 00435 ); 00436 00449 virtual PINDEX InsertAt( 00450 PINDEX index, 00451 PObject * obj 00452 ); 00453 00464 virtual BOOL Remove( 00465 const PObject * obj 00466 ); 00467 00474 virtual PObject * RemoveAt( 00475 PINDEX index 00476 ); 00477 00483 virtual PObject * GetAt( 00484 PINDEX index 00485 ) const; 00486 00499 virtual BOOL SetAt( 00500 PINDEX index, 00501 PObject * val 00502 ); 00503 00515 virtual PINDEX GetObjectsIndex( 00516 const PObject * obj 00517 ) const; 00518 00527 virtual PINDEX GetValuesIndex( 00528 const PObject & obj 00529 ) const; 00531 }; 00532 00533 00534 #ifdef PHAS_TEMPLATES 00535 00546 template <class T> class PSet : public PAbstractSet 00547 { 00548 PCLASSINFO(PSet, PAbstractSet); 00549 00550 public: 00560 inline PSet(BOOL initialDeleteObjects = FALSE) 00561 : PAbstractSet() { AllowDeleteObjects(initialDeleteObjects); } 00563 00569 virtual PObject * Clone() const 00570 { return PNEW PSet(0, this); } 00572 00584 void Include( 00585 const T * obj // New object to include in the set. 00586 ) { Append((PObject *)obj); } 00587 00595 PSet & operator+=( 00596 const T & obj // New object to include in the set. 00597 ) { Append(obj.Clone()); return *this; } 00598 00606 void Exclude( 00607 const T * obj // New object to exclude in the set. 00608 ) { Remove(obj); } 00609 00617 PSet & operator-=( 00618 const T & obj // New object to exclude in the set. 00619 ) { RemoveAt(GetValuesIndex(obj)); return *this; } 00620 00629 BOOL Contains( 00630 const T & key 00631 ) const { return AbstractContains(key); } 00632 00641 BOOL operator[]( 00642 const T & key 00643 ) const { return AbstractContains(key); } 00644 00656 virtual const T & GetKeyAt( 00657 PINDEX index 00658 ) const 00659 { return (const T &)AbstractGetKeyAt(index); } 00661 00662 00663 protected: 00664 PSet(int dummy, const PSet * c) 00665 : PAbstractSet(dummy, c) 00666 { reference->deleteObjects = c->reference->deleteObjects; } 00667 }; 00668 00669 00681 #define PSET(cls, T) typedef PSet<T> cls 00682 00683 00695 #define PDECLARE_SET(cls, T, initDelObj) \ 00696 PSET(cls##_PTemplate, T); \ 00697 PDECLARE_CLASS(cls, cls##_PTemplate) \ 00698 protected: \ 00699 cls(int dummy, const cls * c) \ 00700 : cls##_PTemplate(dummy, c) { } \ 00701 public: \ 00702 cls(BOOL initialDeleteObjects = initDelObj) \ 00703 : cls##_PTemplate(initialDeleteObjects) { } \ 00704 virtual PObject * Clone() const \ 00705 { return PNEW cls(0, this); } \ 00706 00707 00708 #else // PHAS_TEMPLATES 00709 00710 00711 #define PSET(cls, K) \ 00712 class cls : public PAbstractSet { \ 00713 PCLASSINFO(cls, PAbstractSet); \ 00714 protected: \ 00715 inline cls(int dummy, const cls * c) \ 00716 : PAbstractSet(dummy, c) \ 00717 { reference->deleteObjects = c->reference->deleteObjects; } \ 00718 public: \ 00719 inline cls(BOOL initialDeleteObjects = FALSE) \ 00720 : PAbstractSet() { AllowDeleteObjects(initialDeleteObjects); } \ 00721 virtual PObject * Clone() const \ 00722 { return PNEW cls(0, this); } \ 00723 inline void Include(const PObject * key) \ 00724 { Append((PObject *)key); } \ 00725 inline void Exclude(const PObject * key) \ 00726 { Remove(key); } \ 00727 inline BOOL operator[](const K & key) const \ 00728 { return AbstractContains(key); } \ 00729 inline BOOL Contains(const K & key) const \ 00730 { return AbstractContains(key); } \ 00731 virtual const K & GetKeyAt(PINDEX index) const \ 00732 { return (const K &)AbstractGetKeyAt(index); } \ 00733 } 00734 00735 #define PDECLARE_SET(cls, K, initDelObj) \ 00736 PSET(cls##_PTemplate, K); \ 00737 PDECLARE_CLASS(cls, cls##_PTemplate) \ 00738 protected: \ 00739 inline cls(int dummy, const cls * c) \ 00740 : cls##_PTemplate(dummy, c) { } \ 00741 public: \ 00742 inline cls(BOOL initialDeleteObjects = initDelObj) \ 00743 : cls##_PTemplate() { AllowDeleteObjects(initialDeleteObjects); } \ 00744 virtual PObject * Clone() const \ 00745 { return PNEW cls(0, this); } \ 00746 00747 00748 #endif // PHAS_TEMPLATES 00749 00750 00751 PSET(POrdinalSet, POrdinalKey); 00752 00753 00755 00758 class PAbstractDictionary : public PHashTable 00759 { 00760 PCLASSINFO(PAbstractDictionary, PHashTable); 00761 public: 00769 PINLINE PAbstractDictionary(); 00771 00780 virtual void PrintOn( 00781 ostream &strm 00782 ) const; 00784 00795 virtual PINDEX Insert( 00796 const PObject & key, 00797 PObject * obj 00798 ); 00799 00806 virtual PINDEX InsertAt( 00807 PINDEX index, 00808 PObject * obj 00809 ); 00810 00820 virtual PObject * RemoveAt( 00821 PINDEX index 00822 ); 00823 00832 virtual BOOL SetAt( 00833 PINDEX index, 00834 PObject * val 00835 ); 00836 00844 virtual PObject * GetAt( 00845 PINDEX index 00846 ) const; 00847 00859 virtual PINDEX GetObjectsIndex( 00860 const PObject * obj 00861 ) const; 00862 00871 virtual PINDEX GetValuesIndex( 00872 const PObject & obj 00873 ) const; 00875 00876 00887 virtual BOOL SetDataAt( 00888 PINDEX index, 00889 PObject * obj 00890 ); 00891 00903 virtual BOOL AbstractSetAt( 00904 const PObject & key, 00905 PObject * obj 00906 ); 00907 00917 virtual PObject & GetRefAt( 00918 const PObject & key 00919 ) const; 00920 00927 virtual PObject * AbstractGetAt( 00928 const PObject & key 00929 ) const; 00931 00932 protected: 00933 PINLINE PAbstractDictionary(int dummy, const PAbstractDictionary * c); 00934 00935 private: 00936 virtual PINDEX Append( 00937 PObject * obj // New object to place into the collection. 00938 ); 00939 /* This function is meaningless and will assert. 00940 00941 @return 00942 Always zero. 00943 */ 00944 00945 virtual BOOL Remove( 00946 const PObject * obj // Existing object to remove from the collection. 00947 ); 00948 /* Remove the object from the collection. If the AllowDeleteObjects option 00949 is set then the object is also deleted. 00950 00951 Note that the comparison for searching for the object in collection is 00952 made by pointer, not by value. Thus the parameter must point to the 00953 same instance of the object that is in the collection. 00954 00955 @return 00956 TRUE if the object was in the collection. 00957 */ 00958 00959 }; 00960 00961 00962 #ifdef PHAS_TEMPLATES 00963 00971 template <class K, class D> class PDictionary : public PAbstractDictionary 00972 { 00973 PCLASSINFO(PDictionary, PAbstractDictionary); 00974 00975 public: 00984 PDictionary() 00985 : PAbstractDictionary() { } 00987 00994 virtual PObject * Clone() const 00995 { return PNEW PDictionary(0, this); } 00997 01010 D & operator[]( 01011 const K & key 01012 ) const 01013 { return (D &)GetRefAt(key); } 01014 01023 BOOL Contains( 01024 const K & key 01025 ) const { return AbstractContains(key); } 01026 01035 virtual D * RemoveAt( 01036 const K & key 01037 ) { D * obj = GetAt(key); AbstractSetAt(key, NULL); return obj; } 01038 01050 virtual BOOL SetAt( 01051 const K & key, // Key for position in dictionary to add object. 01052 D * obj // New object to put into the dictionary. 01053 ) { return AbstractSetAt(key, obj); } 01054 01061 virtual D * GetAt( 01062 const K & key // Key for position in dictionary to get object. 01063 ) const { return (D *)AbstractGetAt(key); } 01064 01076 const K & GetKeyAt( 01077 PINDEX index 01078 ) const 01079 { return (const K &)AbstractGetKeyAt(index); } 01080 01092 D & GetDataAt( 01093 PINDEX index 01094 ) const 01095 { return (D &)AbstractGetDataAt(index); } 01097 01098 protected: 01099 PDictionary(int dummy, const PDictionary * c) 01100 : PAbstractDictionary(dummy, c) { } 01101 }; 01102 01103 01116 #define PDICTIONARY(cls, K, D) typedef PDictionary<K, D> cls 01117 01118 01131 #define PDECLARE_DICTIONARY(cls, K, D) \ 01132 PDICTIONARY(cls##_PTemplate, K, D); \ 01133 PDECLARE_CLASS(cls, cls##_PTemplate) \ 01134 protected: \ 01135 cls(int dummy, const cls * c) \ 01136 : cls##_PTemplate(dummy, c) { } \ 01137 public: \ 01138 cls() \ 01139 : cls##_PTemplate() { } \ 01140 virtual PObject * Clone() const \ 01141 { return PNEW cls(0, this); } \ 01142 01143 01151 template <class K> class POrdinalDictionary : public PAbstractDictionary 01152 { 01153 PCLASSINFO(POrdinalDictionary, PAbstractDictionary); 01154 01155 public: 01164 POrdinalDictionary() 01165 : PAbstractDictionary() { } 01167 01174 virtual PObject * Clone() const 01175 { return PNEW POrdinalDictionary(0, this); } 01177 01190 PINDEX operator[]( 01191 const K & key // Key to look for in the dictionary. 01192 ) const 01193 { return (POrdinalKey &)GetRefAt(key); } 01194 01203 BOOL Contains( 01204 const K & key 01205 ) const { return AbstractContains(key); } 01206 01207 virtual POrdinalKey * GetAt( 01208 const K & key 01209 ) const { return (POrdinalKey *)AbstractGetAt(key); } 01210 /* Get the object at the specified key position. If the key was not in the 01211 collection then NULL is returned. 01212 01213 @return 01214 pointer to object at the specified key. 01215 */ 01216 01225 virtual BOOL SetDataAt( 01226 PINDEX index, 01227 PINDEX ordinal 01228 ) { return PAbstractDictionary::SetDataAt(index, PNEW POrdinalKey(ordinal)); } 01229 01241 virtual BOOL SetAt( 01242 const K & key, 01243 PINDEX ordinal 01244 ) { return AbstractSetAt(key, PNEW POrdinalKey(ordinal)); } 01245 01254 virtual PINDEX RemoveAt( 01255 const K & key 01256 ) { PINDEX ord = *GetAt(key); AbstractSetAt(key, NULL); return ord; } 01257 01269 const K & GetKeyAt( 01270 PINDEX index 01271 ) const 01272 { return (const K &)AbstractGetKeyAt(index); } 01273 01285 PINDEX GetDataAt( 01286 PINDEX index 01287 ) const 01288 { return (POrdinalKey &)AbstractGetDataAt(index); } 01290 01291 protected: 01292 POrdinalDictionary(int dummy, const POrdinalDictionary * c) 01293 : PAbstractDictionary(dummy, c) { } 01294 }; 01295 01296 01309 #define PORDINAL_DICTIONARY(cls, K) typedef POrdinalDictionary<K> cls 01310 01311 01326 #define PDECLARE_ORDINAL_DICTIONARY(cls, K) \ 01327 PORDINAL_DICTIONARY(cls##_PTemplate, K); \ 01328 PDECLARE_CLASS(cls, POrdinalDictionary<K>) \ 01329 protected: \ 01330 cls(int dummy, const cls * c) \ 01331 : cls##_PTemplate(dummy, c) { } \ 01332 public: \ 01333 cls() \ 01334 : cls##_PTemplate() { } \ 01335 virtual PObject * Clone() const \ 01336 { return PNEW cls(0, this); } \ 01337 01338 01339 #else // PHAS_TEMPLATES 01340 01341 01342 #define PDICTIONARY(cls, K, D) \ 01343 class cls : public PAbstractDictionary { \ 01344 PCLASSINFO(cls, PAbstractDictionary); \ 01345 protected: \ 01346 inline cls(int dummy, const cls * c) \ 01347 : PAbstractDictionary(dummy, c) { } \ 01348 public: \ 01349 cls() \ 01350 : PAbstractDictionary() { } \ 01351 virtual PObject * Clone() const \ 01352 { return PNEW cls(0, this); } \ 01353 D & operator[](const K & key) const \ 01354 { return (D &)GetRefAt(key); } \ 01355 virtual BOOL Contains(const K & key) const \ 01356 { return AbstractContains(key); } \ 01357 virtual D * RemoveAt(const K & key) \ 01358 { D * obj = GetAt(key); AbstractSetAt(key, NULL); return obj; } \ 01359 virtual BOOL SetAt(const K & key, D * obj) \ 01360 { return AbstractSetAt(key, obj); } \ 01361 virtual D * GetAt(const K & key) const \ 01362 { return (D *)AbstractGetAt(key); } \ 01363 const K & GetKeyAt(PINDEX index) const \ 01364 { return (const K &)AbstractGetKeyAt(index); } \ 01365 D & GetDataAt(PINDEX index) const \ 01366 { return (D &)AbstractGetDataAt(index); } \ 01367 } 01368 01369 #define PDECLARE_DICTIONARY(cls, K, D) \ 01370 PDICTIONARY(cls##_PTemplate, K, D); \ 01371 PDECLARE_CLASS(cls, cls##_PTemplate) \ 01372 protected: \ 01373 cls(int dummy, const cls * c) \ 01374 : cls##_PTemplate(dummy, c) { } \ 01375 public: \ 01376 cls() \ 01377 : cls##_PTemplate() { } \ 01378 virtual PObject * Clone() const \ 01379 { return PNEW cls(0, this); } \ 01380 01381 01382 #define PORDINAL_DICTIONARY(cls, K) \ 01383 class cls : public PAbstractDictionary { \ 01384 PCLASSINFO(cls, PAbstractDictionary); \ 01385 protected: \ 01386 inline cls(int dummy, const cls * c) \ 01387 : PAbstractDictionary(dummy, c) { } \ 01388 public: \ 01389 inline cls() \ 01390 : PAbstractDictionary() { } \ 01391 virtual PObject * Clone() const \ 01392 { return PNEW cls(0, this); } \ 01393 inline PINDEX operator[](const K & key) const \ 01394 { return (POrdinalKey &)GetRefAt(key); } \ 01395 virtual BOOL Contains(const K & key) const \ 01396 { return AbstractContains(key); } \ 01397 virtual POrdinalKey * GetAt(const K & key) const \ 01398 { return (POrdinalKey *)AbstractGetAt(key); } \ 01399 virtual BOOL SetDataAt(PINDEX index, PINDEX ordinal) \ 01400 { return PAbstractDictionary::SetDataAt(index, PNEW POrdinalKey(ordinal)); } \ 01401 virtual BOOL SetAt(const K & key, PINDEX ordinal) \ 01402 { return AbstractSetAt(key, PNEW POrdinalKey(ordinal)); } \ 01403 virtual PINDEX RemoveAt(const K & key) \ 01404 { PINDEX ord = *GetAt(key); AbstractSetAt(key, NULL); return ord; } \ 01405 inline const K & GetKeyAt(PINDEX index) const \ 01406 { return (const K &)AbstractGetKeyAt(index); } \ 01407 inline PINDEX GetDataAt(PINDEX index) const \ 01408 { return (POrdinalKey &)AbstractGetDataAt(index); } \ 01409 } 01410 01411 #define PDECLARE_ORDINAL_DICTIONARY(cls, K) \ 01412 PORDINAL_DICTIONARY(cls##_PTemplate, K); \ 01413 PDECLARE_CLASS(cls, cls##_PTemplate) \ 01414 protected: \ 01415 cls(int dummy, const cls * c) \ 01416 : cls##_PTemplate(dummy, c) { } \ 01417 public: \ 01418 cls() \ 01419 : cls##_PTemplate() { } \ 01420 virtual PObject * Clone() const \ 01421 { return PNEW cls(0, this); } \ 01422 01423 01424 #endif // PHAS_TEMPLATES 01425 01426 // End Of File ///////////////////////////////////////////////////////////////

Generated on Sat Jul 24 15:35:56 2004 for PWLib by doxygen 1.3.7