mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added xfer<...> transfer() method to various containers
- this should provide a slightly more naturally means to using transfer
constructors, for example
labelList list2(list1.transfer());
vs. labelList list2(xferMove(list1));
- returns a plain list where appropriate (eg, DynamicList, SortableList)
for example
labelList list2(dynList1.transfer());
vs. labelList list2(xferMoveTo<labelList>(dynList1));
This commit is contained in:
@ -145,6 +145,14 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
|
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
|
||||||
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
|
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
|
||||||
|
|
||||||
|
List<label> lstB(dlC.transfer());
|
||||||
|
|
||||||
|
Info<< "Transferred to normal list via the transfer() method" << endl;
|
||||||
|
Info<< "<lstB>" << lstB << "</lstB>" << nl << "sizes: "
|
||||||
|
<< " " << lstB.size() << endl;
|
||||||
|
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
|
||||||
|
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,11 @@ int main(int argc, char *argv[])
|
|||||||
list2.setSize(10, vector(1, 2, 3));
|
list2.setSize(10, vector(1, 2, 3));
|
||||||
Info<< list2 << endl;
|
Info<< list2 << endl;
|
||||||
|
|
||||||
|
List<vector> list3(list2.transfer());
|
||||||
|
Info<< "Transferred via the transfer() method" << endl;
|
||||||
|
Info<< list2 << endl;
|
||||||
|
Info<< list3 << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<<"list1: " << list1 << endl;
|
Info<<"list1: " << list1 << endl;
|
||||||
|
|
||||||
|
PtrList<Scalar> list3(list1.transfer());
|
||||||
|
Info<< "Transferred via the transfer() method" << endl;
|
||||||
|
|
||||||
|
Info<<"list1: " << list1 << endl;
|
||||||
|
Info<<"list2: " << list2 << endl;
|
||||||
|
Info<<"list3: " << list3 << endl;
|
||||||
|
|
||||||
Info<< nl << "Done." << endl;
|
Info<< nl << "Done." << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,15 +26,10 @@ License
|
|||||||
|
|
||||||
#include "CompactListList.H"
|
#include "CompactListList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
CompactListList<T>::CompactListList(const List<List<T> >& ll)
|
Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll)
|
||||||
:
|
:
|
||||||
offsets_(ll.size())
|
offsets_(ll.size())
|
||||||
{
|
{
|
||||||
@ -61,7 +56,10 @@ CompactListList<T>::CompactListList(const List<List<T> >& ll)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
CompactListList<T>::CompactListList(const UList<label>& rowSizes)
|
Foam::CompactListList<T>::CompactListList
|
||||||
|
(
|
||||||
|
const UList<label>& rowSizes
|
||||||
|
)
|
||||||
:
|
:
|
||||||
offsets_(rowSizes.size())
|
offsets_(rowSizes.size())
|
||||||
{
|
{
|
||||||
@ -77,7 +75,11 @@ CompactListList<T>::CompactListList(const UList<label>& rowSizes)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
CompactListList<T>::CompactListList(const UList<label>& rowSizes, const T& t)
|
Foam::CompactListList<T>::CompactListList
|
||||||
|
(
|
||||||
|
const UList<label>& rowSizes,
|
||||||
|
const T& t
|
||||||
|
)
|
||||||
:
|
:
|
||||||
offsets_(rowSizes.size())
|
offsets_(rowSizes.size())
|
||||||
{
|
{
|
||||||
@ -93,23 +95,31 @@ CompactListList<T>::CompactListList(const UList<label>& rowSizes, const T& t)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
CompactListList<T>::CompactListList(const xfer<CompactListList<T> >& lst)
|
Foam::CompactListList<T>::CompactListList
|
||||||
|
(
|
||||||
|
const xfer<CompactListList<T> >& lst
|
||||||
|
)
|
||||||
{
|
{
|
||||||
transfer(lst());
|
transfer(lst());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
CompactListList<T>::CompactListList(CompactListList<T>& cll, bool reUse)
|
Foam::CompactListList<T>::CompactListList
|
||||||
|
(
|
||||||
|
CompactListList<T>& lst,
|
||||||
|
bool reUse
|
||||||
|
)
|
||||||
:
|
:
|
||||||
offsets_(cll.offsets_, reUse),
|
offsets_(lst.offsets_, reUse),
|
||||||
m_(cll.m_, reUse)
|
m_(lst.m_, reUse)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const CompactListList<T>& CompactListList<T>::null()
|
const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
|
||||||
{
|
{
|
||||||
CompactListList<T>* nullPtr = reinterpret_cast<CompactListList<T>*>(NULL);
|
CompactListList<T>* nullPtr = reinterpret_cast<CompactListList<T>*>(NULL);
|
||||||
return *nullPtr;
|
return *nullPtr;
|
||||||
@ -117,7 +127,7 @@ const CompactListList<T>& CompactListList<T>::null()
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void CompactListList<T>::setSize(const label nRows)
|
void Foam::CompactListList<T>::setSize(const label nRows)
|
||||||
{
|
{
|
||||||
if (nRows == 0)
|
if (nRows == 0)
|
||||||
{
|
{
|
||||||
@ -140,14 +150,14 @@ void CompactListList<T>::setSize(const label nRows)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void CompactListList<T>::setSize(const label nRows, const label nData)
|
void Foam::CompactListList<T>::setSize(const label nRows, const label nData)
|
||||||
{
|
{
|
||||||
offsets_.setSize(nRows);
|
offsets_.setSize(nRows);
|
||||||
m_.setSize(nData);
|
m_.setSize(nData);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void CompactListList<T>::setSize
|
void Foam::CompactListList<T>::setSize
|
||||||
(
|
(
|
||||||
const label nRows,
|
const label nRows,
|
||||||
const label nData,
|
const label nData,
|
||||||
@ -159,7 +169,7 @@ void CompactListList<T>::setSize
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
labelList CompactListList<T>::sizes() const
|
Foam::labelList Foam::CompactListList<T>::sizes() const
|
||||||
{
|
{
|
||||||
labelList rowSizes(offsets_.size());
|
labelList rowSizes(offsets_.size());
|
||||||
|
|
||||||
@ -173,7 +183,7 @@ labelList CompactListList<T>::sizes() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void CompactListList<T>::setSize(const UList<label>& rowSizes)
|
void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes)
|
||||||
{
|
{
|
||||||
offsets_.setSize(rowSizes.size());
|
offsets_.setSize(rowSizes.size());
|
||||||
|
|
||||||
@ -188,7 +198,7 @@ void CompactListList<T>::setSize(const UList<label>& rowSizes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void CompactListList<T>::clear()
|
void Foam::CompactListList<T>::clear()
|
||||||
{
|
{
|
||||||
offsets_.clear();
|
offsets_.clear();
|
||||||
m_.clear();
|
m_.clear();
|
||||||
@ -196,7 +206,7 @@ void CompactListList<T>::clear()
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void CompactListList<T>::transfer(CompactListList<T>& a)
|
void Foam::CompactListList<T>::transfer(CompactListList<T>& a)
|
||||||
{
|
{
|
||||||
offsets_.transfer(a.offsets_);
|
offsets_.transfer(a.offsets_);
|
||||||
m_.transfer(a.m_);
|
m_.transfer(a.m_);
|
||||||
@ -206,34 +216,29 @@ void CompactListList<T>::transfer(CompactListList<T>& a)
|
|||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
List<List<T> > CompactListList<T>::operator()() const
|
Foam::List<Foam::List<T> > Foam::CompactListList<T>::operator()() const
|
||||||
{
|
{
|
||||||
List<List<T> > llt(offsets_.size());
|
List<List<T> > ll(offsets_.size());
|
||||||
|
|
||||||
label offsetPrev = 0;
|
label offsetPrev = 0;
|
||||||
forAll(offsets_, i)
|
forAll(offsets_, i)
|
||||||
{
|
{
|
||||||
List<T>& llti = llt[i];
|
List<T>& lst = ll[i];
|
||||||
|
|
||||||
llti.setSize(offsets_[i] - offsetPrev);
|
lst.setSize(offsets_[i] - offsetPrev);
|
||||||
|
|
||||||
forAll(llti, j)
|
forAll(lst, j)
|
||||||
{
|
{
|
||||||
llti[j] = m_[offsetPrev + j];
|
lst[j] = m_[offsetPrev + j];
|
||||||
}
|
}
|
||||||
|
|
||||||
offsetPrev = offsets_[i];
|
offsetPrev = offsets_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return llt;
|
return ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "CompactListListIO.C"
|
#include "CompactListListIO.C"
|
||||||
|
|||||||
@ -164,6 +164,8 @@ public:
|
|||||||
// into this CompactListList and annull the argument list.
|
// into this CompactListList and annull the argument list.
|
||||||
void transfer(CompactListList<T>&);
|
void transfer(CompactListList<T>&);
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container
|
||||||
|
inline xfer<CompactListList<T> > transfer();
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
|
|||||||
@ -24,20 +24,20 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline CompactListList<T>::CompactListList()
|
inline Foam::CompactListList<T>::CompactListList()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline CompactListList<T>::CompactListList(const label nRows, const label nData)
|
inline Foam::CompactListList<T>::CompactListList
|
||||||
|
(
|
||||||
|
const label nRows,
|
||||||
|
const label nData
|
||||||
|
)
|
||||||
:
|
:
|
||||||
offsets_(nRows, 0),
|
offsets_(nRows, 0),
|
||||||
m_(nData)
|
m_(nData)
|
||||||
@ -45,7 +45,7 @@ inline CompactListList<T>::CompactListList(const label nRows, const label nData)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline CompactListList<T>::CompactListList
|
inline Foam::CompactListList<T>::CompactListList
|
||||||
(
|
(
|
||||||
const label nRows,
|
const label nRows,
|
||||||
const label nData,
|
const label nData,
|
||||||
@ -58,7 +58,8 @@ inline CompactListList<T>::CompactListList
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline autoPtr<CompactListList<T> > CompactListList<T>::clone() const
|
inline Foam::autoPtr<Foam::CompactListList<T> >
|
||||||
|
Foam::CompactListList<T>::clone() const
|
||||||
{
|
{
|
||||||
return autoPtr<CompactListList<T> >(new CompactListList<T>(*this));
|
return autoPtr<CompactListList<T> >(new CompactListList<T>(*this));
|
||||||
}
|
}
|
||||||
@ -67,38 +68,46 @@ inline autoPtr<CompactListList<T> > CompactListList<T>::clone() const
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label CompactListList<T>::size() const
|
inline Foam::label Foam::CompactListList<T>::size() const
|
||||||
{
|
{
|
||||||
return offsets_.size();
|
return offsets_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const List<label>& CompactListList<T>::offsets() const
|
inline const Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() const
|
||||||
{
|
{
|
||||||
return offsets_;
|
return offsets_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline List<label>& CompactListList<T>::offsets()
|
inline Foam::List<label>& Foam::CompactListList<T>::offsets()
|
||||||
{
|
{
|
||||||
return offsets_;
|
return offsets_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const List<T>& CompactListList<T>::m() const
|
|
||||||
{
|
|
||||||
return m_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline List<T>& CompactListList<T>::m()
|
inline const Foam::List<T>& Foam::CompactListList<T>::m() const
|
||||||
{
|
{
|
||||||
return m_;
|
return m_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label CompactListList<T>::index(const label i, const label j) const
|
inline Foam::List<T>& Foam::CompactListList<T>::m()
|
||||||
|
{
|
||||||
|
return m_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::label Foam::CompactListList<T>::index
|
||||||
|
(
|
||||||
|
const label i,
|
||||||
|
const label j
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
@ -110,8 +119,9 @@ inline label CompactListList<T>::index(const label i, const label j) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label CompactListList<T>::whichRow(const label i) const
|
inline Foam::label Foam::CompactListList<T>::whichRow(const label i) const
|
||||||
{
|
{
|
||||||
if (i < 0 || i >= m_.size())
|
if (i < 0 || i >= m_.size())
|
||||||
{
|
{
|
||||||
@ -133,30 +143,35 @@ inline label CompactListList<T>::whichRow(const label i) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label CompactListList<T>::whichColumn(const label row, const label i)
|
inline Foam::label Foam::CompactListList<T>::whichColumn
|
||||||
const
|
(
|
||||||
|
const label row,
|
||||||
|
const label i
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
return i - index(row, 0);
|
return i - index(row, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::xfer<Foam::CompactListList<T> >
|
||||||
|
Foam::CompactListList<T>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<CompactListList<T> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline UList<T> CompactListList<T>::operator[](const label i)
|
inline Foam::UList<T> Foam::CompactListList<T>::operator[]
|
||||||
{
|
(
|
||||||
if (i == 0)
|
const label i
|
||||||
{
|
)
|
||||||
return UList<T>(m_.begin(), offsets_[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const UList<T> CompactListList<T>::operator[](const label i) const
|
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
@ -170,13 +185,35 @@ inline const UList<T> CompactListList<T>::operator[](const label i) const
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& CompactListList<T>::operator()(const label i, const label j)
|
inline const Foam::UList<T> Foam::CompactListList<T>::operator[]
|
||||||
|
(
|
||||||
|
const label i
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
return UList<T>(m_.begin(), offsets_[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline T& Foam::CompactListList<T>::operator()
|
||||||
|
(
|
||||||
|
const label i,
|
||||||
|
const label j
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return m_[index(i, j)];
|
return m_[index(i, j)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const T& CompactListList<T>::operator()
|
inline const T& Foam::CompactListList<T>::operator()
|
||||||
(
|
(
|
||||||
const label i,
|
const label i,
|
||||||
const label j
|
const label j
|
||||||
@ -187,14 +224,10 @@ inline const T& CompactListList<T>::operator()
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void CompactListList<T>::operator=(const T& t)
|
inline void Foam::CompactListList<T>::operator=(const T& t)
|
||||||
{
|
{
|
||||||
m_ = t;
|
m_ = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,15 +27,10 @@ License
|
|||||||
#include "CompactListList.H"
|
#include "CompactListList.H"
|
||||||
#include "Istream.H"
|
#include "Istream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
CompactListList<T>::CompactListList(Istream& is)
|
Foam::CompactListList<T>::CompactListList(Istream& is)
|
||||||
{
|
{
|
||||||
operator>>(is, *this);
|
operator>>(is, *this);
|
||||||
}
|
}
|
||||||
@ -44,23 +39,19 @@ CompactListList<T>::CompactListList(Istream& is)
|
|||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Istream& operator>>(Istream& is, CompactListList<T>& cll)
|
Foam::Istream& Foam::operator>>(Istream& is, CompactListList<T>& lst)
|
||||||
{
|
{
|
||||||
is >> cll.offsets_ >> cll.m_;
|
is >> lst.offsets_ >> lst.m_;
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Ostream& operator<<(Ostream& os, const CompactListList<T>& cll)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const CompactListList<T>& lst)
|
||||||
{
|
{
|
||||||
os << cll.offsets_ << cll.m_;
|
os << lst.offsets_ << lst.m_;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -153,6 +153,8 @@ public:
|
|||||||
//- Transfer contents of the argument DynamicList into this DynamicList
|
//- Transfer contents of the argument DynamicList into this DynamicList
|
||||||
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
inline void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container as a plain List
|
||||||
|
inline xfer<List<T> > transfer();
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -211,6 +211,16 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::xfer<Foam::List<T> >
|
||||||
|
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<List<T> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
(
|
(
|
||||||
|
|||||||
@ -178,6 +178,9 @@ public:
|
|||||||
// and annull the argument list.
|
// and annull the argument list.
|
||||||
void transfer(SortableList<T>&);
|
void transfer(SortableList<T>&);
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container
|
||||||
|
inline xfer<List<T> > transfer();
|
||||||
|
|
||||||
//- Return subscript-checked element of UList.
|
//- Return subscript-checked element of UList.
|
||||||
inline T& newElmt(const label);
|
inline T& newElmt(const label);
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,16 @@ inline Foam::label Foam::List<T>::size() const
|
|||||||
return UList<T>::size_;
|
return UList<T>::size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::xfer<Foam::List<T> > Foam::List<T>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<List<T> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -101,7 +101,6 @@ void Foam::PackedList<nBits>::transfer(PackedList<nBits>& lst)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Assignment.
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -46,7 +46,6 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class PackedListName Declaration
|
Class PackedListName Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -158,6 +157,9 @@ public:
|
|||||||
// and annull the argument list.
|
// and annull the argument list.
|
||||||
void transfer(PackedList<nBits>&);
|
void transfer(PackedList<nBits>&);
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container
|
||||||
|
inline xfer<PackedList<nBits> > transfer();
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
@ -195,10 +197,9 @@ public:
|
|||||||
|
|
||||||
// Ostream operator
|
// Ostream operator
|
||||||
|
|
||||||
// // Write PackedList to Ostream.
|
// // Write PackedList to Ostream.
|
||||||
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
||||||
}
|
};
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -32,12 +32,9 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// Calculate underlying list size
|
// Calculate underlying list size
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline label PackedList<nBits>::intSize(const label sz)
|
inline Foam::label Foam::PackedList<nBits>::intSize(const label sz)
|
||||||
{
|
{
|
||||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||||
|
|
||||||
@ -47,7 +44,7 @@ inline label PackedList<nBits>::intSize(const label sz)
|
|||||||
|
|
||||||
// Convert index into index in integer array
|
// Convert index into index in integer array
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline label PackedList<nBits>::intIndex(const label i)
|
inline Foam::label Foam::PackedList<nBits>::intIndex(const label i)
|
||||||
{
|
{
|
||||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||||
|
|
||||||
@ -60,7 +57,7 @@ inline label PackedList<nBits>::intIndex(const label i)
|
|||||||
|
|
||||||
// Check index i is within valid range (0 ... size-1).
|
// Check index i is within valid range (0 ... size-1).
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline void PackedList<nBits>::checkIndex(const label i) const
|
inline void Foam::PackedList<nBits>::checkIndex(const label i) const
|
||||||
{
|
{
|
||||||
if (!size_)
|
if (!size_)
|
||||||
{
|
{
|
||||||
@ -79,7 +76,7 @@ inline void PackedList<nBits>::checkIndex(const label i) const
|
|||||||
|
|
||||||
// Check value is representable in nBits
|
// Check value is representable in nBits
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline void PackedList<nBits>::checkValue(const unsigned int val) const
|
inline void Foam::PackedList<nBits>::checkValue(const unsigned int val) const
|
||||||
{
|
{
|
||||||
if (val>=(1u << nBits))
|
if (val>=(1u << nBits))
|
||||||
{
|
{
|
||||||
@ -95,7 +92,7 @@ inline void PackedList<nBits>::checkValue(const unsigned int val) const
|
|||||||
|
|
||||||
// Null constructor
|
// Null constructor
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline PackedList<nBits>::PackedList()
|
inline Foam::PackedList<nBits>::PackedList()
|
||||||
:
|
:
|
||||||
List<unsigned int>(0),
|
List<unsigned int>(0),
|
||||||
size_(0)
|
size_(0)
|
||||||
@ -104,7 +101,7 @@ inline PackedList<nBits>::PackedList()
|
|||||||
|
|
||||||
// Construct with given size.
|
// Construct with given size.
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline PackedList<nBits>::PackedList(const label size)
|
inline Foam::PackedList<nBits>::PackedList(const label size)
|
||||||
:
|
:
|
||||||
List<unsigned int>(intSize(size), 0u),
|
List<unsigned int>(intSize(size), 0u),
|
||||||
size_(size)
|
size_(size)
|
||||||
@ -114,7 +111,7 @@ inline PackedList<nBits>::PackedList(const label size)
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline label PackedList<nBits>::size() const
|
inline Foam::label Foam::PackedList<nBits>::size() const
|
||||||
{
|
{
|
||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
@ -122,7 +119,7 @@ inline label PackedList<nBits>::size() const
|
|||||||
|
|
||||||
// Get value at i
|
// Get value at i
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline unsigned int PackedList<nBits>::get(const label i) const
|
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
||||||
{
|
{
|
||||||
# ifdef DEBUGList
|
# ifdef DEBUGList
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
@ -143,7 +140,7 @@ inline unsigned int PackedList<nBits>::get(const label i) const
|
|||||||
|
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline unsigned int PackedList<nBits>::operator[](const label i) const
|
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
return get(i);
|
return get(i);
|
||||||
}
|
}
|
||||||
@ -151,7 +148,7 @@ inline unsigned int PackedList<nBits>::operator[](const label i) const
|
|||||||
|
|
||||||
// Set value at i
|
// Set value at i
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline bool PackedList<nBits>::set(const label i, const unsigned int val)
|
inline bool Foam::PackedList<nBits>::set(const label i, const unsigned int val)
|
||||||
{
|
{
|
||||||
# ifdef DEBUGList
|
# ifdef DEBUGList
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
@ -170,8 +167,7 @@ inline bool PackedList<nBits>::set(const label i, const unsigned int val)
|
|||||||
|
|
||||||
|
|
||||||
unsigned int shiftedMask = mask << startBit;
|
unsigned int shiftedMask = mask << startBit;
|
||||||
|
unsigned int shiftedVal = val << startBit;
|
||||||
unsigned int shiftedVal = val << startBit;
|
|
||||||
|
|
||||||
unsigned int& elem = List<unsigned int>::operator[](intIndex(i));
|
unsigned int& elem = List<unsigned int>::operator[](intIndex(i));
|
||||||
|
|
||||||
@ -184,14 +180,25 @@ inline bool PackedList<nBits>::set(const label i, const unsigned int val)
|
|||||||
|
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline List<unsigned int>& PackedList<nBits>::storage()
|
inline Foam::List<unsigned int>& Foam::PackedList<nBits>::storage()
|
||||||
{
|
{
|
||||||
return static_cast<List<unsigned int>&>(*this);
|
return static_cast<List<unsigned int>&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline ::Foam::reference PackedList<nBits>::operator[](const label i)
|
inline Foam::xfer<Foam::PackedList<nBits> >
|
||||||
|
Foam::PackedList<nBits>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<PackedList<nBits> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<int nBits>
|
||||||
|
inline Foam::reference Foam::PackedList<nBits>::operator[](const label i)
|
||||||
{
|
{
|
||||||
# ifdef DEBUGList
|
# ifdef DEBUGList
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
@ -215,7 +222,7 @@ inline ::Foam::reference PackedList<nBits>::operator[](const label i)
|
|||||||
|
|
||||||
// Set all to val
|
// Set all to val
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline void PackedList<nBits>::operator=(const unsigned int val)
|
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||||
{
|
{
|
||||||
# ifdef DEBUGList
|
# ifdef DEBUGList
|
||||||
checkValue(val);
|
checkValue(val);
|
||||||
@ -235,10 +242,6 @@ inline void PackedList<nBits>::operator=(const unsigned int val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -175,6 +175,9 @@ public:
|
|||||||
// and annull the argument list.
|
// and annull the argument list.
|
||||||
void transfer(PtrList<T>&);
|
void transfer(PtrList<T>&);
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container
|
||||||
|
inline xfer<PtrList<T> > transfer();
|
||||||
|
|
||||||
//- Is element set
|
//- Is element set
|
||||||
inline bool set(const label) const;
|
inline bool set(const label) const;
|
||||||
|
|
||||||
|
|||||||
@ -29,29 +29,24 @@ License
|
|||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "tmp.H"
|
#include "tmp.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label PtrList<T>::size() const
|
inline Foam::label Foam::PtrList<T>::size() const
|
||||||
{
|
{
|
||||||
return ptrs_.size();
|
return ptrs_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::set(const label i) const
|
inline bool Foam::PtrList<T>::set(const label i) const
|
||||||
{
|
{
|
||||||
return ptrs_[i] != NULL;
|
return ptrs_[i] != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline autoPtr<T> PtrList<T>::set(const label i, T* ptr)
|
inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, T* ptr)
|
||||||
{
|
{
|
||||||
autoPtr<T> old(ptrs_[i]);
|
autoPtr<T> old(ptrs_[i]);
|
||||||
|
|
||||||
@ -62,23 +57,40 @@ inline autoPtr<T> PtrList<T>::set(const label i, T* ptr)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline autoPtr<T> PtrList<T>::set(const label i, const autoPtr<T>& aptr)
|
inline Foam::autoPtr<T> Foam::PtrList<T>::set
|
||||||
|
(
|
||||||
|
const label i,
|
||||||
|
const autoPtr<T>& aptr
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
|
return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline autoPtr<T> PtrList<T>::set(const label i, const tmp<T>& t)
|
inline Foam::autoPtr<T> Foam::PtrList<T>::set
|
||||||
|
(
|
||||||
|
const label i,
|
||||||
|
const tmp<T>& t
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return set(i, const_cast<tmp<T>&>(t).ptr());
|
return set(i, const_cast<tmp<T>&>(t).ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::xfer<Foam::PtrList<T> > Foam::PtrList<T>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<PtrList<T> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const T& PtrList<T>::operator[](const label i) const
|
const T& Foam::PtrList<T>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
if (!ptrs_[i])
|
if (!ptrs_[i])
|
||||||
{
|
{
|
||||||
@ -92,7 +104,7 @@ const T& PtrList<T>::operator[](const label i) const
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T& PtrList<T>::operator[](const label i)
|
T& Foam::PtrList<T>::operator[](const label i)
|
||||||
{
|
{
|
||||||
if (!ptrs_[i])
|
if (!ptrs_[i])
|
||||||
{
|
{
|
||||||
@ -106,7 +118,7 @@ T& PtrList<T>::operator[](const label i)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const T* PtrList<T>::operator()(const label i) const
|
const T* Foam::PtrList<T>::operator()(const label i) const
|
||||||
{
|
{
|
||||||
return ptrs_[i];
|
return ptrs_[i];
|
||||||
}
|
}
|
||||||
@ -115,46 +127,46 @@ const T* PtrList<T>::operator()(const label i) const
|
|||||||
// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline PtrList<T>::iterator::iterator(T** ptr)
|
inline Foam::PtrList<T>::iterator::iterator(T** ptr)
|
||||||
:
|
:
|
||||||
ptr_(ptr)
|
ptr_(ptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::iterator::operator==(const iterator& iter) const
|
inline bool Foam::PtrList<T>::iterator::operator==(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ == iter.ptr_;
|
return ptr_ == iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::iterator::operator!=(const iterator& iter) const
|
inline bool Foam::PtrList<T>::iterator::operator!=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ != iter.ptr_;
|
return ptr_ != iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& PtrList<T>::iterator::operator*()
|
inline T& Foam::PtrList<T>::iterator::operator*()
|
||||||
{
|
{
|
||||||
return **ptr_;
|
return **ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& PtrList<T>::iterator::operator()()
|
inline T& Foam::PtrList<T>::iterator::operator()()
|
||||||
{
|
{
|
||||||
return operator*();
|
return operator*();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
PtrList<T>::iterator::operator++()
|
Foam::PtrList<T>::iterator::operator++()
|
||||||
{
|
{
|
||||||
++ptr_;
|
++ptr_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
PtrList<T>::iterator::operator++(int)
|
Foam::PtrList<T>::iterator::operator++(int)
|
||||||
{
|
{
|
||||||
iterator tmp = *this;
|
iterator tmp = *this;
|
||||||
++ptr_;
|
++ptr_;
|
||||||
@ -162,16 +174,16 @@ PtrList<T>::iterator::operator++(int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
PtrList<T>::iterator::operator--()
|
Foam::PtrList<T>::iterator::operator--()
|
||||||
{
|
{
|
||||||
--ptr_;
|
--ptr_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
PtrList<T>::iterator::operator--(int)
|
Foam::PtrList<T>::iterator::operator--(int)
|
||||||
{
|
{
|
||||||
iterator tmp = *this;
|
iterator tmp = *this;
|
||||||
--ptr_;
|
--ptr_;
|
||||||
@ -179,47 +191,47 @@ PtrList<T>::iterator::operator--(int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
PtrList<T>::iterator::operator+=(label n)
|
Foam::PtrList<T>::iterator::operator+=(label n)
|
||||||
{
|
{
|
||||||
ptr_ += n;
|
ptr_ += n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
operator+(const typename PtrList<T>::iterator& iter, label n)
|
Foam::operator+(const typename PtrList<T>::iterator& iter, label n)
|
||||||
{
|
{
|
||||||
typename PtrList<T>::iterator tmp = iter;
|
typename PtrList<T>::iterator tmp = iter;
|
||||||
return tmp += n;
|
return tmp += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
operator+(label n, const typename PtrList<T>::iterator& iter)
|
Foam::operator+(label n, const typename PtrList<T>::iterator& iter)
|
||||||
{
|
{
|
||||||
typename PtrList<T>::iterator tmp = iter;
|
typename PtrList<T>::iterator tmp = iter;
|
||||||
return tmp += n;
|
return tmp += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
PtrList<T>::iterator::operator-=(label n)
|
Foam::PtrList<T>::iterator::operator-=(label n)
|
||||||
{
|
{
|
||||||
ptr_ -= n;
|
ptr_ -= n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator
|
inline typename Foam::PtrList<T>::iterator
|
||||||
operator-(const typename PtrList<T>::iterator& iter, label n)
|
Foam::operator-(const typename PtrList<T>::iterator& iter, label n)
|
||||||
{
|
{
|
||||||
typename PtrList<T>::iterator tmp = iter;
|
typename PtrList<T>::iterator tmp = iter;
|
||||||
return tmp -= n;
|
return tmp -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label operator-
|
inline Foam::label Foam::operator-
|
||||||
(
|
(
|
||||||
const typename PtrList<T>::iterator& iter1,
|
const typename PtrList<T>::iterator& iter1,
|
||||||
const typename PtrList<T>::iterator& iter2
|
const typename PtrList<T>::iterator& iter2
|
||||||
@ -229,50 +241,49 @@ inline label operator-
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& PtrList<T>::iterator::operator[](label n)
|
inline T& Foam::PtrList<T>::iterator::operator[](label n)
|
||||||
{
|
{
|
||||||
return *(*this + n);
|
return *(*this + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::iterator::operator<(const iterator& iter) const
|
inline bool Foam::PtrList<T>::iterator::operator<(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ < iter.ptr_;
|
return ptr_ < iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::iterator::operator>(const iterator& iter) const
|
inline bool Foam::PtrList<T>::iterator::operator>(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ > iter.ptr_;
|
return ptr_ > iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::iterator::operator<=(const iterator& iter) const
|
inline bool Foam::PtrList<T>::iterator::operator<=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ <= iter.ptr_;
|
return ptr_ <= iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool PtrList<T>::iterator::operator>=(const iterator& iter) const
|
inline bool Foam::PtrList<T>::iterator::operator>=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ >= iter.ptr_;
|
return ptr_ >= iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator PtrList<T>::begin()
|
inline typename Foam::PtrList<T>::iterator
|
||||||
|
Foam::PtrList<T>::begin()
|
||||||
{
|
{
|
||||||
return ptrs_.begin();
|
return ptrs_.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename PtrList<T>::iterator PtrList<T>::end()
|
inline typename Foam::PtrList<T>::iterator
|
||||||
|
Foam::PtrList<T>::end()
|
||||||
{
|
{
|
||||||
return ptrs_.end();
|
return ptrs_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -30,16 +30,11 @@ License
|
|||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "INew.H"
|
#include "INew.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
template<class INew>
|
template<class INew>
|
||||||
void PtrList<T>::read(Istream& is, const INew& inewt)
|
void Foam::PtrList<T>::read(Istream& is, const INew& inewt)
|
||||||
{
|
{
|
||||||
is.fatalCheck("PtrList<T>::read(Istream& is, const INew& inewt)");
|
is.fatalCheck("PtrList<T>::read(Istream& is, const INew& inewt)");
|
||||||
|
|
||||||
@ -155,14 +150,14 @@ void PtrList<T>::read(Istream& is, const INew& inewt)
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
template<class INew>
|
template<class INew>
|
||||||
PtrList<T>::PtrList(Istream& is, const INew& inewt)
|
Foam::PtrList<T>::PtrList(Istream& is, const INew& inewt)
|
||||||
{
|
{
|
||||||
read(is, inewt);
|
read(is, inewt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
PtrList<T>::PtrList(Istream& is)
|
Foam::PtrList<T>::PtrList(Istream& is)
|
||||||
{
|
{
|
||||||
read(is, INew<T>());
|
read(is, INew<T>());
|
||||||
}
|
}
|
||||||
@ -171,7 +166,7 @@ PtrList<T>::PtrList(Istream& is)
|
|||||||
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Istream& operator>>(Istream& is, PtrList<T>& L)
|
Foam::Istream& Foam::operator>>(Istream& is, PtrList<T>& L)
|
||||||
{
|
{
|
||||||
L.clear();
|
L.clear();
|
||||||
L.read(is, INew<T>());
|
L.read(is, INew<T>());
|
||||||
@ -183,21 +178,18 @@ Istream& operator>>(Istream& is, PtrList<T>& L)
|
|||||||
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Ostream& operator<<(Ostream& os, const PtrList<T>& pL)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const PtrList<T>& L)
|
||||||
{
|
{
|
||||||
// Write size of list
|
// Write size of list and start contents delimiter
|
||||||
os << nl << pL.size();
|
os << nl << L.size() << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
// Write beginning of contents
|
|
||||||
os << nl << token::BEGIN_LIST;
|
|
||||||
|
|
||||||
// Write list contents
|
// Write list contents
|
||||||
forAll(pL, i)
|
forAll(L, i)
|
||||||
{
|
{
|
||||||
os << nl << pL[i];
|
os << nl << L[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write end of contents
|
// Write end of contents delimiter
|
||||||
os << nl << token::END_LIST << nl;
|
os << nl << token::END_LIST << nl;
|
||||||
|
|
||||||
// Check state of IOstream
|
// Check state of IOstream
|
||||||
@ -207,8 +199,4 @@ Ostream& operator<<(Ostream& os, const PtrList<T>& pL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -138,6 +138,15 @@ void Foam::SortableList<Type>::reverseSort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
Foam::xfer<Foam::List<Type> > Foam::SortableList<Type>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<List<T> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
|
|||||||
@ -115,6 +115,9 @@ public:
|
|||||||
//- Reverse (stable) sort the list
|
//- Reverse (stable) sort the list
|
||||||
void reverseSort();
|
void reverseSort();
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container as a plain List
|
||||||
|
inline Foam::xfer<List<T> > transfer();
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
//- Assignment of all entries to the given value
|
||||||
|
|||||||
@ -139,6 +139,9 @@ public:
|
|||||||
// UPtrList and annull the argument list.
|
// UPtrList and annull the argument list.
|
||||||
void transfer(UPtrList<T>&);
|
void transfer(UPtrList<T>&);
|
||||||
|
|
||||||
|
//- Transfer the contents to the xfer container
|
||||||
|
inline xfer<UPtrList<T> > transfer();
|
||||||
|
|
||||||
//- Is element set
|
//- Is element set
|
||||||
inline bool set(const label) const;
|
inline bool set(const label) const;
|
||||||
|
|
||||||
|
|||||||
@ -26,40 +26,43 @@ License
|
|||||||
|
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label UPtrList<T>::size() const
|
inline Foam::label Foam::UPtrList<T>::size() const
|
||||||
{
|
{
|
||||||
return ptrs_.size();
|
return ptrs_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::set(const label i) const
|
inline bool Foam::UPtrList<T>::set(const label i) const
|
||||||
{
|
{
|
||||||
return ptrs_[i] != NULL;
|
return ptrs_[i] != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T* UPtrList<T>::set(const label i, T* ptr)
|
inline T* Foam::UPtrList<T>::set(const label i, T* ptr)
|
||||||
{
|
{
|
||||||
T* old = ptrs_[i];
|
T* old = ptrs_[i];
|
||||||
ptrs_[i] = ptr;
|
ptrs_[i] = ptr;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::xfer<Foam::UPtrList<T> > Foam::UPtrList<T>::transfer()
|
||||||
|
{
|
||||||
|
Foam::xfer<UPtrList<T> > xf;
|
||||||
|
xf().transfer(*this);
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const T& UPtrList<T>::operator[](const label i) const
|
const T& Foam::UPtrList<T>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
if (!ptrs_[i])
|
if (!ptrs_[i])
|
||||||
{
|
{
|
||||||
@ -73,7 +76,7 @@ const T& UPtrList<T>::operator[](const label i) const
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T& UPtrList<T>::operator[](const label i)
|
T& Foam::UPtrList<T>::operator[](const label i)
|
||||||
{
|
{
|
||||||
if (!ptrs_[i])
|
if (!ptrs_[i])
|
||||||
{
|
{
|
||||||
@ -87,7 +90,7 @@ T& UPtrList<T>::operator[](const label i)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const T* UPtrList<T>::operator()(const label i) const
|
const T* Foam::UPtrList<T>::operator()(const label i) const
|
||||||
{
|
{
|
||||||
return ptrs_[i];
|
return ptrs_[i];
|
||||||
}
|
}
|
||||||
@ -96,46 +99,46 @@ const T* UPtrList<T>::operator()(const label i) const
|
|||||||
// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline UPtrList<T>::iterator::iterator(T** ptr)
|
inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
|
||||||
:
|
:
|
||||||
ptr_(ptr)
|
ptr_(ptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::iterator::operator==(const iterator& iter) const
|
inline bool Foam::UPtrList<T>::iterator::operator==(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ == iter.ptr_;
|
return ptr_ == iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::iterator::operator!=(const iterator& iter) const
|
inline bool Foam::UPtrList<T>::iterator::operator!=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ != iter.ptr_;
|
return ptr_ != iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& UPtrList<T>::iterator::operator*()
|
inline T& Foam::UPtrList<T>::iterator::operator*()
|
||||||
{
|
{
|
||||||
return **ptr_;
|
return **ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& UPtrList<T>::iterator::operator()()
|
inline T& Foam::UPtrList<T>::iterator::operator()()
|
||||||
{
|
{
|
||||||
return operator*();
|
return operator*();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
UPtrList<T>::iterator::operator++()
|
Foam::UPtrList<T>::iterator::operator++()
|
||||||
{
|
{
|
||||||
++ptr_;
|
++ptr_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
UPtrList<T>::iterator::operator++(int)
|
Foam::UPtrList<T>::iterator::operator++(int)
|
||||||
{
|
{
|
||||||
iterator tmp = *this;
|
iterator tmp = *this;
|
||||||
++ptr_;
|
++ptr_;
|
||||||
@ -143,16 +146,16 @@ UPtrList<T>::iterator::operator++(int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
UPtrList<T>::iterator::operator--()
|
Foam::UPtrList<T>::iterator::operator--()
|
||||||
{
|
{
|
||||||
--ptr_;
|
--ptr_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
UPtrList<T>::iterator::operator--(int)
|
Foam::UPtrList<T>::iterator::operator--(int)
|
||||||
{
|
{
|
||||||
iterator tmp = *this;
|
iterator tmp = *this;
|
||||||
--ptr_;
|
--ptr_;
|
||||||
@ -160,47 +163,47 @@ UPtrList<T>::iterator::operator--(int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
UPtrList<T>::iterator::operator+=(label n)
|
Foam::UPtrList<T>::iterator::operator+=(label n)
|
||||||
{
|
{
|
||||||
ptr_ += n;
|
ptr_ += n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
operator+(const typename UPtrList<T>::iterator& iter, label n)
|
Foam::operator+(const typename UPtrList<T>::iterator& iter, label n)
|
||||||
{
|
{
|
||||||
typename UPtrList<T>::iterator tmp = iter;
|
typename UPtrList<T>::iterator tmp = iter;
|
||||||
return tmp += n;
|
return tmp += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
operator+(label n, const typename UPtrList<T>::iterator& iter)
|
Foam::operator+(label n, const typename UPtrList<T>::iterator& iter)
|
||||||
{
|
{
|
||||||
typename UPtrList<T>::iterator tmp = iter;
|
typename UPtrList<T>::iterator tmp = iter;
|
||||||
return tmp += n;
|
return tmp += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
UPtrList<T>::iterator::operator-=(label n)
|
Foam::UPtrList<T>::iterator::operator-=(label n)
|
||||||
{
|
{
|
||||||
ptr_ -= n;
|
ptr_ -= n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
operator-(const typename UPtrList<T>::iterator& iter, label n)
|
Foam::operator-(const typename UPtrList<T>::iterator& iter, label n)
|
||||||
{
|
{
|
||||||
typename UPtrList<T>::iterator tmp = iter;
|
typename UPtrList<T>::iterator tmp = iter;
|
||||||
return tmp -= n;
|
return tmp -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline label operator-
|
inline Foam::label Foam::operator-
|
||||||
(
|
(
|
||||||
const typename UPtrList<T>::iterator& iter1,
|
const typename UPtrList<T>::iterator& iter1,
|
||||||
const typename UPtrList<T>::iterator& iter2
|
const typename UPtrList<T>::iterator& iter2
|
||||||
@ -210,50 +213,48 @@ inline label operator-
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& UPtrList<T>::iterator::operator[](label n)
|
inline T& Foam::UPtrList<T>::iterator::operator[](label n)
|
||||||
{
|
{
|
||||||
return *(*this + n);
|
return *(*this + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::iterator::operator<(const iterator& iter) const
|
inline bool Foam::UPtrList<T>::iterator::operator<(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ < iter.ptr_;
|
return ptr_ < iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::iterator::operator>(const iterator& iter) const
|
inline bool Foam::UPtrList<T>::iterator::operator>(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ > iter.ptr_;
|
return ptr_ > iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::iterator::operator<=(const iterator& iter) const
|
inline bool Foam::UPtrList<T>::iterator::operator<=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ <= iter.ptr_;
|
return ptr_ <= iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline bool UPtrList<T>::iterator::operator>=(const iterator& iter) const
|
inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
|
||||||
{
|
{
|
||||||
return ptr_ >= iter.ptr_;
|
return ptr_ >= iter.ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator UPtrList<T>::begin()
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
|
Foam::UPtrList<T>::begin()
|
||||||
{
|
{
|
||||||
return ptrs_.begin();
|
return ptrs_.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename UPtrList<T>::iterator UPtrList<T>::end()
|
inline typename Foam::UPtrList<T>::iterator
|
||||||
|
Foam::UPtrList<T>::end()
|
||||||
{
|
{
|
||||||
return ptrs_.end();
|
return ptrs_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,29 +27,21 @@ License
|
|||||||
#include "UPtrList.H"
|
#include "UPtrList.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Ostream& operator<<(Ostream& os, const UPtrList<T>& pL)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const UPtrList<T>& L)
|
||||||
{
|
{
|
||||||
// Write size of list
|
// Write size of list and start contents delimiter
|
||||||
os << nl << pL.size();
|
os << nl << L.size() << nl << token::BEGIN_LIST;
|
||||||
|
|
||||||
// Write beginning of contents
|
|
||||||
os << nl << token::BEGIN_LIST;
|
|
||||||
|
|
||||||
// Write list contents
|
// Write list contents
|
||||||
forAll(pL, i)
|
forAll(L, i)
|
||||||
{
|
{
|
||||||
os << nl << pL[i];
|
os << nl << L[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write end of contents
|
// Write end of contents delimiter
|
||||||
os << nl << token::END_LIST << nl;
|
os << nl << token::END_LIST << nl;
|
||||||
|
|
||||||
// Check state of IOstream
|
// Check state of IOstream
|
||||||
@ -59,8 +51,4 @@ Ostream& operator<<(Ostream& os, const UPtrList<T>& pL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user