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