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 #ifndef PtrList_H
00042 #define PtrList_H
00043
00044 #include "List.H"
00045
00046
00047
00048 namespace Foam
00049 {
00050
00051
00052
00053 template<class T> class PtrList;
00054 template<class T> class SLPtrList;
00055
00056 template<class T>
00057 inline typename PtrList<T>::iterator operator+
00058 (
00059 const typename PtrList<T>::iterator&,
00060 label
00061 );
00062
00063 template<class T>
00064 inline typename PtrList<T>::iterator operator+
00065 (
00066 label,
00067 const typename PtrList<T>::iterator&
00068 );
00069
00070 template<class T>
00071 inline typename PtrList<T>::iterator operator-
00072 (
00073 const typename PtrList<T>::iterator&,
00074 label
00075 );
00076
00077 template<class T>
00078 inline label operator-
00079 (
00080 const typename PtrList<T>::iterator&,
00081 const typename PtrList<T>::iterator&
00082 );
00083
00084 template<class T>
00085 Istream& operator>>(Istream&, PtrList<T>&);
00086
00087 template<class T>
00088 Ostream& operator<<(Ostream&, const PtrList<T>&);
00089
00090 template<class T> class autoPtr;
00091 template<class T> class tmp;
00092
00093
00094
00095
00096
00097
00098 template<class T>
00099 class PtrList
00100 {
00101
00102
00103 List<T*> ptrs_;
00104
00105
00106 label nextFree_;
00107
00108
00109
00110
00111
00112
00113 PtrList(const label, const T&);
00114
00115
00116
00117 template<class INew>
00118 void read(Istream&, const INew& inewt);
00119
00120
00121 protected:
00122
00123
00124 label nextFree() const
00125 {
00126 return nextFree_;
00127 }
00128
00129
00130 public:
00131
00132
00133
00134
00135 PtrList();
00136
00137
00138 explicit PtrList(const label);
00139
00140
00141 PtrList(const PtrList<T>&);
00142
00143
00144 template<class CloneArg>
00145 PtrList(const PtrList<T>&, const CloneArg&);
00146
00147
00148 PtrList(PtrList<T>&, bool reUse);
00149
00150
00151 PtrList(const SLPtrList<T>&);
00152
00153
00154 template<class INew>
00155 PtrList(Istream&, const INew&);
00156
00157
00158 PtrList(Istream&);
00159
00160
00161
00162
00163 ~PtrList();
00164
00165
00166
00167
00168
00169
00170
00171 inline label size() const;
00172
00173
00174
00175
00176
00177
00178
00179
00180 void setSize(const label);
00181
00182
00183
00184 void clear();
00185
00186
00187
00188 void transfer(PtrList<T>&);
00189
00190
00191
00192 typedef T* Tptr;
00193 Tptr& set(const label);
00194
00195
00196 void hook(T*);
00197
00198
00199 inline void hook(const autoPtr<T>&);
00200
00201
00202 inline void hook(const tmp<T>&);
00203
00204
00205
00206
00207 void reorder(const UList<label>&);
00208
00209
00210
00211
00212
00213 inline const T& operator[](const label) const;
00214
00215
00216 inline T& operator[](const label);
00217
00218
00219 inline const T* operator()(const label) const;
00220
00221
00222
00223 PtrList<T>& operator=(const PtrList<T>&);
00224
00225
00226
00227
00228
00229 typedef T value_type;
00230
00231
00232 typedef T& reference;
00233
00234
00235
00236 typedef const T& const_reference;
00237
00238
00239
00240
00241
00242 class iterator;
00243 friend class iterator;
00244
00245 class iterator
00246 {
00247 T** ptr_;
00248
00249 public:
00250
00251
00252 inline iterator(T**);
00253
00254
00255
00256 inline bool operator==(const iterator&) const;
00257 inline bool operator!=(const iterator&) const;
00258
00259 inline T& operator*();
00260 inline T& operator()();
00261
00262 inline iterator operator++();
00263 inline iterator operator++(int);
00264
00265 inline iterator operator--();
00266 inline iterator operator--(int);
00267
00268 inline iterator operator+=(label);
00269
00270 friend iterator operator+ <T>(const iterator&, label);
00271 friend iterator operator+ <T>(label, const iterator&);
00272
00273 inline iterator operator-=(label);
00274
00275 friend iterator operator- <T>(const iterator&, label);
00276
00277 friend label operator- <T>
00278 (
00279 const iterator&,
00280 const iterator&
00281 );
00282
00283 inline T& operator[](label);
00284
00285 inline bool operator<(const iterator&) const;
00286 inline bool operator>(const iterator&) const;
00287
00288 inline bool operator<=(const iterator&) const;
00289 inline bool operator>=(const iterator&) const;
00290 };
00291
00292
00293 inline iterator begin();
00294
00295
00296 inline iterator end();
00297
00298
00299
00300
00301
00302 friend Istream& operator>> <T>(Istream&, PtrList<T>&);
00303
00304
00305 friend Ostream& operator<< <T>(Ostream&, const PtrList<T>&);
00306 };
00307
00308
00309
00310
00311 }
00312
00313
00314
00315 # include "PtrListI.H"
00316
00317
00318
00319 #ifdef NoRepository
00320 # include "PtrList.C"
00321 #endif
00322
00323
00324
00325 #endif
00326
00327