1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 inline label PtrList<T>::size() const
47 inline bool PtrList<T>::set(const label i) const
49 return ptrs_[i] != NULL;
54 inline autoPtr<T> PtrList<T>::set(const label i, T* ptr)
56 autoPtr<T> old(ptrs_[i]);
65 inline autoPtr<T> PtrList<T>::set(const label i, const autoPtr<T>& aptr)
67 return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
72 inline autoPtr<T> PtrList<T>::set(const label i, const tmp<T>& t)
74 return set(i, const_cast<tmp<T>&>(t).ptr());
78 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
81 const T& PtrList<T>::operator[](const label i) const
85 FatalErrorIn("PtrList::operator[] const")
86 << "hanging pointer, cannot dereference"
95 T& PtrList<T>::operator[](const label i)
99 FatalErrorIn("PtrList::operator[]")
100 << "hanging pointer, cannot dereference"
101 << abort(FatalError);
109 const T* PtrList<T>::operator()(const label i) const
115 // * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
118 inline PtrList<T>::iterator::iterator(T** ptr)
124 inline bool PtrList<T>::iterator::operator==(const iterator& iter) const
126 return ptr_ == iter.ptr_;
130 inline bool PtrList<T>::iterator::operator!=(const iterator& iter) const
132 return ptr_ != iter.ptr_;
136 inline T& PtrList<T>::iterator::operator*()
142 inline T& PtrList<T>::iterator::operator()()
148 inline typename PtrList<T>::iterator
149 PtrList<T>::iterator::operator++()
156 inline typename PtrList<T>::iterator
157 PtrList<T>::iterator::operator++(int)
159 iterator tmp = *this;
165 inline typename PtrList<T>::iterator
166 PtrList<T>::iterator::operator--()
173 inline typename PtrList<T>::iterator
174 PtrList<T>::iterator::operator--(int)
176 iterator tmp = *this;
182 inline typename PtrList<T>::iterator
183 PtrList<T>::iterator::operator+=(label n)
190 inline typename PtrList<T>::iterator
191 operator+(const typename PtrList<T>::iterator& iter, label n)
193 typename PtrList<T>::iterator tmp = iter;
198 inline typename PtrList<T>::iterator
199 operator+(label n, const typename PtrList<T>::iterator& iter)
201 typename PtrList<T>::iterator tmp = iter;
206 inline typename PtrList<T>::iterator
207 PtrList<T>::iterator::operator-=(label n)
214 inline typename PtrList<T>::iterator
215 operator-(const typename PtrList<T>::iterator& iter, label n)
217 typename PtrList<T>::iterator tmp = iter;
222 inline label operator-
224 const typename PtrList<T>::iterator& iter1,
225 const typename PtrList<T>::iterator& iter2
228 return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
232 inline T& PtrList<T>::iterator::operator[](label n)
238 inline bool PtrList<T>::iterator::operator<(const iterator& iter) const
240 return ptr_ < iter.ptr_;
244 inline bool PtrList<T>::iterator::operator>(const iterator& iter) const
246 return ptr_ > iter.ptr_;
250 inline bool PtrList<T>::iterator::operator<=(const iterator& iter) const
252 return ptr_ <= iter.ptr_;
256 inline bool PtrList<T>::iterator::operator>=(const iterator& iter) const
258 return ptr_ >= iter.ptr_;
262 inline typename PtrList<T>::iterator PtrList<T>::begin()
264 return ptrs_.begin();
268 inline typename PtrList<T>::iterator PtrList<T>::end()
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 } // End namespace Foam
278 // ************************************************************************* //