1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 inline Foam::label Foam::PtrList<T>::size() const
41 inline bool Foam::PtrList<T>::empty() const
48 inline void Foam::PtrList<T>::resize(const label newSize)
50 this->setSize(newSize);
55 inline bool Foam::PtrList<T>::set(const label i) const
57 return ptrs_[i] != NULL;
62 inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, T* ptr)
64 autoPtr<T> old(ptrs_[i]);
73 inline Foam::autoPtr<T> Foam::PtrList<T>::set
76 const autoPtr<T>& aptr
79 return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
84 inline Foam::autoPtr<T> Foam::PtrList<T>::set
90 return set(i, const_cast<tmp<T>&>(t).ptr());
95 inline Foam::Xfer<Foam::PtrList<T> > Foam::PtrList<T>::xfer()
97 return xferMove(*this);
101 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
104 const T& Foam::PtrList<T>::operator[](const label i) const
108 FatalErrorIn("PtrList::operator[] const")
109 << "hanging pointer, cannot dereference"
110 << abort(FatalError);
118 T& Foam::PtrList<T>::operator[](const label i)
122 FatalErrorIn("PtrList::operator[]")
123 << "hanging pointer, cannot dereference"
124 << abort(FatalError);
132 const T* Foam::PtrList<T>::operator()(const label i) const
138 // * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
141 inline Foam::PtrList<T>::iterator::iterator(T** ptr)
147 inline bool Foam::PtrList<T>::iterator::operator==(const iterator& iter) const
149 return ptr_ == iter.ptr_;
153 inline bool Foam::PtrList<T>::iterator::operator!=(const iterator& iter) const
155 return ptr_ != iter.ptr_;
159 inline T& Foam::PtrList<T>::iterator::operator*()
165 inline T& Foam::PtrList<T>::iterator::operator()()
171 inline typename Foam::PtrList<T>::iterator
172 Foam::PtrList<T>::iterator::operator++()
179 inline typename Foam::PtrList<T>::iterator
180 Foam::PtrList<T>::iterator::operator++(int)
182 iterator tmp = *this;
188 inline typename Foam::PtrList<T>::iterator
189 Foam::PtrList<T>::iterator::operator--()
196 inline typename Foam::PtrList<T>::iterator
197 Foam::PtrList<T>::iterator::operator--(int)
199 iterator tmp = *this;
205 inline typename Foam::PtrList<T>::iterator
206 Foam::PtrList<T>::iterator::operator+=(label n)
213 inline typename Foam::PtrList<T>::iterator
214 Foam::operator+(const typename PtrList<T>::iterator& iter, label n)
216 typename PtrList<T>::iterator tmp = iter;
221 inline typename Foam::PtrList<T>::iterator
222 Foam::operator+(label n, const typename PtrList<T>::iterator& iter)
224 typename PtrList<T>::iterator tmp = iter;
229 inline typename Foam::PtrList<T>::iterator
230 Foam::PtrList<T>::iterator::operator-=(label n)
237 inline typename Foam::PtrList<T>::iterator
238 Foam::operator-(const typename PtrList<T>::iterator& iter, label n)
240 typename PtrList<T>::iterator tmp = iter;
245 inline Foam::label Foam::operator-
247 const typename PtrList<T>::iterator& iter1,
248 const typename PtrList<T>::iterator& iter2
251 return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
255 inline T& Foam::PtrList<T>::iterator::operator[](label n)
261 inline bool Foam::PtrList<T>::iterator::operator<(const iterator& iter) const
263 return ptr_ < iter.ptr_;
267 inline bool Foam::PtrList<T>::iterator::operator>(const iterator& iter) const
269 return ptr_ > iter.ptr_;
273 inline bool Foam::PtrList<T>::iterator::operator<=(const iterator& iter) const
275 return ptr_ <= iter.ptr_;
279 inline bool Foam::PtrList<T>::iterator::operator>=(const iterator& iter) const
281 return ptr_ >= iter.ptr_;
285 inline typename Foam::PtrList<T>::iterator
286 Foam::PtrList<T>::begin()
288 return ptrs_.begin();
292 inline typename Foam::PtrList<T>::iterator
293 Foam::PtrList<T>::end()
300 // ************************************************************************* //