PtrList.H
Go to the documentation of this file.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 protected:
00107
00108
00109
00110
00111 template<class INew>
00112 void read(Istream&, const INew& inewt);
00113
00114
00115 public:
00116
00117
00118
00119
00120 PtrList();
00121
00122
00123 explicit PtrList(const label);
00124
00125
00126 PtrList(const PtrList<T>&);
00127
00128
00129 template<class CloneArg>
00130 PtrList(const PtrList<T>&, const CloneArg&);
00131
00132
00133 PtrList(const Xfer<PtrList<T> >&);
00134
00135
00136 PtrList(PtrList<T>&, bool reUse);
00137
00138
00139 PtrList(const SLPtrList<T>&);
00140
00141
00142 template<class INew>
00143 PtrList(Istream&, const INew&);
00144
00145
00146 PtrList(Istream&);
00147
00148
00149
00150
00151 ~PtrList();
00152
00153
00154
00155
00156
00157
00158
00159 inline label size() const;
00160
00161
00162 inline bool empty() const;
00163
00164
00165
00166
00167
00168
00169
00170
00171 void setSize(const label);
00172
00173
00174
00175
00176
00177 inline void resize(const label);
00178
00179
00180
00181 void clear();
00182
00183
00184
00185 void transfer(PtrList<T>&);
00186
00187
00188 inline Xfer<PtrList<T> > xfer();
00189
00190
00191 inline bool set(const label) const;
00192
00193
00194
00195 inline autoPtr<T> set(const label, T*);
00196 inline autoPtr<T> set(const label, const autoPtr<T>&);
00197 inline autoPtr<T> set(const label, const tmp<T>&);
00198
00199
00200
00201
00202 void reorder(const UList<label>&);
00203
00204
00205
00206
00207
00208 inline const T& operator[](const label) const;
00209
00210
00211 inline T& operator[](const label);
00212
00213
00214 inline const T* operator()(const label) const;
00215
00216
00217
00218 PtrList<T>& operator=(const PtrList<T>&);
00219
00220
00221
00222
00223
00224 typedef T value_type;
00225
00226
00227 typedef T& reference;
00228
00229
00230
00231 typedef const T& const_reference;
00232
00233
00234
00235
00236
00237 class iterator;
00238 friend class iterator;
00239
00240
00241 class iterator
00242 {
00243 T** ptr_;
00244
00245 public:
00246
00247
00248 inline iterator(T**);
00249
00250
00251
00252 inline bool operator==(const iterator&) const;
00253 inline bool operator!=(const iterator&) const;
00254
00255 typedef T& Tref;
00256 inline Tref operator*();
00257 inline Tref operator()();
00258
00259 inline iterator operator++();
00260 inline iterator operator++(int);
00261
00262 inline iterator operator--();
00263 inline iterator operator--(int);
00264
00265 inline iterator operator+=(label);
00266
00267 friend iterator operator+ <T>(const iterator&, label);
00268 friend iterator operator+ <T>(label, const iterator&);
00269
00270 inline iterator operator-=(label);
00271
00272 friend iterator operator- <T>(const iterator&, label);
00273
00274 friend label operator- <T>
00275 (
00276 const iterator&,
00277 const iterator&
00278 );
00279
00280 inline T& operator[](label);
00281
00282 inline bool operator<(const iterator&) const;
00283 inline bool operator>(const iterator&) const;
00284
00285 inline bool operator<=(const iterator&) const;
00286 inline bool operator>=(const iterator&) const;
00287 };
00288
00289
00290 inline iterator begin();
00291
00292
00293 inline iterator end();
00294
00295
00296
00297
00298
00299 friend Istream& operator>> <T>(Istream&, PtrList<T>&);
00300
00301
00302 friend Ostream& operator<< <T>(Ostream&, const PtrList<T>&);
00303 };
00304
00305
00306
00307
00308 }
00309
00310
00311
00312 # include "PtrListI.H"
00313
00314
00315
00316 #ifdef NoRepository
00317 # include "PtrList.C"
00318 #endif
00319
00320
00321
00322 #endif
00323
00324
Copyright © 2000-2009 OpenCFD Ltd