mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: PtrList, UPtrList cleanup
- rationalize iterators, reduce code duplication, improve assignment behaviour, moveable construct and assignment.
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -21,10 +21,8 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
|
||||
Description
|
||||
|
||||
Test behaviour of UPtrList, PtrList
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSspecific.H"
|
||||
@ -102,13 +100,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAllIters(llist1, it)
|
||||
{
|
||||
Info<< typeid(*it).name() << endl;
|
||||
Info<< "reversed: " << *it << endl;
|
||||
Info<< typeid(*it).name() << nl
|
||||
<< "reversed: " << *it << endl;
|
||||
}
|
||||
for (const auto& it : llist1)
|
||||
{
|
||||
Info<< typeid(it).name() << endl;
|
||||
Info<< "for-: " << it << endl;
|
||||
Info<< typeid(it).name() << nl
|
||||
<< "for-: " << it << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,9 +125,10 @@ int main(int argc, char *argv[])
|
||||
listApp.append(new Scalar(1.3*i));
|
||||
}
|
||||
|
||||
Info<<"list1: " << list1 << endl;
|
||||
Info<<"list2: " << list2 << endl;
|
||||
Info<<"listApp: " << listApp << endl;
|
||||
Info<< nl
|
||||
<<"list1: " << list1 << nl
|
||||
<<"list2: " << list2 << nl
|
||||
<<"list-appended: " << listApp << endl;
|
||||
|
||||
Info<<"indirectly delete some items via set(.., 0) :" << endl;
|
||||
for (label i = 0; i < 3; i++)
|
||||
@ -140,8 +139,8 @@ int main(int argc, char *argv[])
|
||||
Info<<"transfer list2 -> list1:" << endl;
|
||||
list1.transfer(list2);
|
||||
|
||||
Info<<"list1: " << list1 << endl;
|
||||
Info<<"list2: " << list2 << endl;
|
||||
Info<<"list1: " << list1 << nl
|
||||
<<"list2: " << list2 << endl;
|
||||
|
||||
Info<<"indirectly delete some items via setSize :" << endl;
|
||||
list1.setSize(4);
|
||||
@ -151,16 +150,71 @@ int main(int argc, char *argv[])
|
||||
PtrList<Scalar> list3(list1.xfer());
|
||||
Info<< "Transferred via the xfer() method" << endl;
|
||||
|
||||
Info<<"list1: " << list1 << endl;
|
||||
Info<<"list2: " << list2 << endl;
|
||||
Info<<"list3: " << list3 << endl;
|
||||
Info<<"list1: " << list1 << nl
|
||||
<<"list2: " << list2 << nl
|
||||
<<"list3: " << list3 << endl;
|
||||
|
||||
|
||||
Info<<"Move construct:" << endl;
|
||||
|
||||
PtrList<Scalar> list4(std::move(list3));
|
||||
|
||||
Info<<"list3: " << list3 << nl
|
||||
<<"list4: " << list4 << endl;
|
||||
|
||||
Info<<"Move assign:" << endl;
|
||||
list3 = std::move(list4);
|
||||
|
||||
Info<<"list3: " << list3 << nl
|
||||
<<"list4: " << list4 << endl;
|
||||
|
||||
|
||||
Info<<"UPtrList from PtrList" << nl;
|
||||
|
||||
UPtrList<Scalar> ulist1(list3);
|
||||
|
||||
Info<<"ulist1: " << ulist1 << nl;
|
||||
|
||||
Info<<"Move construct:" << endl;
|
||||
|
||||
UPtrList<Scalar> ulist2(std::move(ulist1));
|
||||
|
||||
Info<<"ulist1: " << ulist1 << nl
|
||||
<<"ulist2: " << ulist2 << nl;
|
||||
|
||||
Info<<"Copy assign:" << endl;
|
||||
ulist1 = ulist2;
|
||||
|
||||
Info<<"ulist1: " << ulist1 << nl
|
||||
<<"ulist2: " << ulist2 << nl;
|
||||
|
||||
Info<<"Move assign:" << endl;
|
||||
ulist1 = std::move(ulist2);
|
||||
|
||||
Info<<"ulist1: " << ulist1 << nl
|
||||
<<"ulist2: " << ulist2 << nl;
|
||||
|
||||
// Test iterator random access
|
||||
{
|
||||
auto iter1 = ulist1.begin();
|
||||
auto iter2 = iter1 + 3;
|
||||
|
||||
Info<<"begin:" << *iter1 << " (+3):" << *iter2 << nl;
|
||||
Info<< "diff= " << (iter1 - iter2) << nl;
|
||||
Info<< "iter[2]=" << iter1[2] << nl;
|
||||
Info<< "iter1 < iter2 : " << (iter1 < iter2) << nl;
|
||||
Info<< "iter1 >= iter2 : " << (iter1 >= iter2) << nl;
|
||||
}
|
||||
|
||||
PtrList<plane> planes;
|
||||
planes.append(new plane(vector::one, vector::one));
|
||||
planes.append(new plane(vector(1,2,3), vector::one));
|
||||
|
||||
forAll(planes, p)
|
||||
Info<< "plane " << planes[p] << endl;
|
||||
Info<< nl << "appended values" << nl;
|
||||
for (const plane& p : planes)
|
||||
{
|
||||
Info<< " plane " << p << endl;
|
||||
}
|
||||
|
||||
Info<< nl << "Done." << endl;
|
||||
return 0;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,40 +29,30 @@ License
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::PtrList<T>::PtrList()
|
||||
Foam::PtrList<T>::PtrList(const PtrList<T>& lst)
|
||||
:
|
||||
UPtrList<T>()
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::PtrList<T>::PtrList(const label len)
|
||||
:
|
||||
UPtrList<T>(len)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::PtrList<T>::PtrList(const PtrList<T>& a)
|
||||
:
|
||||
UPtrList<T>(a.size())
|
||||
UPtrList<T>(lst.size())
|
||||
{
|
||||
forAll(*this, i)
|
||||
const label len = this->size();
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
this->ptrs_[i] = (a[i]).clone().ptr();
|
||||
this->ptrs_[i] = (lst[i]).clone().ptr();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class CloneArg>
|
||||
Foam::PtrList<T>::PtrList(const PtrList<T>& a, const CloneArg& cloneArg)
|
||||
Foam::PtrList<T>::PtrList(const PtrList<T>& lst, const CloneArg& cloneArg)
|
||||
:
|
||||
UPtrList<T>(a.size())
|
||||
UPtrList<T>(lst.size())
|
||||
{
|
||||
forAll(*this, i)
|
||||
const label len = this->size();
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
this->ptrs_[i] = (a[i]).clone(cloneArg).ptr();
|
||||
this->ptrs_[i] = (lst[i]).clone(cloneArg).ptr();
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,34 +65,31 @@ Foam::PtrList<T>::PtrList(const Xfer<PtrList<T>>& lst)
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::PtrList<T>::PtrList(PtrList<T>& a, bool reuse)
|
||||
Foam::PtrList<T>::PtrList(PtrList<T>& lst, bool reuse)
|
||||
:
|
||||
UPtrList<T>(a, reuse)
|
||||
UPtrList<T>(lst, reuse)
|
||||
{
|
||||
if (!reuse)
|
||||
{
|
||||
forAll(*this, i)
|
||||
const label len = this->size();
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
this->ptrs_[i] = (a[i]).clone().ptr();
|
||||
this->ptrs_[i] = (lst[i]).clone().ptr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::PtrList<T>::PtrList(const SLPtrList<T>& sll)
|
||||
Foam::PtrList<T>::PtrList(const SLPtrList<T>& lst)
|
||||
:
|
||||
UPtrList<T>(sll.size())
|
||||
UPtrList<T>(lst.size())
|
||||
{
|
||||
if (sll.size())
|
||||
if (lst.size())
|
||||
{
|
||||
label i = 0;
|
||||
for
|
||||
(
|
||||
typename SLPtrList<T>::const_iterator iter = sll.cbegin();
|
||||
iter != sll.cend();
|
||||
++iter
|
||||
)
|
||||
for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter)
|
||||
{
|
||||
this->ptrs_[i++] = (*iter).clone().ptr();
|
||||
}
|
||||
@ -115,7 +102,10 @@ Foam::PtrList<T>::PtrList(const SLPtrList<T>& sll)
|
||||
template<class T>
|
||||
Foam::PtrList<T>::~PtrList()
|
||||
{
|
||||
forAll(*this, i)
|
||||
const label len = this->size();
|
||||
|
||||
// Free old pointers
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
if (this->ptrs_[i])
|
||||
{
|
||||
@ -127,53 +117,12 @@ Foam::PtrList<T>::~PtrList()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::PtrList<T>::setSize(const label newSize)
|
||||
{
|
||||
if (newSize < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad set size " << newSize
|
||||
<< " for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
label oldSize = this->size();
|
||||
|
||||
if (newSize == 0)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
else if (newSize < oldSize)
|
||||
{
|
||||
label i;
|
||||
for (i=newSize; i<oldSize; i++)
|
||||
{
|
||||
if (this->ptrs_[i])
|
||||
{
|
||||
delete this->ptrs_[i];
|
||||
}
|
||||
}
|
||||
|
||||
this->ptrs_.setSize(newSize);
|
||||
}
|
||||
else // newSize > oldSize
|
||||
{
|
||||
this->ptrs_.setSize(newSize);
|
||||
|
||||
label i;
|
||||
for (i=oldSize; i<newSize; i++)
|
||||
{
|
||||
this->ptrs_[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::PtrList<T>::clear()
|
||||
{
|
||||
forAll(*this, i)
|
||||
const label len = this->size();
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
if (this->ptrs_[i])
|
||||
{
|
||||
@ -181,109 +130,82 @@ void Foam::PtrList<T>::clear()
|
||||
}
|
||||
}
|
||||
|
||||
this->ptrs_.clear();
|
||||
UPtrList<T>::clear();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::PtrList<T>::transfer(PtrList<T>& a)
|
||||
void Foam::PtrList<T>::setSize(const label newLen)
|
||||
{
|
||||
clear();
|
||||
this->ptrs_.transfer(a.ptrs_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::PtrList<T>::reorder(const labelUList& oldToNew)
|
||||
{
|
||||
if (oldToNew.size() != this->size())
|
||||
if (newLen <= 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Size of map (" << oldToNew.size()
|
||||
<< ") not equal to list size (" << this->size()
|
||||
<< ") for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
List<T*> newPtrs_(this->ptrs_.size(), reinterpret_cast<T*>(0));
|
||||
|
||||
forAll(*this, i)
|
||||
const label oldLen = this->size();
|
||||
if (newLen < oldLen)
|
||||
{
|
||||
const label newI = oldToNew[i];
|
||||
|
||||
if (newI < 0 || newI >= this->size())
|
||||
// Truncate - free old pointers
|
||||
for (label i=newLen; i<oldLen; ++i)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Illegal index " << newI << nl
|
||||
<< "Valid indices are 0.." << this->size()-1
|
||||
<< " for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
if (this->ptrs_[i])
|
||||
{
|
||||
delete this->ptrs_[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (newPtrs_[newI])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "reorder map is not unique; element " << newI
|
||||
<< " already set for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
newPtrs_[newI] = this->ptrs_[i];
|
||||
this->ptrs_.setSize(newLen);
|
||||
}
|
||||
|
||||
forAll(newPtrs_, i)
|
||||
else if (newLen > oldLen)
|
||||
{
|
||||
if (!newPtrs_[i])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Element " << i << " not set after reordering with type "
|
||||
<< typeid(T).name() << nl << abort(FatalError);
|
||||
}
|
||||
// Extend - new elements initialized to nullptr
|
||||
this->ptrs_.setSize(newLen, reinterpret_cast<T*>(0));
|
||||
}
|
||||
|
||||
this->ptrs_.transfer(newPtrs_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::PtrList<T>::operator=(const PtrList<T>& a)
|
||||
void Foam::PtrList<T>::operator=(const PtrList<T>& lst)
|
||||
{
|
||||
if (this == &a)
|
||||
if (this == &lst)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted assignment to self for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (this->size() == 0)
|
||||
{
|
||||
setSize(a.size());
|
||||
const label oldLen = this->size();
|
||||
const label newLen = lst.size();
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
this->ptrs_[i] = (a[i]).clone().ptr();
|
||||
}
|
||||
}
|
||||
else if (a.size() == this->size())
|
||||
// Truncate (frees old pointers) or extend the length
|
||||
setSize(newLen);
|
||||
|
||||
if (newLen < oldLen)
|
||||
{
|
||||
forAll(*this, i)
|
||||
// Copy values for existing entries
|
||||
for (label i=0; i<newLen; ++i)
|
||||
{
|
||||
(*this)[i] = a[i];
|
||||
(*this)[i] = lst[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "bad size: " << a.size()
|
||||
<< " for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
// Copy values for existing entries
|
||||
for (label i=0; i<oldLen; ++i)
|
||||
{
|
||||
(*this)[i] = lst[i];
|
||||
}
|
||||
|
||||
// Clone pointers for new entries
|
||||
for (label i=oldLen; i<newLen; ++i)
|
||||
{
|
||||
this->ptrs_[i] = (lst[i]).clone().ptr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PtrListIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,11 +25,12 @@ Class
|
||||
Foam::PtrList
|
||||
|
||||
Description
|
||||
A templated 1D list of pointers to objects of type \<T\>, where the
|
||||
size of the array is known and used for subscript bounds checking, etc.
|
||||
A list of pointers to objects of type \<T\>, with allocation/deallocation
|
||||
management of the pointers.
|
||||
The operator[] returns a reference to the object, not the pointer.
|
||||
|
||||
The element operator [] returns a reference to the object rather than a
|
||||
pointer.
|
||||
See Also
|
||||
Foam::PtrList
|
||||
|
||||
SourceFiles
|
||||
PtrListI.H
|
||||
@ -81,27 +82,30 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null Constructor
|
||||
PtrList();
|
||||
//- Construct null
|
||||
PtrList() = default;
|
||||
|
||||
//- Construct with size specified
|
||||
explicit PtrList(const label len);
|
||||
//- Construct with specified size, each element initialized to nullptr
|
||||
explicit inline PtrList(const label nElem);
|
||||
|
||||
//- Copy constructor, using 'clone()' method on each element
|
||||
PtrList(const PtrList<T>& a);
|
||||
//- Copy construct using 'clone()' method on each element
|
||||
PtrList(const PtrList<T>& lst);
|
||||
|
||||
//- Copy constructor with additional argument for clone
|
||||
//- Move construct
|
||||
inline PtrList(PtrList<T>&& lst);
|
||||
|
||||
//- Copy construct with additional argument for 'clone()'
|
||||
template<class CloneArg>
|
||||
PtrList(const PtrList<T>& a, const CloneArg& cloneArg);
|
||||
PtrList(const PtrList<T>& lst, const CloneArg& cloneArg);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
PtrList(const Xfer<PtrList<T>>& lst);
|
||||
|
||||
//- Construct as copy or re-use as specified
|
||||
PtrList(PtrList<T>& a, bool reuse);
|
||||
PtrList(PtrList<T>& lst, bool reuse);
|
||||
|
||||
//- Construct as copy of SLPtrList<T>
|
||||
explicit PtrList(const SLPtrList<T>& sll);
|
||||
explicit PtrList(const SLPtrList<T>& lst);
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
@ -115,62 +119,62 @@ public:
|
||||
~PtrList();
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Edit
|
||||
//- Clear the PtrList. Set size to zero and delete allocated entries
|
||||
void clear();
|
||||
|
||||
//- Reset size of PtrList. If extending the PtrList, new entries are
|
||||
// set to nullptr. If truncating the PtrList, removed entries are
|
||||
// deleted
|
||||
void setSize(const label);
|
||||
//- Reset size of PtrList.
|
||||
// New entries are initialized to nullptr, removed entries are deleted
|
||||
void setSize(const label newLen);
|
||||
|
||||
//- Alias for setSize(const label)
|
||||
inline void resize(const label);
|
||||
//- Reset size of PtrList.
|
||||
// New entries are initialized to nullptr, removed entries are deleted
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Clear the PtrList, i.e. set size to zero deleting all the
|
||||
// allocated entries
|
||||
void clear();
|
||||
//- Append an element at the end of the list
|
||||
using UPtrList<T>::append;
|
||||
|
||||
//- Append an element at the end of the list
|
||||
inline void append(T*);
|
||||
inline void append(const autoPtr<T>&);
|
||||
inline void append(const tmp<T>&);
|
||||
//- Append an element at the end of the list
|
||||
inline void append(const autoPtr<T>& aptr);
|
||||
|
||||
//- Transfer the contents of the argument PtrList into this PtrList
|
||||
// and annul the argument list
|
||||
void transfer(PtrList<T>&);
|
||||
//- Append an element at the end of the list
|
||||
inline void append(const tmp<T>& tptr);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PtrList<T>> xfer();
|
||||
//- Transfer into this list and annul the argument list
|
||||
inline void transfer(PtrList<T>& lst);
|
||||
|
||||
//- Is element set
|
||||
inline bool set(const label) const;
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PtrList<T>> xfer();
|
||||
|
||||
//- Set element to given T* and return old element (can be nullptr)
|
||||
inline autoPtr<T> set(const label, T*);
|
||||
//- Return true if element is set (ie, not a nullptr)
|
||||
inline bool set(const label i) const;
|
||||
|
||||
//- Set element to given autoPtr<T> and return old element
|
||||
inline autoPtr<T> set(const label, const autoPtr<T>&);
|
||||
//- Set element to given pointer and return old element (can be null)
|
||||
inline autoPtr<T> set(const label i, T* ptr);
|
||||
|
||||
//- Set element to given tmp<T> and return old element
|
||||
inline autoPtr<T> set(const label, const tmp<T>&);
|
||||
//- Set element to given autoPtr and return old element
|
||||
inline autoPtr<T> set(const label i, const autoPtr<T>& aptr);
|
||||
|
||||
//- Reorders elements. Ordering does not have to be done in
|
||||
// ascending or descending order. Reordering has to be unique.
|
||||
// (is shuffle)
|
||||
void reorder(const labelUList&);
|
||||
//- Set element to given tmp and return old element
|
||||
inline autoPtr<T> set(const label i, const tmp<T>& tptr);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Assignment
|
||||
void operator=(const PtrList<T>&);
|
||||
//- Copy assignment.
|
||||
// For existing list entries, values are copied from the list.
|
||||
// For new list entries, pointers are cloned from the list.
|
||||
void operator=(const PtrList<T>& lst);
|
||||
|
||||
//- Move assignment
|
||||
inline void operator=(PtrList<T>&& lst);
|
||||
|
||||
|
||||
// IOstream operator
|
||||
|
||||
//- Read PtrList from Istream, discarding contents of existing PtrList
|
||||
friend Istream& operator>> <T>(Istream&, PtrList<T>&);
|
||||
friend Istream& operator>> <T>(Istream& is, PtrList<T>& lst);
|
||||
};
|
||||
|
||||
|
||||
@ -186,6 +190,7 @@ public:
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "PtrList.C"
|
||||
#include "PtrListIO.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,38 +26,42 @@ License
|
||||
#include "autoPtr.H"
|
||||
#include "tmp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::PtrList<T>::PtrList(const label nElem)
|
||||
:
|
||||
UPtrList<T>(nElem)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::PtrList<T>::PtrList(PtrList<T>&& lst)
|
||||
:
|
||||
UPtrList<T>(std::move(lst))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::resize(const label newSize)
|
||||
inline void Foam::PtrList<T>::resize(const label newLen)
|
||||
{
|
||||
this->setSize(newSize);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(T* ptr)
|
||||
{
|
||||
const label idx = this->size();
|
||||
this->setSize(idx + 1);
|
||||
this->ptrs_[idx] = ptr;
|
||||
this->setSize(newLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append(const autoPtr<T>& aptr)
|
||||
{
|
||||
return append(const_cast<autoPtr<T>&>(aptr).ptr());
|
||||
return UPtrList<T>::append(const_cast<autoPtr<T>&>(aptr).ptr());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::append
|
||||
(
|
||||
const tmp<T>& t
|
||||
)
|
||||
inline void Foam::PtrList<T>::append(const tmp<T>& tptr)
|
||||
{
|
||||
return append(const_cast<tmp<T>&>(t).ptr());
|
||||
return UPtrList<T>::append(const_cast<tmp<T>&>(tptr).ptr());
|
||||
}
|
||||
|
||||
|
||||
@ -92,10 +96,18 @@ template<class T>
|
||||
inline Foam::autoPtr<T> Foam::PtrList<T>::set
|
||||
(
|
||||
const label i,
|
||||
const tmp<T>& t
|
||||
const tmp<T>& tptr
|
||||
)
|
||||
{
|
||||
return set(i, const_cast<tmp<T>&>(t).ptr());
|
||||
return set(i, const_cast<tmp<T>&>(tptr).ptr());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::transfer(PtrList<T>& lst)
|
||||
{
|
||||
this->clear();
|
||||
UPtrList<T>::swap(lst);
|
||||
}
|
||||
|
||||
|
||||
@ -106,4 +118,14 @@ inline Foam::Xfer<Foam::PtrList<T>> Foam::PtrList<T>::xfer()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::operator=(PtrList<T>&& lst)
|
||||
{
|
||||
this->clear();
|
||||
this->swap(lst);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -139,16 +139,11 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inew)
|
||||
|
||||
setSize(sllPtrs.size());
|
||||
|
||||
// Pointers - can simply copy
|
||||
// A list of pointers - can simply copy
|
||||
label i = 0;
|
||||
for
|
||||
(
|
||||
typename SLList<T*>::const_iterator iter = sllPtrs.cbegin();
|
||||
iter != sllPtrs.cend();
|
||||
++iter
|
||||
)
|
||||
for (T* ptr : sllPtrs)
|
||||
{
|
||||
set(i++, *iter);
|
||||
set(i++, ptr);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,137 +27,66 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList()
|
||||
:
|
||||
ptrs_()
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList(const label s)
|
||||
:
|
||||
ptrs_(s, reinterpret_cast<T*>(0))
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList(UList<T>& lst)
|
||||
:
|
||||
ptrs_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
const label len = lst.size();
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
ptrs_[i] = &lst[i];
|
||||
ptrs_[i] = &(lst[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList(PtrList<T>& lst)
|
||||
:
|
||||
ptrs_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
{
|
||||
ptrs_[i] = &lst[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList(const Xfer<UPtrList<T>>& lst)
|
||||
{
|
||||
transfer(lst());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList(UPtrList<T>& a, bool reuse)
|
||||
:
|
||||
ptrs_(a.ptrs_, reuse)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::UPtrList<T>::setSize(const label newSize)
|
||||
{
|
||||
label oldSize = size();
|
||||
|
||||
if (newSize <= 0)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
else if (newSize < oldSize)
|
||||
{
|
||||
ptrs_.setSize(newSize);
|
||||
}
|
||||
else if (newSize > oldSize)
|
||||
{
|
||||
ptrs_.setSize(newSize);
|
||||
|
||||
// set new elements to nullptr
|
||||
for (label i=oldSize; i<newSize; i++)
|
||||
{
|
||||
ptrs_[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::UPtrList<T>::clear()
|
||||
{
|
||||
ptrs_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::UPtrList<T>::transfer(UPtrList<T>& a)
|
||||
{
|
||||
ptrs_.transfer(a.ptrs_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::UPtrList<T>::reorder(const labelUList& oldToNew)
|
||||
{
|
||||
if (oldToNew.size() != size())
|
||||
const label len = this->size();
|
||||
|
||||
if (oldToNew.size() != len)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Size of map (" << oldToNew.size()
|
||||
<< ") not equal to list size (" << size()
|
||||
<< ")." << abort(FatalError);
|
||||
<< ") not equal to list size (" << len
|
||||
<< ") for type " << typeid(T).name() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(0));
|
||||
// New list of pointers
|
||||
List<T*> ptrLst(len, reinterpret_cast<T*>(0));
|
||||
|
||||
forAll(*this, i)
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
label newI = oldToNew[i];
|
||||
const label idx = oldToNew[i];
|
||||
|
||||
if (newI < 0 || newI >= size())
|
||||
if (idx < 0 || idx >= len)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Illegal index " << newI << nl
|
||||
<< "Valid indices are 0.." << size()-1
|
||||
<< "Illegal index " << idx << nl
|
||||
<< "Valid indices are 0.." << len-1
|
||||
<< " for type " << typeid(T).name() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (newPtrs_[newI])
|
||||
if (ptrLst[idx])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "reorder map is not unique; element " << newI
|
||||
<< " already set." << abort(FatalError);
|
||||
<< "reorder map is not unique; element " << idx
|
||||
<< " already set for type " << typeid(T).name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
newPtrs_[newI] = ptrs_[i];
|
||||
ptrLst[idx] = ptrs_[i];
|
||||
}
|
||||
|
||||
forAll(newPtrs_, i)
|
||||
// Verify that all pointers were set
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
if (!newPtrs_[i])
|
||||
if (!ptrLst[i])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Element " << i << " not set after reordering." << nl
|
||||
@ -165,12 +94,8 @@ void Foam::UPtrList<T>::reorder(const labelUList& oldToNew)
|
||||
}
|
||||
}
|
||||
|
||||
ptrs_.transfer(newPtrs_);
|
||||
ptrs_.swap(ptrLst);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "UPtrListIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,14 +25,15 @@ Class
|
||||
Foam::UPtrList
|
||||
|
||||
Description
|
||||
A templated 1D list of pointers to objects of type \<T\>, where the
|
||||
size of the array is known and used for subscript bounds checking, etc.
|
||||
A list of pointers to objects of type \<T\>, without allocation/deallocation
|
||||
management of the pointers - this is to be done elsewhere.
|
||||
The operator[] returns a reference to the object, not the pointer.
|
||||
|
||||
The element operator [] returns a reference to the object rather than a
|
||||
pointer. Storage is not allocated during construction or use but is
|
||||
supplied to the constructor as an argument.
|
||||
See Also
|
||||
Foam::PtrList
|
||||
|
||||
SourceFiles
|
||||
UPtrListI.H
|
||||
UPtrList.C
|
||||
UPtrListIO.C
|
||||
|
||||
@ -43,337 +44,271 @@ SourceFiles
|
||||
|
||||
#include "List.H"
|
||||
#include "PtrList.H"
|
||||
#include <iterator>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend classes
|
||||
template<class T> class PtrList;
|
||||
// Forward declarations
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class T> class PtrList;
|
||||
template<class T> class UPtrList;
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::iterator operator+
|
||||
(
|
||||
const typename UPtrList<T>::iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::iterator operator+
|
||||
(
|
||||
label,
|
||||
const typename UPtrList<T>::iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::iterator operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline label operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator&,
|
||||
const typename UPtrList<T>::iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::const_iterator operator+
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::const_iterator operator+
|
||||
(
|
||||
label,
|
||||
const typename UPtrList<T>::const_iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::const_iterator operator-
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline label operator-
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator&,
|
||||
const typename UPtrList<T>::const_iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
Istream& operator>>(Istream&, UPtrList<T>&);
|
||||
|
||||
template<class T>
|
||||
Ostream& operator<<(Ostream&, const UPtrList<T>&);
|
||||
template<class T> Ostream& operator<<(Ostream& os, const UPtrList<T>& lst);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class UPtrList Declaration
|
||||
Class UPtrList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
class UPtrList
|
||||
{
|
||||
// Private data
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
List<T*> ptrs_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Related types
|
||||
// STL type definitions
|
||||
|
||||
//- Declare friendship with the UPtrList class
|
||||
friend class PtrList<T>;
|
||||
//- Type of values the list contains
|
||||
typedef T value_type;
|
||||
|
||||
//- A non-const reference to the value_type
|
||||
typedef T& reference;
|
||||
|
||||
//- A const reference to the value_type
|
||||
typedef const T& const_reference;
|
||||
|
||||
//- Random-access iterator with non-const access
|
||||
class iterator;
|
||||
|
||||
//- Random-access iterator with const access
|
||||
class const_iterator;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null Constructor
|
||||
UPtrList();
|
||||
//- Construct null
|
||||
UPtrList() = default;
|
||||
|
||||
//- Construct with size specified
|
||||
explicit UPtrList(const label);
|
||||
//- Construct with specified size, each element initialized to nullptr
|
||||
explicit inline UPtrList(const label nElem);
|
||||
|
||||
//- Construct from UList
|
||||
explicit UPtrList(UList<T>&);
|
||||
//- Construct from PtrList, copying addresses of each list element.
|
||||
// The argument is non-const access since this UPtrList can be used
|
||||
// to change its values.
|
||||
explicit inline UPtrList(PtrList<T>& lst);
|
||||
|
||||
//- Construct from PtrList
|
||||
explicit UPtrList(PtrList<T>&);
|
||||
//- Construct from UList, taking addresses of each list element
|
||||
explicit UPtrList(UList<T>& lst);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
UPtrList(const Xfer<UPtrList<T>>&);
|
||||
inline UPtrList(const Xfer<UPtrList<T>>& lst);
|
||||
|
||||
//- Construct as copy or re-use as specified
|
||||
UPtrList(UPtrList<T>&, bool reuse);
|
||||
inline UPtrList(UPtrList<T>& lst, bool reuse);
|
||||
|
||||
//- Copy construct
|
||||
inline UPtrList(const UPtrList<T>& lst) = default;
|
||||
|
||||
//- Move construct
|
||||
inline UPtrList(UPtrList<T>&& lst);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Return the number of elements in the UPtrList
|
||||
inline label size() const;
|
||||
//- Return the number of elements in the UPtrList
|
||||
inline label size() const;
|
||||
|
||||
//- Return true if the UPtrList is empty (ie, size() is zero)
|
||||
inline bool empty() const;
|
||||
//- Return true if the UPtrList is empty (ie, size() is zero)
|
||||
inline bool empty() const;
|
||||
|
||||
//- Swap content with another UPtrList
|
||||
inline void swap(UPtrList<T>& lst);
|
||||
//- Return reference to the first element of the list
|
||||
inline T& first();
|
||||
|
||||
//- Return reference to the first element of the list
|
||||
inline T& first();
|
||||
//- Return reference to first element of the list
|
||||
inline const T& first() const;
|
||||
|
||||
//- Return reference to first element of the list
|
||||
inline const T& first() const;
|
||||
//- Return reference to the last element of the list
|
||||
inline T& last();
|
||||
|
||||
//- Return reference to the last element of the list
|
||||
inline T& last();
|
||||
|
||||
//- Return reference to the last element of the list
|
||||
inline const T& last() const;
|
||||
//- Return reference to the last element of the list
|
||||
inline const T& last() const;
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Reset size of UPtrList. This can only be used to set the size
|
||||
// of an empty UPtrList, extend a UPtrList, remove entries from
|
||||
// the end of a UPtrList
|
||||
void setSize(const label);
|
||||
//- Set list size to zero.
|
||||
inline void clear();
|
||||
|
||||
//- Reset size of UPtrList. This can only be used to set the size
|
||||
// of an empty UPtrList, extend a UPtrList, remove entries from
|
||||
// the end of a UPtrList
|
||||
inline void resize(const label);
|
||||
//- Reset size of UPtrList.
|
||||
// New entries are initialized to nullptr.
|
||||
inline void setSize(const label newLen);
|
||||
|
||||
//- Clear the UPtrList, i.e. set size to zero
|
||||
void clear();
|
||||
//- Reset size of UPtrList.
|
||||
// New entries are initialized to nullptr.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Transfer the contents of the argument UPtrList into this
|
||||
// UPtrList and annul the argument list
|
||||
void transfer(UPtrList<T>&);
|
||||
//- Append an element to the end of the list
|
||||
inline void append(T* ptr);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<UPtrList<T>> xfer();
|
||||
//- Swap content
|
||||
inline void swap(UPtrList<T>& lst);
|
||||
|
||||
//- Is element set
|
||||
inline bool set(const label) const;
|
||||
//- Transfer contents into this list and annul the argument
|
||||
inline void transfer(UPtrList<T>& lst);
|
||||
|
||||
//- Set element. Return old element (can be nullptr).
|
||||
// No checks on new element
|
||||
inline T* set(const label, T*);
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<UPtrList<T>> xfer();
|
||||
|
||||
//- Reorders elements. Ordering does not have to be done in
|
||||
// ascending or descending order. Reordering has to be unique.
|
||||
// (is shuffle)
|
||||
void reorder(const labelUList&);
|
||||
//- Return true if element is set (ie, not a nullptr)
|
||||
inline bool set(const label i) const;
|
||||
|
||||
//- Set element to given pointer and return old element (can be null).
|
||||
// No checks on new element
|
||||
inline T* set(const label i, T* ptr);
|
||||
|
||||
//- Reorder elements. Reordering must be unique (ie, shuffle).
|
||||
void reorder(const labelUList& oldToNew);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Return element const reference
|
||||
inline const T& operator[](const label) const;
|
||||
inline const T& operator[](const label i) const;
|
||||
|
||||
//- Return element reference
|
||||
inline T& operator[](const label);
|
||||
inline T& operator[](const label i);
|
||||
|
||||
//- Return element const pointer
|
||||
inline const T* operator()(const label) const;
|
||||
inline const T* operator()(const label i) const;
|
||||
|
||||
//- Copy assignment
|
||||
UPtrList<T>& operator=(const UPtrList<T>& lst) = default;
|
||||
|
||||
//- Move assignment
|
||||
inline void operator=(UPtrList<T>&& lst);
|
||||
|
||||
|
||||
// STL type definitions
|
||||
// Iterators
|
||||
|
||||
//- Type of values the UPtrList contains
|
||||
typedef T value_type;
|
||||
|
||||
//- Type that can be used for storing into UPtrList::value_type objects
|
||||
typedef T& reference;
|
||||
|
||||
//- Type that can be used for storing into constant UPtrList::value_type
|
||||
// objects
|
||||
typedef const T& const_reference;
|
||||
|
||||
|
||||
// STL iterator
|
||||
// Random access iterator for traversing UPtrList
|
||||
|
||||
class iterator;
|
||||
friend class iterator;
|
||||
|
||||
//- An STL iterator
|
||||
//- Random-access iterator with non-const access
|
||||
class iterator
|
||||
{
|
||||
T** ptr_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct for a given UPtrList entry
|
||||
inline iterator(T**);
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using value_type = T;
|
||||
using difference_type = label;
|
||||
using pointer = T*;
|
||||
using reference = T&;
|
||||
friend class const_iterator;
|
||||
|
||||
//- Construct for a given entry
|
||||
inline iterator(T** ptr);
|
||||
|
||||
// Member operators
|
||||
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
|
||||
inline T& operator*();
|
||||
inline T& operator()();
|
||||
inline reference operator*() const;
|
||||
inline reference operator()() const;
|
||||
|
||||
inline iterator operator++();
|
||||
inline iterator operator++(int);
|
||||
// Forward iteration
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
|
||||
inline iterator operator--();
|
||||
inline iterator operator--(int);
|
||||
inline iterator& operator--();
|
||||
inline iterator operator--(int);
|
||||
|
||||
inline iterator operator+=(label);
|
||||
// Random-access
|
||||
inline iterator& operator+=(difference_type n);
|
||||
inline iterator& operator-=(difference_type n);
|
||||
inline iterator operator+(difference_type n) const;
|
||||
inline iterator operator-(difference_type n) const;
|
||||
|
||||
friend iterator operator+ <T>(const iterator&, label);
|
||||
friend iterator operator+ <T>(label, const iterator&);
|
||||
inline difference_type operator-(const iterator& iter) const;
|
||||
|
||||
inline iterator operator-=(label);
|
||||
inline reference operator[](difference_type n) const;
|
||||
|
||||
friend iterator operator- <T>(const iterator&, label);
|
||||
inline bool operator<(const iterator& iter) const;
|
||||
inline bool operator>(const iterator& iter) const;
|
||||
|
||||
friend label operator- <T>
|
||||
(
|
||||
const iterator&,
|
||||
const iterator&
|
||||
);
|
||||
|
||||
inline T& operator[](label);
|
||||
|
||||
inline bool operator<(const iterator&) const;
|
||||
inline bool operator>(const iterator&) const;
|
||||
|
||||
inline bool operator<=(const iterator&) const;
|
||||
inline bool operator>=(const iterator&) const;
|
||||
inline bool operator<=(const iterator& iter) const;
|
||||
inline bool operator>=(const iterator& iter) const;
|
||||
};
|
||||
|
||||
//- Return an iterator to begin traversing the UPtrList
|
||||
inline iterator begin();
|
||||
|
||||
//- Return an iterator to end traversing the UPtrList
|
||||
inline iterator end();
|
||||
|
||||
|
||||
// STL const_iterator
|
||||
// Random access iterator for traversing UPtrList
|
||||
|
||||
//- An STL-conforming const_iterator
|
||||
//- Random-access iterator with const access
|
||||
class const_iterator
|
||||
{
|
||||
const T* const* ptr_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct for a given UPtrList entry
|
||||
inline const_iterator(const T* const*);
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using value_type = const T;
|
||||
using difference_type = label;
|
||||
using pointer = const T*;
|
||||
using reference = const T&;
|
||||
|
||||
//- Construct from an iterator
|
||||
inline const_iterator(const iterator&);
|
||||
//- Construct for a given entry
|
||||
inline const_iterator(const T* const* ptr);
|
||||
|
||||
//- Copy construct from non-const iterator
|
||||
inline const_iterator(const iterator& iter);
|
||||
|
||||
// Member operators
|
||||
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
|
||||
typedef const T& Tref;
|
||||
inline Tref operator*();
|
||||
inline Tref operator()();
|
||||
inline reference operator*() const;
|
||||
inline reference operator()() const;
|
||||
|
||||
inline const_iterator operator++();
|
||||
inline const_iterator operator++(int);
|
||||
// Forward iteration
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
|
||||
inline const_iterator operator--();
|
||||
inline const_iterator operator--(int);
|
||||
inline const_iterator& operator--();
|
||||
inline const_iterator operator--(int);
|
||||
|
||||
inline const_iterator operator+=(label);
|
||||
// Random-access
|
||||
inline const_iterator& operator+=(difference_type n);
|
||||
inline const_iterator& operator-=(difference_type n);
|
||||
inline const_iterator operator+(difference_type n) const;
|
||||
inline const_iterator operator-(difference_type n) const;
|
||||
|
||||
friend const_iterator operator+ <T>
|
||||
(
|
||||
const const_iterator&,
|
||||
label
|
||||
);
|
||||
friend const_iterator operator+ <T>
|
||||
(
|
||||
label,
|
||||
const const_iterator&
|
||||
);
|
||||
inline difference_type operator-(const const_iterator& iter) const;
|
||||
|
||||
inline const_iterator operator-=(label);
|
||||
inline reference operator[](difference_type n) const;
|
||||
|
||||
friend const_iterator operator- <T>
|
||||
(
|
||||
const const_iterator&,
|
||||
label
|
||||
);
|
||||
inline bool operator<(const const_iterator& iter) const;
|
||||
inline bool operator>(const const_iterator& iter) const;
|
||||
|
||||
friend label operator- <T>
|
||||
(
|
||||
const const_iterator&,
|
||||
const const_iterator&
|
||||
);
|
||||
|
||||
inline const T& operator[](label);
|
||||
|
||||
inline bool operator<(const const_iterator&) const;
|
||||
inline bool operator>(const const_iterator&) const;
|
||||
|
||||
inline bool operator<=(const const_iterator&) const;
|
||||
inline bool operator>=(const const_iterator&) const;
|
||||
inline bool operator<=(const const_iterator& iter) const;
|
||||
inline bool operator>=(const const_iterator& iter) const;
|
||||
};
|
||||
|
||||
|
||||
//- Return an iterator to begin traversing the UPtrList
|
||||
inline iterator begin();
|
||||
|
||||
//- Return an iterator to end traversing the UPtrList
|
||||
inline iterator end();
|
||||
|
||||
//- Return an const_iterator to begin traversing the UPtrList
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
@ -390,7 +325,7 @@ public:
|
||||
// IOstream operator
|
||||
|
||||
//- Write UPtrList to Ostream
|
||||
friend Ostream& operator<< <T>(Ostream&, const UPtrList<T>&);
|
||||
friend Ostream& operator<< <T>(Ostream& os, const UPtrList<T>& lst);
|
||||
};
|
||||
|
||||
|
||||
@ -406,6 +341,7 @@ public:
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "UPtrList.C"
|
||||
#include "UPtrListIO.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,6 +23,43 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::UPtrList(const label nElem)
|
||||
:
|
||||
ptrs_(nElem, reinterpret_cast<T*>(0))
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::UPtrList(PtrList<T>& lst)
|
||||
:
|
||||
ptrs_(lst.ptrs_)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::UPtrList(UPtrList<T>&& lst)
|
||||
:
|
||||
ptrs_(std::move(lst.ptrs_))
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::UPtrList(const Xfer<UPtrList<T>>& lst)
|
||||
{
|
||||
transfer(lst());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::UPtrList(UPtrList<T>& lst, bool reuse)
|
||||
:
|
||||
ptrs_(lst.ptrs_, reuse)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -39,6 +76,13 @@ inline bool Foam::UPtrList<T>::empty() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::clear()
|
||||
{
|
||||
ptrs_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::swap(UPtrList<T>& lst)
|
||||
{
|
||||
@ -46,6 +90,13 @@ inline void Foam::UPtrList<T>::swap(UPtrList<T>& lst)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::transfer(UPtrList<T>& lst)
|
||||
{
|
||||
ptrs_.transfer(lst.ptrs_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::first()
|
||||
{
|
||||
@ -75,9 +126,36 @@ inline const T& Foam::UPtrList<T>::last() const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::resize(const label newSize)
|
||||
inline void Foam::UPtrList<T>::setSize(const label newLen)
|
||||
{
|
||||
this->setSize(newSize);
|
||||
if (newLen <= 0)
|
||||
{
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const label oldLen = this->size();
|
||||
if (newLen != oldLen)
|
||||
{
|
||||
// Truncate or extend (new elements initialized to nullptr)
|
||||
ptrs_.setSize(newLen, reinterpret_cast<T*>(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::resize(const label nElem)
|
||||
{
|
||||
this->setSize(nElem);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::append(T* ptr)
|
||||
{
|
||||
const label idx = this->size();
|
||||
ptrs_.setSize(idx + 1);
|
||||
ptrs_[idx] = ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -153,158 +231,149 @@ inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
|
||||
ptr_(ptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator==(const iterator& iter) const
|
||||
{
|
||||
return ptr_ == iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator!=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ != iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator*()
|
||||
inline T& Foam::UPtrList<T>::iterator::operator*() const
|
||||
{
|
||||
return **ptr_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator()()
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
inline T& Foam::UPtrList<T>::iterator::operator()() const
|
||||
{
|
||||
return **ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator++()
|
||||
{
|
||||
++ptr_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator++(int)
|
||||
{
|
||||
iterator tmp = *this;
|
||||
iterator iter(*this);
|
||||
++ptr_;
|
||||
return tmp;
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator--()
|
||||
{
|
||||
--ptr_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator--(int)
|
||||
{
|
||||
iterator tmp = *this;
|
||||
iterator iter(*this);
|
||||
--ptr_;
|
||||
return tmp;
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator+=(label n)
|
||||
{
|
||||
ptr_ += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::operator+(const typename UPtrList<T>::iterator& iter, label n)
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::operator+(label n, const typename UPtrList<T>::iterator& iter)
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator-=(label n)
|
||||
{
|
||||
ptr_ -= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::operator-(const typename UPtrList<T>::iterator& iter, label n)
|
||||
Foam::UPtrList<T>::iterator::operator+(label n) const
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = iter;
|
||||
return tmp -= n;
|
||||
return iterator(ptr_ + n);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator& iter1,
|
||||
const typename UPtrList<T>::iterator& iter2
|
||||
)
|
||||
{
|
||||
return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator[](label n)
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator-(label n) const
|
||||
{
|
||||
return iterator(ptr_ - n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label
|
||||
Foam::UPtrList<T>::iterator::operator-(const iterator& iter) const
|
||||
{
|
||||
return (ptr_ - iter.ptr_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator[](label n) const
|
||||
{
|
||||
return *(*this + n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator<(const iterator& iter) const
|
||||
{
|
||||
return ptr_ < iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator>(const iterator& iter) const
|
||||
{
|
||||
return ptr_ > iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator<=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ <= iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ >= iter.ptr_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::begin()
|
||||
{
|
||||
return ptrs_.begin();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::end()
|
||||
{
|
||||
return ptrs_.end();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * //
|
||||
|
||||
@ -343,21 +412,21 @@ inline bool Foam::UPtrList<T>::const_iterator::operator!=
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator*()
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator*() const
|
||||
{
|
||||
return **ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator()()
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator()() const
|
||||
{
|
||||
return operator*();
|
||||
return **ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator++()
|
||||
{
|
||||
++ptr_;
|
||||
@ -369,14 +438,14 @@ template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator++(int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
const_iterator iter(*this);
|
||||
++ptr_;
|
||||
return tmp;
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator--()
|
||||
{
|
||||
--ptr_;
|
||||
@ -388,14 +457,14 @@ template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator--(int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
const_iterator iter(*this);
|
||||
--ptr_;
|
||||
return tmp;
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator+=(label n)
|
||||
{
|
||||
ptr_ += n;
|
||||
@ -404,25 +473,7 @@ Foam::UPtrList<T>::const_iterator::operator+=(label n)
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::operator+(const typename UPtrList<T>::const_iterator& iter, label n)
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::operator+(label n, const typename UPtrList<T>::const_iterator& iter)
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator-=(label n)
|
||||
{
|
||||
ptr_ -= n;
|
||||
@ -432,26 +483,31 @@ Foam::UPtrList<T>::const_iterator::operator-=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::operator-(const typename UPtrList<T>::const_iterator& iter, label n)
|
||||
Foam::UPtrList<T>::const_iterator::operator+(label n) const
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = iter;
|
||||
return tmp -= n;
|
||||
return const_iterator(ptr_ + n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::operator-
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator& iter1,
|
||||
const typename UPtrList<T>::const_iterator& iter2
|
||||
)
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator-(label n) const
|
||||
{
|
||||
return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
|
||||
return const_iterator(ptr_ - n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator[](label n)
|
||||
inline Foam::label
|
||||
Foam::UPtrList<T>::const_iterator::operator-(const const_iterator& iter) const
|
||||
{
|
||||
return (ptr_ - iter.ptr_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T&
|
||||
Foam::UPtrList<T>::const_iterator::operator[](label n) const
|
||||
{
|
||||
return *(*this + n);
|
||||
}
|
||||
@ -497,6 +553,40 @@ inline bool Foam::UPtrList<T>::const_iterator::operator>=
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::begin()
|
||||
{
|
||||
return ptrs_.begin();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::end()
|
||||
{
|
||||
return ptrs_.end();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::cbegin() const
|
||||
{
|
||||
return ptrs_.cbegin();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::cend() const
|
||||
{
|
||||
return ptrs_.cend();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::begin() const
|
||||
@ -513,19 +603,13 @@ Foam::UPtrList<T>::end() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::cbegin() const
|
||||
{
|
||||
return ptrs_.begin();
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::cend() const
|
||||
inline void Foam::UPtrList<T>::operator=(UPtrList<T>&& lst)
|
||||
{
|
||||
return ptrs_.end();
|
||||
this->clear();
|
||||
this->swap(lst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user