00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #ifdef P_USE_PRAGMA
00137 #pragma interface
00138 #endif
00139
00140
00142
00143
00164 class PAbstractList : public PCollection
00165 {
00166 PCONTAINERINFO(PAbstractList, PCollection);
00167
00168 public:
00176 PINLINE PAbstractList();
00178
00179
00207 virtual Comparison Compare(const PObject & obj) const;
00208
00218 virtual BOOL SetSize(
00219 PINDEX newSize
00220 );
00222
00231 virtual PINDEX Append(
00232 PObject * obj
00233 );
00234
00247 virtual PINDEX Insert(
00248 const PObject & before,
00249 PObject * obj
00250 );
00251
00259 virtual PINDEX InsertAt(
00260 PINDEX index,
00261 PObject * obj
00262 );
00263
00270 virtual BOOL Remove(
00271 const PObject * obj
00272 );
00273
00283 virtual PObject * RemoveAt(
00284 PINDEX index
00285 );
00286
00298 virtual BOOL SetAt(
00299 PINDEX index,
00300 PObject * val
00301 );
00302
00313 virtual BOOL ReplaceAt(
00314 PINDEX index,
00315 PObject * val
00316 );
00317
00328 virtual PObject * GetAt(
00329 PINDEX index
00330 ) const;
00331
00339 virtual PINDEX GetObjectsIndex(
00340 const PObject * obj
00341 ) const;
00342
00351 virtual PINDEX GetValuesIndex(
00352 const PObject & obj
00353 ) const;
00355
00356
00357 protected:
00368 PINLINE PObject & GetReferenceAt(
00369 PINDEX index
00370 ) const;
00371
00381 BOOL SetCurrent(
00382 PINDEX index
00383 ) const;
00384
00385 class Element {
00386 public:
00387 friend class Info;
00388 Element(PObject * theData);
00389 Element * prev;
00390 Element * next;
00391 PObject * data;
00392 };
00393
00394 class Info {
00395 public:
00396 Info() { head = tail = lastElement = NULL; }
00397 Element * head;
00398 Element * tail;
00399 Element * lastElement;
00400 PINDEX lastIndex;
00401 } * info;
00402 };
00403
00404
00405 #ifdef PHAS_TEMPLATES
00406
00413 template <class T> class PList : public PAbstractList
00414 {
00415 PCLASSINFO(PList, PAbstractList);
00416
00417 public:
00425 PList()
00426 : PAbstractList() { }
00428
00434 virtual PObject * Clone() const
00435 { return PNEW PList(0, this); }
00437
00451 T & operator[](PINDEX index) const
00452 { return (T &)GetReferenceAt(index); }
00454
00455 protected:
00456 PList(int dummy, const PList * c)
00457 : PAbstractList(dummy, c) { }
00458 };
00459
00460
00472 #define PLIST(cls, T) typedef PList<T> cls
00473
00485 #define PDECLARE_LIST(cls, T) \
00486 PLIST(cls##_PTemplate, T); \
00487 PDECLARE_CLASS(cls, PList<T>) \
00488 protected: \
00489 cls(int dummy, const cls * c) \
00490 : PList<T>(dummy, c) { } \
00491 public: \
00492 cls() \
00493 : PList<T>() { } \
00494 virtual PObject * Clone() const \
00495 { return PNEW cls(0, this); } \
00496
00497
00510 template <class T> class PQueue : public PAbstractList
00511 {
00512 PCLASSINFO(PQueue, PAbstractList);
00513
00514 public:
00523 PQueue()
00524 : PAbstractList() { DisallowDeleteObjects(); }
00526
00532 virtual PObject * Clone() const
00533 { return PNEW PQueue(0, this); }
00535
00541 virtual void Enqueue(
00542 T * obj
00543 ) { PAbstractList::Append(obj); }
00549 virtual T * Dequeue()
00550 { if (GetSize() == 0) return NULL; else return (T *)PAbstractList::RemoveAt(0);}
00552
00553 protected:
00554 PQueue(int dummy, const PQueue * c)
00555 : PAbstractList(dummy, c)
00556 { reference->deleteObjects = c->reference->deleteObjects; }
00557 };
00558
00559
00572 #define PQUEUE(cls, T) typedef PQueue<T> cls
005n 1.20 2002/09/16 01:08:59 robertj
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #ifdef P_USE_PRAGMA
00137 #pragma interface
00138 #endif
00139
00140
00142
00143
00164 class PAbstractList : public PCollection
00165 {
00166 PCONTAINERINFO(PAbstractList, PCollection);
00167
00168 public:
00176 PINLINE PAbstractList();
00178
00179
00207 virtual Comparison Compare(const PObject & obj) const;
00208
00218 virtual BOOL SetSize(
00219 PINDEX newSize
00220 );
00222
00231 virtual PINDEX Append(
00232 PObject * obj
00233 );
00234
00247 virtual PINDEX Insert(
00248 const PObject & before,
00249 PObject * obj
00250 );
00251
00259 virtual PINDEX InsertAt(
00260 PINDEX index,
00261 PObject * obj
00262 );
00263
00270 virtual BOOL Remove(
00271 const PObject * obj
00272 );
00273
00283 virtual PObject * RemoveAt(
00284 PINDEX index
00285 );
00286
00298 virtual BOOL SetAt(
00299 PINDEX index,
00300 PObject * val
00301 );
00302
00313 virtual BOOL ReplaceAt(
00314 PINDEX index,
00315 PObject * val
00316 );
00317
00328 virtual PObject * GetAt(
00329 PINDEX index
00330 ) const;
00331
00339 virtual PINDEX GetObjectsIndex(
00340 const PObject * obj
00341 ) const;
00342
00351 virtual PINDEX GetValuesIndex(
00352 const PObject & obj
00353 ) const;
00355
00356
00357 protected:
00368 PINLINE PObject & GetReferenceAt(
00369 PINDEX index
00370 ) const;
00371
00381 BOOL SetCurrent(
00382 PINDEX index
00383 ) const;
00384
00385 class Element {
00386 public:
00387 friend class Info;
00388 Element(PObject * theData);
00389 Element * prev;
00390 Element * next;
00391 PObject * data;
00392 };
00393
00394 class Info {
00395 public:
00396 Info() { head = tail = lastElement = NULL; }
00397 Element * head;
00398 Element * tail;
00399 Element * lastElement;
00400 PINDEX lastIndex;
00401 } * info;
00402 };
00403
00404
00405 #ifdef PHAS_TEMPLATES
00406
00413 template <class T> class PList : public PAbstractList
00414 {
00415 PCLASSINFO(PList, PAbstractList);
00416
00417 public:
00425 PList()
00426 : PAbstractList() { }
00428
00434 virtual PObject * Clone() const
00435 { return PNEW PList(0, this); }
00437
00451 T & operator[](PINDEX index) const
00452 { return (T &)GetReferenceAt(index); }
00454
00455 protected:
00456 PList(int dummy, const PList * c)
00457 : PAbstractList(dummy, c) { }
00458 };
00459
00460
00472 #define PLIST(cls, T) typedef PList<T> cls
00473
00485 #define PDECLARE_LIST(cls, T) \
00486 PLIST(cls##_PTemplate, T); \
00487 PDECLARE_CLASS(cls, PList<T>) \
00488 protected: \
00489 cls(int dummy, const cls * c) \
00490 : PList<T>(dummy, c) { } \
00491 public: \
00492 cls() \
00493 : PList<T>() { } \
00494 virtual PObject * Clone() const \
00495 { return PNEW cls(0, this); } \
00496
00497
00510 template <class T> class PQueue : public PAbstractList
00511 {
00512 PCLASSINFO(PQueue, PAbstractList);
00513
00514 public:
00523 PQueue()
00524 : PAbstractList() { DisallowDeleteObjects(); }
00526
00532 virtual PObject * Clone() const
00533 { return PNEW PQueue(0, this); }
00535
00541 virtual void Enqueue(
00542 T * obj
00543 ) { PAbstractList::Append(obj); }
00549 virtual T * Dequeue()
00550 { if (GetSize() == 0) return NULL; else return (T *)PAbstractList::RemoveAt(0);}
00552
00553 protected:
00554 PQueue(int dummy, const PQueue * c)
00555 : PAbstractList(dummy, c)
00556 { reference->deleteObjects = c->reference->deleteObjects; }
00557 };
00558
00559
00572 #define PQUEUE(cls, T) typedef PQueue<T> cls
005n 1.20 2002/09/16 01:08:59 robertj
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #ifdef P_USE_PRAGMA
00137 #pragma interface
00138 #endif
00139
00140
00142
00143
00164 class PAbstractList : public PCollection
00165 {
00166 PCONTAINERINFO(PAbstractList, PCollection);
00167
00168 public:
00176 PINLINE PAbstractList();
00178
00179
00207 virtual Comparison Compare(const PObject & obj) const;
00208
00218 virtual BOOL SetSize(
00219 PINDEX newSize
00220 );
00222
00231 virtual PINDEX Append(
00232 PObject * obj
00233 );
00234
00247 virtual PINDEX Insert(
00248 const PObject & before,
00249 PObject * obj
00250 );
00251
00259 virtual PINDEX InsertAt(
00260 PINDEX index,
00261 PObject * obj
00262 );
00263
00270 virtual BOOL Remove(
00271 const PObject * obj
00272 );
00273
00283 virtual PObject * RemoveAt(
00284 PINDEX index
00285 );
00286
00298 virtual BOOL SetAt(
00299 PINDEX index,
00300 PObject * val
00301 );
00302
00313 virtual BOOL ReplaceAt(
00314 PINDEX index,
00315 PObject * val
00316 );
00317
00328 virtual PObject * GetAt(
00329 PINDEX index
00330 ) const;
00331
00339 virtual PINDEX GetObjectsIndex(
00340 const PObject * obj
00341 ) const;
00342
00351 virtual PINDEX GetValuesIndex(
00352 const PObject & obj
00353 ) const;
00355
00356
00357 protected:
00368 PINLINE PObject & GetReferenceAt(
00369 PINDEX index
00370 ) const;
00371
00381 BOOL SetCurrent(
00382 PINDEX index
00383 ) const;
00384
00385 class Element {
00386 public:
00387 friend class Info;
00388 Element(PObject * theData);
00389 Element * prev;
00390 Element * next;
00391 PObject * data;
00392 };
00393
00394 class Info {
00395 public: