LinkedLists cleanup

This commit is contained in:
Mark Olesen
2008-12-17 11:36:04 +01:00
parent 625c75630c
commit d5ac9d4c36
24 changed files with 204 additions and 291 deletions

View File

@ -26,22 +26,17 @@ License
#include "ILList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T>
ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl)
Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst)
:
UILList<LListBase, T>()
{
for
(
typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
iter != slpl.end();
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
@ -53,9 +48,9 @@ ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl)
#ifndef __INTEL_COMPILER
template<class LListBase, class T>
template<class CloneArg>
ILList<LListBase, T>::ILList
Foam::ILList<LListBase, T>::ILList
(
const ILList<LListBase, T>& slpl,
const ILList<LListBase, T>& lst,
const CloneArg& cloneArg
)
:
@ -63,8 +58,8 @@ ILList<LListBase, T>::ILList
{
for
(
typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
iter != slpl.end();
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
@ -77,7 +72,7 @@ ILList<LListBase, T>::ILList
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
template<class LListBase, class T>
ILList<LListBase, T>::~ILList()
Foam::ILList<LListBase, T>::~ILList()
{
this->clear();
}
@ -85,9 +80,8 @@ ILList<LListBase, T>::~ILList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return and remove head
template<class LListBase, class T>
bool ILList<LListBase, T>::eraseHead()
bool Foam::ILList<LListBase, T>::eraseHead()
{
T* tPtr;
if ((tPtr = this->removeHead()))
@ -101,9 +95,8 @@ bool ILList<LListBase, T>::eraseHead()
}
}
//- Return and remove element
template<class LListBase, class T>
bool ILList<LListBase, T>::erase(T* p)
bool Foam::ILList<LListBase, T>::erase(T* p)
{
T* tPtr;
if ((tPtr = remove(p)))
@ -119,7 +112,7 @@ bool ILList<LListBase, T>::erase(T* p)
template<class LListBase, class T>
void ILList<LListBase, T>::clear()
void Foam::ILList<LListBase, T>::clear()
{
label oldSize = this->size();
for (label i=0; i<oldSize; i++)
@ -134,14 +127,14 @@ void ILList<LListBase, T>::clear()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T>
void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl)
void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst)
{
this->clear();
for
(
typename UILList<LListBase, T>::const_iterator iter = slpl.begin();
iter != slpl.end();
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
@ -149,11 +142,6 @@ void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl)
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#include "ILListIO.C"

View File

@ -71,7 +71,7 @@ class ILList
//- Read from Istream using given Istream constructor class
template<class INew>
void read(Istream&, const INew& inewt);
void read(Istream&, const INew&);
public:
@ -96,7 +96,7 @@ public:
//- Copy constructor with additional argument for clone
template<class CloneArg>
ILList(const ILList<LListBase, T>& slpl, const CloneArg& cloneArg)
ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg)
#ifdef __INTEL_COMPILER
:
UILList<LListBase, T>()
@ -104,8 +104,8 @@ public:
for
(
typename UILList<LListBase, T>::const_iterator iter =
slpl.begin();
iter != slpl.end();
lst.begin();
iter != lst.end();
++iter
)
{
@ -118,7 +118,7 @@ public:
//- Construct from Istream using given Istream constructor class
template<class INew>
ILList(Istream&, const INew& inewt);
ILList(Istream&, const INew&);
// Destructor

View File

@ -30,24 +30,19 @@ Description
#include "Istream.H"
#include "INew.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T>
template<class INew>
void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew)
{
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
token firstToken(is);
is.fatalCheck
(
"operator>>(Istream& is, ILList<LListBase, T>& L) : reading first token"
"operator>>(Istream&, ILList<LListBase, T>&) : reading first token"
);
if (firstToken.isLabel())
@ -63,26 +58,26 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
{
for (label i=0; i<s; i++)
{
append(inewt(is).ptr());
append(iNew(is).ptr());
is.fatalCheck
(
"operator>>(Istream& is, ILList<LListBase, T>& L) : "
"operator>>(Istream&, ILList<LListBase, T>&) : "
"reading entry"
);
}
}
else
{
T* tPtr = inewt(is).ptr();
T* tPtr = iNew(is).ptr();
append(tPtr);
is.fatalCheck
(
"operator>>(Istream& is, ILList<LListBase, T>& L) : "
"operator>>(Istream&, ILList<LListBase, T>&) : "
"reading entry"
);
for (label i=1; i<s; i++)
{
append(new T(*tPtr));
@ -99,14 +94,14 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
{
FatalIOErrorIn
(
"operator>>(Istream& is, ILList<LListBase, T>& L)",
"operator>>(Istream&, ILList<LListBase, T>&)",
is
) << "incorrect first token, '(', found " << firstToken.info()
<< exit(FatalIOError);
}
token lastToken(is);
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
while
(
@ -117,36 +112,34 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt)
)
{
is.putBack(lastToken);
append(inewt(is).ptr());
append(iNew(is).ptr());
is >> lastToken;
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
}
}
else
{
FatalIOErrorIn("operator>>(Istream& is, ILList<LListBase, T>& L)", is)
FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is)
<< "incorrect first token, expected <int> or '(', found "
<< firstToken.info()
<< exit(FatalIOError);
}
is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)");
is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)");
}
//- Construct from Istream using given Istream constructor class
template<class LListBase, class T>
template<class INew>
ILList<LListBase, T>::ILList(Istream& is, const INew& inewt)
Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew)
{
read(is, inewt);
read(is, iNew);
}
// Construct from Istream
template<class LListBase, class T>
ILList<LListBase, T>::ILList(Istream& is)
Foam::ILList<LListBase, T>::ILList(Istream& is)
{
read(is, INew<T>());
}
@ -155,7 +148,7 @@ ILList<LListBase, T>::ILList(Istream& is)
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
template<class LListBase, class T>
Istream& operator>>(Istream& is, ILList<LListBase, T>& L)
Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L)
{
L.clear();
L.read(is, INew<T>());
@ -166,6 +159,4 @@ Istream& operator>>(Istream& is, ILList<LListBase, T>& L)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -27,22 +27,16 @@ Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "LList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T>
LList<LListBase, T>::LList(const LList<LListBase, T>& slpl)
Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst)
:
LListBase()
{
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{
append(iter());
}
@ -50,7 +44,7 @@ LList<LListBase, T>::LList(const LList<LListBase, T>& slpl)
template<class LListBase, class T>
LList<LListBase, T>::~LList()
Foam::LList<LListBase, T>::~LList()
{
this->clear();
}
@ -59,7 +53,7 @@ LList<LListBase, T>::~LList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class LListBase, class T>
void LList<LListBase, T>::clear()
void Foam::LList<LListBase, T>::clear()
{
label oldSize = this->size();
for (label i=0; i<oldSize; i++)
@ -74,21 +68,17 @@ void LList<LListBase, T>::clear()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T>
void LList<LListBase, T>::operator=(const LList<LListBase, T>& slpl)
void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst)
{
this->clear();
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{
append(iter());
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#include "LListIO.C"

View File

@ -67,7 +67,7 @@ Ostream& operator<<
/*---------------------------------------------------------------------------*\
Class LList Declaration
Class LList Declaration
\*---------------------------------------------------------------------------*/
template<class LListBase, class T>

View File

@ -30,16 +30,10 @@ Description
#include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from Istream
template<class LListBase, class T>
LList<LListBase, T>::LList(Istream& is)
Foam::LList<LListBase, T>::LList(Istream& is)
{
operator>>(is, *this);
}
@ -48,18 +42,18 @@ LList<LListBase, T>::LList(Istream& is)
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
template<class LListBase, class T>
Istream& operator>>(Istream& is, LList<LListBase, T>& L)
Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L)
{
// Anull list
L.clear();
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
token firstToken(is);
is.fatalCheck
(
" operator>>(Istream& is, LList<LListBase, T>& L) : reading first token"
" operator>>(Istream&, LList<LListBase, T>&) : reading first token"
);
if (firstToken.isLabel())
@ -101,14 +95,14 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L)
{
FatalIOErrorIn
(
" operator>>(Istream& is, LList<LListBase, T>& L)",
" operator>>(Istream&, LList<LListBase, T>&)",
is
) << "incorrect first token, '(', found " << firstToken.info()
<< exit(FatalIOError);
}
token lastToken(is);
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
while
(
@ -124,19 +118,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L)
L.append(element);
is >> lastToken;
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)");
}
}
else
{
FatalIOErrorIn(" operator>>(Istream& is, LList<LListBase, T>& L)", is)
FatalIOErrorIn(" operator>>(Istream&, LList<LListBase, T>&)", is)
<< "incorrect first token, expected <int> or '(', found "
<< firstToken.info()
<< exit(FatalIOError);
}
// Check state of IOstream
is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)");
is.fatalCheck(" operator>>(Istream&, LList<LListBase,>&)");
return is;
}
@ -145,19 +139,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L)
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class LListBase, class T>
Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll)
Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst)
{
// Write size of LList
os << nl << ll.size();
// Write size
os << nl << lst.size();
// Write beginning of contents
os << nl << token::BEGIN_LIST << nl;
// Write LList contents
// Write contents
for
(
typename LList<LListBase, T>::const_iterator iter = ll.begin();
iter != ll.end();
typename LList<LListBase, T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
@ -168,14 +162,10 @@ Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll)
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const LList&)");
os.check("Ostream& operator<<(Ostream&, const LList<LListBase, T>&)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -34,11 +34,11 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T>
LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl)
LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst)
:
LList<LListBase, T*>()
{
for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{
append(iter().clone().ptr());
}
@ -89,11 +89,11 @@ void LPtrList<LListBase, T>::clear()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T>
void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& slpl)
void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst)
{
clear();
for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{
append(iter().clone().ptr());
}

View File

@ -29,16 +29,11 @@ License
#include "Ostream.H"
#include "INew.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class LListBase, class T>
template<class INew>
void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew)
{
is.fatalCheck
(
@ -66,8 +61,8 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
{
for (label i=0; i<s; i++)
{
append(inewt(is).ptr());
append(iNew(is).ptr());
is.fatalCheck
(
"LPtrList<LListBase, T>::read(Istream&, const INew&) : "
@ -77,7 +72,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
}
else
{
T* tPtr = inewt(is).ptr();
T* tPtr = iNew(is).ptr();
append(tPtr);
is.fatalCheck
@ -85,7 +80,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
"LPtrList<LListBase, T>::read(Istream&, const INew&) : "
"reading entry"
);
for (label i=1; i<s; i++)
{
append(tPtr->clone().ptr());
@ -120,7 +115,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
)
{
is.putBack(lastToken);
append(inewt(is).ptr());
append(iNew(is).ptr());
is >> lastToken;
is.fatalCheck
@ -148,14 +143,14 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt)
template<class LListBase, class T>
template<class INew>
LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& inewt)
Foam::LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& iNew)
{
read(is, inewt);
read(is, iNew);
}
template<class LListBase, class T>
LPtrList<LListBase, T>::LPtrList(Istream& is)
Foam::LPtrList<LListBase, T>::LPtrList(Istream& is)
{
read(is, INew<T>());
}
@ -164,11 +159,10 @@ LPtrList<LListBase, T>::LPtrList(Istream& is)
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
template<class LListBase, class T>
Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L)
Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& L)
{
// Anull list
L.clear();
L.read(is, INew<T>());
return is;
}
@ -177,19 +171,19 @@ Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L)
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
template<class LListBase, class T>
Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl)
Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList<LListBase, T>& lst)
{
// Write size of LPtrList
os << nl << slpl.size();
// Write size
os << nl << lst.size();
// Write beginning of contents
os << nl << token::BEGIN_LIST << nl;
// Write LPtrList contents
// Write contents
for
(
typename LPtrList<LListBase, T>::const_iterator iter = slpl.begin();
iter != slpl.end();
typename LPtrList<LListBase, T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
@ -200,14 +194,9 @@ Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl)
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const LPtrList&)");
os.check("Ostream& operator<<(Ostream&, const LPtrList<LListBase, T>&)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -28,17 +28,12 @@ Description
#include "UILList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class LListBase, class T>
UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl)
Foam::UILList<LListBase, T>::UILList(const UILList<LListBase, T>& lst)
{
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
{
append(&iter());
}
@ -48,22 +43,24 @@ UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class LListBase, class T>
void UILList<LListBase, T>::operator=(const UILList<LListBase, T>& slpl)
void Foam::UILList<LListBase, T>::operator=(const UILList<LListBase, T>& rhs)
{
LListBase::clear();
for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter)
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
{
append(&iter());
}
}
// Comparison for equality
template<class LListBase, class T>
bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const
bool Foam::UILList<LListBase, T>::operator==
(
const UILList<LListBase, T>& rhs
) const
{
if (this->size() != slpl.size())
if (this->size() != rhs.size())
{
return false;
}
@ -71,7 +68,7 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const
bool equal = true;
const_iterator iter1 = this->begin();
const_iterator iter2 = slpl.begin();
const_iterator iter2 = rhs.begin();
for (; iter1 != this->end(); ++iter1, ++iter2)
{
@ -84,16 +81,15 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const
// Comparison for inequality
template<class LListBase, class T>
bool UILList<LListBase, T>::operator!=(const UILList<LListBase, T>& slpl) const
bool Foam::UILList<LListBase, T>::operator!=
(
const UILList<LListBase, T>& rhs
) const
{
return !operator==(slpl);
return !operator==(rhs);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#include "UILListIO.C"

View File

@ -245,7 +245,7 @@ public:
const T& operator*()
{
return
return
static_cast<const T&>
(LListBase_const_iterator::operator*());
}
@ -266,7 +266,7 @@ public:
// STL member operators
//- Equality operation on ULists of the same type.
// Returns true when the ULists are elementwise equal
// Returns true when the ULists are element-wise equal
// (using UList::value_type::operator==). Takes linear time.
bool operator==(const UILList<LListBase, T>&) const;

View File

@ -30,27 +30,22 @@ Description
#include "Ostream.H"
#include "token.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class LListBase, class T>
Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill)
Foam::Ostream& Foam::operator<<(Ostream& os, const UILList<LListBase, T>& lst)
{
// Write size of UILList
os << nl << ill.size();
// Write size
os << nl << lst.size();
// Write beginning of contents
os << nl << token::BEGIN_LIST << nl;
// Write UILList contents
// Write contents
for
(
typename UILList<LListBase, T>::const_iterator iter = ill.begin();
iter != ill.end();
typename UILList<LListBase, T>::const_iterator iter = lst.begin();
iter != lst.end();
++iter
)
{
@ -61,14 +56,9 @@ Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill)
os << token::END_LIST;
// Check state of IOstream
os.check("Ostream& operator<<(Ostream&, const UILList&)");
os.check("Ostream& operator<<(Ostream&, const UILList<LListBase, T>&)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -32,17 +32,12 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
DLListBase::iterator DLListBase::endIter
Foam::DLListBase::iterator Foam::DLListBase::endIter
(
const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase()))
);
DLListBase::const_iterator DLListBase::endConstIter
Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter
(
static_cast<const DLListBase&>(DLListBase()),
reinterpret_cast<const link*>(NULL)
@ -51,7 +46,7 @@ DLListBase::const_iterator DLListBase::endConstIter
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void DLListBase::insert(DLListBase::link* a)
void Foam::DLListBase::insert(DLListBase::link* a)
{
nElmts_++;
@ -71,7 +66,7 @@ void DLListBase::insert(DLListBase::link* a)
}
void DLListBase::append(DLListBase::link* a)
void Foam::DLListBase::append(DLListBase::link* a)
{
nElmts_++;
@ -91,7 +86,7 @@ void DLListBase::append(DLListBase::link* a)
}
bool DLListBase::swapUp(DLListBase::link* a)
bool Foam::DLListBase::swapUp(DLListBase::link* a)
{
if (first_ != a)
{
@ -132,7 +127,7 @@ bool DLListBase::swapUp(DLListBase::link* a)
}
bool DLListBase::swapDown(DLListBase::link* a)
bool Foam::DLListBase::swapDown(DLListBase::link* a)
{
if (last_ != a)
{
@ -173,7 +168,7 @@ bool DLListBase::swapDown(DLListBase::link* a)
}
DLListBase::link* DLListBase::removeHead()
Foam::DLListBase::link* Foam::DLListBase::removeHead()
{
nElmts_--;
@ -197,7 +192,7 @@ DLListBase::link* DLListBase::removeHead()
}
DLListBase::link* DLListBase::remove(DLListBase::link* l)
Foam::DLListBase::link* Foam::DLListBase::remove(DLListBase::link* l)
{
nElmts_--;
@ -229,7 +224,7 @@ DLListBase::link* DLListBase::remove(DLListBase::link* l)
}
DLListBase::link* DLListBase::replace
Foam::DLListBase::link* Foam::DLListBase::replace
(
DLListBase::link* oldLink,
DLListBase::link* newLink
@ -266,8 +261,4 @@ DLListBase::link* DLListBase::replace
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -26,21 +26,16 @@ License
#include "error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
inline DLListBase::link::link()
inline Foam::DLListBase::link::link()
:
prev_(0),
next_(0)
{}
inline DLListBase::DLListBase()
inline Foam::DLListBase::DLListBase()
:
first_(0),
last_(0),
@ -48,7 +43,7 @@ inline DLListBase::DLListBase()
{}
inline DLListBase::DLListBase(link* a)
inline Foam::DLListBase::DLListBase(link* a)
:
first_(a),
last_(a),
@ -61,32 +56,32 @@ inline DLListBase::DLListBase(link* a)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
inline DLListBase::~DLListBase()
inline Foam::DLListBase::~DLListBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool DLListBase::link::registered() const
inline bool Foam::DLListBase::link::registered() const
{
return prev_ != 0 && next_ != 0;
}
inline void DLListBase::link::deregister()
inline void Foam::DLListBase::link::deregister()
{
prev_ = 0;
next_ = 0;
}
inline label DLListBase::size() const
inline Foam::label Foam::DLListBase::size() const
{
return nElmts_;
}
inline DLListBase::link* DLListBase::first()
inline Foam::DLListBase::link* Foam::DLListBase::first()
{
if (!nElmts_)
{
@ -98,7 +93,7 @@ inline DLListBase::link* DLListBase::first()
}
inline const DLListBase::link* DLListBase::first() const
inline const Foam::DLListBase::link* Foam::DLListBase::first() const
{
if (!nElmts_)
{
@ -110,7 +105,7 @@ inline const DLListBase::link* DLListBase::first() const
}
inline DLListBase::link* DLListBase::last()
inline Foam::DLListBase::link* Foam::DLListBase::last()
{
if (!nElmts_)
{
@ -122,7 +117,7 @@ inline DLListBase::link* DLListBase::last()
}
inline const DLListBase::link* DLListBase::last() const
inline const Foam::DLListBase::link* Foam::DLListBase::last() const
{
if (!nElmts_)
{
@ -134,7 +129,7 @@ inline const DLListBase::link* DLListBase::last() const
}
inline void DLListBase::clear()
inline void Foam::DLListBase::clear()
{
nElmts_ = 0;
first_ = 0;
@ -142,13 +137,16 @@ inline void DLListBase::clear()
}
inline DLListBase::link* DLListBase::remove(DLListBase::iterator& it)
inline Foam::DLListBase::link* Foam::DLListBase::remove
(
DLListBase::iterator& it
)
{
return remove(it.curElmt_);
}
inline DLListBase::link* DLListBase::replace
inline Foam::DLListBase::link* Foam::DLListBase::replace
(
DLListBase::iterator& oldIter,
DLListBase::link* newLink
@ -160,7 +158,7 @@ inline DLListBase::link* DLListBase::replace
// * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * //
inline DLListBase::iterator::iterator(DLListBase& s, link* elmt)
inline Foam::DLListBase::iterator::iterator(DLListBase& s, link* elmt)
:
curList_(s),
curElmt_(elmt),
@ -168,7 +166,7 @@ inline DLListBase::iterator::iterator(DLListBase& s, link* elmt)
{}
inline DLListBase::iterator::iterator(DLListBase& s)
inline Foam::DLListBase::iterator::iterator(DLListBase& s)
:
curList_(s),
curElmt_(NULL),
@ -176,32 +174,32 @@ inline DLListBase::iterator::iterator(DLListBase& s)
{}
inline void DLListBase::iterator::operator=(const iterator& iter)
inline void Foam::DLListBase::iterator::operator=(const iterator& iter)
{
curElmt_ = iter.curElmt_;
curLink_ = iter.curLink_;
}
inline bool DLListBase::iterator::operator==(const iterator& iter) const
inline bool Foam::DLListBase::iterator::operator==(const iterator& iter) const
{
return curElmt_ == iter.curElmt_;
}
inline bool DLListBase::iterator::operator!=(const iterator& iter) const
inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const
{
return curElmt_ != iter.curElmt_;
}
inline DLListBase::link& DLListBase::iterator::operator*()
inline Foam::DLListBase::link& Foam::DLListBase::iterator::operator*()
{
return *curElmt_;
}
inline DLListBase::iterator& DLListBase::iterator::operator++()
inline Foam::DLListBase::iterator& Foam::DLListBase::iterator::operator++()
{
// Check if the curElmt_ is the last element (if it points to itself)
// or if the list is empty because the last element may have been removed
@ -219,7 +217,7 @@ inline DLListBase::iterator& DLListBase::iterator::operator++()
}
inline DLListBase::iterator DLListBase::iterator::operator++(int)
inline Foam::DLListBase::iterator Foam::DLListBase::iterator::operator++(int)
{
iterator tmp = *this;
++*this;
@ -227,7 +225,7 @@ inline DLListBase::iterator DLListBase::iterator::operator++(int)
}
inline DLListBase::iterator DLListBase::begin()
inline Foam::DLListBase::iterator Foam::DLListBase::begin()
{
if (size())
{
@ -240,7 +238,7 @@ inline DLListBase::iterator DLListBase::begin()
}
inline const DLListBase::iterator& DLListBase::end()
inline const Foam::DLListBase::iterator& Foam::DLListBase::end()
{
return endIter;
}
@ -248,7 +246,7 @@ inline const DLListBase::iterator& DLListBase::end()
// * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * //
inline DLListBase::const_iterator::const_iterator
inline Foam::DLListBase::const_iterator::const_iterator
(
const DLListBase& s,
const link* elmt
@ -259,20 +257,23 @@ inline DLListBase::const_iterator::const_iterator
{}
inline DLListBase::const_iterator::const_iterator(const iterator& iter)
inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter)
:
curList_(iter.curList_),
curElmt_(iter.curElmt_)
{}
inline void DLListBase::const_iterator::operator=(const const_iterator& iter)
inline void Foam::DLListBase::const_iterator::operator=
(
const const_iterator& iter
)
{
curElmt_ = iter.curElmt_;
}
inline bool DLListBase::const_iterator::operator==
inline bool Foam::DLListBase::const_iterator::operator==
(
const const_iterator& iter
) const
@ -281,7 +282,7 @@ inline bool DLListBase::const_iterator::operator==
}
inline bool DLListBase::const_iterator::operator!=
inline bool Foam::DLListBase::const_iterator::operator!=
(
const const_iterator& iter
) const
@ -290,13 +291,14 @@ inline bool DLListBase::const_iterator::operator!=
}
inline const DLListBase::link& DLListBase::const_iterator::operator*()
inline const Foam::DLListBase::link& DLListBase::const_iterator::operator*()
{
return *curElmt_;
}
inline DLListBase::const_iterator& DLListBase::const_iterator::operator++()
inline Foam::DLListBase::const_iterator&
Foam::DLListBase::const_iterator::operator++()
{
if (curElmt_ == curList_.last_)
{
@ -311,7 +313,8 @@ inline DLListBase::const_iterator& DLListBase::const_iterator::operator++()
}
inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int)
inline Foam::DLListBase::const_iterator
Foam::DLListBase::const_iterator::operator++(int)
{
const_iterator tmp = *this;
++*this;
@ -319,7 +322,7 @@ inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int)
}
inline DLListBase::const_iterator DLListBase::begin() const
inline Foam::DLListBase::const_iterator Foam::DLListBase::begin() const
{
if (size())
{
@ -332,14 +335,10 @@ inline DLListBase::const_iterator DLListBase::begin() const
}
inline const DLListBase::const_iterator& DLListBase::end() const
inline const Foam::DLListBase::const_iterator& Foam::DLListBase::end() const
{
return endConstIter;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -25,22 +25,16 @@ License
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "SLListBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
SLListBase::iterator SLListBase::endIter
Foam::SLListBase::iterator Foam::SLListBase::endIter
(
const_cast<SLListBase&>(static_cast<const SLListBase&>(SLListBase()))
);
SLListBase::const_iterator SLListBase::endConstIter
Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter
(
static_cast<const SLListBase&>(SLListBase()),
reinterpret_cast<const link*>(NULL)
@ -49,7 +43,7 @@ SLListBase::const_iterator SLListBase::endConstIter
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void SLListBase::insert(SLListBase::link* a)
void Foam::SLListBase::insert(SLListBase::link* a)
{
nElmts_++;
@ -66,7 +60,7 @@ void SLListBase::insert(SLListBase::link* a)
}
void SLListBase::append(SLListBase::link* a)
void Foam::SLListBase::append(SLListBase::link* a)
{
nElmts_++;
@ -82,7 +76,7 @@ void SLListBase::append(SLListBase::link* a)
}
SLListBase::link* SLListBase::removeHead()
Foam::SLListBase::link* Foam::SLListBase::removeHead()
{
nElmts_--;
@ -108,7 +102,7 @@ SLListBase::link* SLListBase::removeHead()
}
SLListBase::link* SLListBase::remove(SLListBase::link* it)
Foam::SLListBase::link* Foam::SLListBase::remove(SLListBase::link* it)
{
SLListBase::iterator iter = begin();
SLListBase::link *prev = &(*iter);
@ -143,8 +137,4 @@ SLListBase::link* SLListBase::remove(SLListBase::link* it)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -29,33 +29,28 @@ Description
#include "error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
inline SLListBase::link::link()
inline Foam::SLListBase::link::link()
:
next_(0)
{}
inline SLListBase::link::link(link* p)
inline Foam::SLListBase::link::link(link* p)
:
next_(p)
{}
inline SLListBase::SLListBase()
inline Foam::SLListBase::SLListBase()
:
last_(0),
nElmts_(0)
{}
inline SLListBase::SLListBase(link* a)
inline Foam::SLListBase::SLListBase(link* a)
:
last_(a->next_ = a),
nElmts_(1)
@ -64,19 +59,19 @@ inline SLListBase::SLListBase(link* a)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
inline SLListBase::~SLListBase()
inline Foam::SLListBase::~SLListBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline label SLListBase::size() const
inline Foam::label Foam::SLListBase::size() const
{
return nElmts_;
}
inline SLListBase::link* SLListBase::first()
inline Foam::SLListBase::link* Foam::SLListBase::first()
{
if (!nElmts_)
{
@ -88,7 +83,7 @@ inline SLListBase::link* SLListBase::first()
}
inline const SLListBase::link* SLListBase::first() const
inline const Foam::SLListBase::link* Foam::SLListBase::first() const
{
if (!nElmts_)
{
@ -100,7 +95,7 @@ inline const SLListBase::link* SLListBase::first() const
}
inline SLListBase::link* SLListBase::last()
inline Foam::SLListBase::link* Foam::SLListBase::last()
{
if (!nElmts_)
{
@ -112,7 +107,7 @@ inline SLListBase::link* SLListBase::last()
}
inline const SLListBase::link* SLListBase::last() const
inline const Foam::SLListBase::link* Foam::SLListBase::last() const
{
if (!nElmts_)
{
@ -124,14 +119,17 @@ inline const SLListBase::link* SLListBase::last() const
}
inline void SLListBase::clear()
inline void Foam::SLListBase::clear()
{
nElmts_ = 0;
last_ = 0;
}
inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it)
inline Foam::SLListBase::link* Foam::SLListBase::remove
(
SLListBase::iterator& it
)
{
return remove(it.curElmt_);
}
@ -139,7 +137,7 @@ inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it)
// * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * //
inline SLListBase::iterator::iterator(SLListBase& s, link* elmt)
inline Foam::SLListBase::iterator::iterator(SLListBase& s, link* elmt)
:
curList_(s),
curElmt_(elmt),
@ -147,7 +145,7 @@ inline SLListBase::iterator::iterator(SLListBase& s, link* elmt)
{}
inline SLListBase::iterator::iterator(SLListBase& s)
inline Foam::SLListBase::iterator::iterator(SLListBase& s)
:
curList_(s),
curElmt_(NULL),
@ -155,32 +153,32 @@ inline SLListBase::iterator::iterator(SLListBase& s)
{}
inline void SLListBase::iterator::operator=(const iterator& iter)
inline void Foam::SLListBase::iterator::operator=(const iterator& iter)
{
curElmt_ = iter.curElmt_;
curLink_ = iter.curLink_;
}
inline bool SLListBase::iterator::operator==(const iterator& iter) const
inline bool Foam::SLListBase::iterator::operator==(const iterator& iter) const
{
return curElmt_ == iter.curElmt_;
}
inline bool SLListBase::iterator::operator!=(const iterator& iter) const
inline bool Foam::SLListBase::iterator::operator!=(const iterator& iter) const
{
return curElmt_ != iter.curElmt_;
}
inline SLListBase::link& SLListBase::iterator::operator*()
inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*()
{
return *curElmt_;
}
inline SLListBase::iterator& SLListBase::iterator::operator++()
inline Foam::SLListBase::iterator& Foam::SLListBase::iterator::operator++()
{
if (curElmt_ == curList_.last_ || curList_.last_ == 0)
{
@ -196,7 +194,7 @@ inline SLListBase::iterator& SLListBase::iterator::operator++()
}
inline SLListBase::iterator SLListBase::iterator::operator++(int)
inline Foam::SLListBase::iterator Foam::SLListBase::iterator::operator++(int)
{
iterator tmp = *this;
++*this;
@ -204,7 +202,7 @@ inline SLListBase::iterator SLListBase::iterator::operator++(int)
}
inline SLListBase::iterator SLListBase::begin()
inline Foam::SLListBase::iterator Foam::SLListBase::begin()
{
if (size())
{
@ -217,7 +215,7 @@ inline SLListBase::iterator SLListBase::begin()
}
inline const SLListBase::iterator& SLListBase::end()
inline const Foam::SLListBase::iterator& Foam::SLListBase::end()
{
return endIter;
}
@ -225,7 +223,7 @@ inline const SLListBase::iterator& SLListBase::end()
// * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * //
inline SLListBase::const_iterator::const_iterator
inline Foam::SLListBase::const_iterator::const_iterator
(
const SLListBase& s,
const link* elmt
@ -236,20 +234,23 @@ inline SLListBase::const_iterator::const_iterator
{}
inline SLListBase::const_iterator::const_iterator(const iterator& iter)
inline Foam::SLListBase::const_iterator::const_iterator(const iterator& iter)
:
curList_(iter.curList_),
curElmt_(iter.curElmt_)
{}
inline void SLListBase::const_iterator::operator=(const const_iterator& iter)
inline void Foam::SLListBase::const_iterator::operator=
(
const const_iterator& iter
)
{
curElmt_ = iter.curElmt_;
}
inline bool SLListBase::const_iterator::operator==
inline bool Foam::SLListBase::const_iterator::operator==
(
const const_iterator& iter
) const
@ -258,7 +259,7 @@ inline bool SLListBase::const_iterator::operator==
}
inline bool SLListBase::const_iterator::operator!=
inline bool Foam::SLListBase::const_iterator::operator!=
(
const const_iterator& iter
) const
@ -267,13 +268,14 @@ inline bool SLListBase::const_iterator::operator!=
}
inline const SLListBase::link& SLListBase::const_iterator::operator*()
inline const Foam::SLListBase::link& SLListBase::const_iterator::operator*()
{
return *curElmt_;
}
inline SLListBase::const_iterator& SLListBase::const_iterator::operator++()
inline Foam::SLListBase::const_iterator&
Foam::SLListBase::const_iterator::operator++()
{
if (curElmt_ == curList_.last_)
{
@ -288,7 +290,8 @@ inline SLListBase::const_iterator& SLListBase::const_iterator::operator++()
}
inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int)
inline Foam::SLListBase::const_iterator
Foam::SLListBase::const_iterator::operator++(int)
{
const_iterator tmp = *this;
++*this;
@ -296,7 +299,7 @@ inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int)
}
inline SLListBase::const_iterator SLListBase::begin() const
inline Foam::SLListBase::const_iterator Foam::SLListBase::begin() const
{
if (size())
{
@ -309,14 +312,10 @@ inline SLListBase::const_iterator SLListBase::begin() const
}
inline const SLListBase::const_iterator& SLListBase::end() const
inline const Foam::SLListBase::const_iterator& Foam::SLListBase::end() const
{
return endConstIter;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //