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 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 inline Foam::label Foam::UPtrList<T>::size() const
39 inline bool Foam::UPtrList<T>::empty() const
46 inline void Foam::UPtrList<T>::resize(const label newSize)
48 this->setSize(newSize);
53 inline bool Foam::UPtrList<T>::set(const label i) const
55 return ptrs_[i] != NULL;
59 inline T* Foam::UPtrList<T>::set(const label i, T* ptr)
67 inline Foam::Xfer<Foam::UPtrList<T> > Foam::UPtrList<T>::xfer()
69 return xferMove(*this);
73 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
76 const T& Foam::UPtrList<T>::operator[](const label i) const
80 FatalErrorIn("UPtrList::operator[] const")
81 << "hanging pointer, cannot dereference"
90 T& Foam::UPtrList<T>::operator[](const label i)
94 FatalErrorIn("UPtrList::operator[]")
95 << "hanging pointer, cannot dereference"
104 const T* Foam::UPtrList<T>::operator()(const label i) const
110 // * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
113 inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
119 inline bool Foam::UPtrList<T>::iterator::operator==(const iterator& iter) const
121 return ptr_ == iter.ptr_;
125 inline bool Foam::UPtrList<T>::iterator::operator!=(const iterator& iter) const
127 return ptr_ != iter.ptr_;
131 inline T& Foam::UPtrList<T>::iterator::operator*()
137 inline T& Foam::UPtrList<T>::iterator::operator()()
143 inline typename Foam::UPtrList<T>::iterator
144 Foam::UPtrList<T>::iterator::operator++()
151 inline typename Foam::UPtrList<T>::iterator
152 Foam::UPtrList<T>::iterator::operator++(int)
154 iterator tmp = *this;
160 inline typename Foam::UPtrList<T>::iterator
161 Foam::UPtrList<T>::iterator::operator--()
168 inline typename Foam::UPtrList<T>::iterator
169 Foam::UPtrList<T>::iterator::operator--(int)
171 iterator tmp = *this;
177 inline typename Foam::UPtrList<T>::iterator
178 Foam::UPtrList<T>::iterator::operator+=(label n)
185 inline typename Foam::UPtrList<T>::iterator
186 Foam::operator+(const typename UPtrList<T>::iterator& iter, label n)
188 typename UPtrList<T>::iterator tmp = iter;
193 inline typename Foam::UPtrList<T>::iterator
194 Foam::operator+(label n, const typename UPtrList<T>::iterator& iter)
196 typename UPtrList<T>::iterator tmp = iter;
201 inline typename Foam::UPtrList<T>::iterator
202 Foam::UPtrList<T>::iterator::operator-=(label n)
209 inline typename Foam::UPtrList<T>::iterator
210 Foam::operator-(const typename UPtrList<T>::iterator& iter, label n)
212 typename UPtrList<T>::iterator tmp = iter;
217 inline Foam::label Foam::operator-
219 const typename UPtrList<T>::iterator& iter1,
220 const typename UPtrList<T>::iterator& iter2
223 return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
227 inline T& Foam::UPtrList<T>::iterator::operator[](label n)
233 inline bool Foam::UPtrList<T>::iterator::operator<(const iterator& iter) const
235 return ptr_ < iter.ptr_;
239 inline bool Foam::UPtrList<T>::iterator::operator>(const iterator& iter) const
241 return ptr_ > iter.ptr_;
245 inline bool Foam::UPtrList<T>::iterator::operator<=(const iterator& iter) const
247 return ptr_ <= iter.ptr_;
251 inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
253 return ptr_ >= iter.ptr_;
257 inline typename Foam::UPtrList<T>::iterator
258 Foam::UPtrList<T>::begin()
260 return ptrs_.begin();
264 inline typename Foam::UPtrList<T>::iterator
265 Foam::UPtrList<T>::end()
271 // ************************************************************************* //