1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 inline Foam::label Foam::PtrList<T>::size() const
42 inline bool Foam::PtrList<T>::empty() const
49 inline void Foam::PtrList<T>::resize(const label newSize)
51 this->setSize(newSize);
56 inline bool Foam::PtrList<T>::set(const label i) const
58 return ptrs_[i] != NULL;
63 inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, T* ptr)
65 autoPtr<T> old(ptrs_[i]);
74 inline Foam::autoPtr<T> Foam::PtrList<T>::set
77 const autoPtr<T>& aptr
80 return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
85 inline Foam::autoPtr<T> Foam::PtrList<T>::set
91 return set(i, const_cast<tmp<T>&>(t).ptr());
96 inline Foam::Xfer<Foam::PtrList<T> > Foam::PtrList<T>::xfer()
98 return xferMove(*this);
102 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
105 const T& Foam::PtrList<T>::operator[](const label i) const
109 FatalErrorIn("PtrList::operator[] const")
110 << "hanging pointer, cannot dereference"
111 << abort(FatalError);
119 T& Foam::PtrList<T>::operator[](const label i)
123 FatalErrorIn("PtrList::operator[]")
124 << "hanging pointer, cannot dereference"
125 << abort(FatalError);
133 const T* Foam::PtrList<T>::operator()(const label i) const
139 // * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
142 inline Foam::PtrList<T>::iterator::iterator(T** ptr)
148 inline bool Foam::PtrList<T>::iterator::operator==(const iterator& iter) const
150 return ptr_ == iter.ptr_;
154 inline bool Foam::PtrList<T>::iterator::operator!=(const iterator& iter) const
156 return ptr_ != iter.ptr_;
160 inline T& Foam::PtrList<T>::iterator::operator*()
166 inline T& Foam::PtrList<T>::iterator::operator()()
172 inline typename Foam::PtrList<T>::iterator
173 Foam::PtrList<T>::iterator::operator++()
180 inline typename Foam::PtrList<T>::iterator
181 Foam::PtrList<T>::iterator::operator++(int)
183 iterator tmp = *this;
189 inline typename Foam::PtrList<T>::iterator
190 Foam::PtrList<T>::iterator::operator--()
197 inline typename Foam::PtrList<T>::iterator
198 Foam::PtrList<T>::iterator::operator--(int)
200 iterator tmp = *this;
206 inline typename Foam::PtrList<T>::iterator
207 Foam::PtrList<T>::iterator::operator+=(label n)
214 inline typename Foam::PtrList<T>::iterator
215 Foam::operator+(const typename PtrList<T>::iterator& iter, label n)
217 typename PtrList<T>::iterator tmp = iter;
222 inline typename Foam::PtrList<T>::iterator
223 Foam::operator+(label n, const typename PtrList<T>::iterator& iter)
225 typename PtrList<T>::iterator tmp = iter;
230 inline typename Foam::PtrList<T>::iterator
231 Foam::PtrList<T>::iterator::operator-=(label n)
238 inline typename Foam::PtrList<T>::iterator
239 Foam::operator-(const typename PtrList<T>::iterator& iter, label n)
241 typename PtrList<T>::iterator tmp = iter;
246 inline Foam::label Foam::operator-
248 const typename PtrList<T>::iterator& iter1,
249 const typename PtrList<T>::iterator& iter2
252 return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
256 inline T& Foam::PtrList<T>::iterator::operator[](label n)
262 inline bool Foam::PtrList<T>::iterator::operator<(const iterator& iter) const
264 return ptr_ < iter.ptr_;
268 inline bool Foam::PtrList<T>::iterator::operator>(const iterator& iter) const
270 return ptr_ > iter.ptr_;
274 inline bool Foam::PtrList<T>::iterator::operator<=(const iterator& iter) const
276 return ptr_ <= iter.ptr_;
280 inline bool Foam::PtrList<T>::iterator::operator>=(const iterator& iter) const
282 return ptr_ >= iter.ptr_;
286 inline typename Foam::PtrList<T>::iterator
287 Foam::PtrList<T>::begin()
289 return ptrs_.begin();
293 inline typename Foam::PtrList<T>::iterator
294 Foam::PtrList<T>::end()
301 // ************************************************************************* //