mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
LList, SLList: Added construction from and assignment to initializer_list
SLList: now a C++11 template alias rather than a wrapper-class.
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -39,7 +39,8 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SLList<scalar> myList;
|
SLList<scalar> myList{2.1, 3.4};
|
||||||
|
myList = {2.1, 3.4, 4.3};
|
||||||
|
|
||||||
for (int i = 0; i<10; i++)
|
for (int i = 0; i<10; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,7 +23,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
#include "LList.H"
|
#include "LList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -33,9 +32,21 @@ Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst)
|
|||||||
:
|
:
|
||||||
LListBase()
|
LListBase()
|
||||||
{
|
{
|
||||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
for (const T& val : lst)
|
||||||
{
|
{
|
||||||
this->append(iter());
|
this->append(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class LListBase, class T>
|
||||||
|
Foam::LList<LListBase, T>::LList(std::initializer_list<T> lst)
|
||||||
|
:
|
||||||
|
LListBase()
|
||||||
|
{
|
||||||
|
for (const T& val : lst)
|
||||||
|
{
|
||||||
|
this->append(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +88,21 @@ void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst)
|
|||||||
{
|
{
|
||||||
this->clear();
|
this->clear();
|
||||||
|
|
||||||
for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter)
|
for (const T& val : lst)
|
||||||
{
|
{
|
||||||
this->append(iter());
|
this->append(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class LListBase, class T>
|
||||||
|
void Foam::LList<LListBase, T>::operator=(std::initializer_list<T> lst)
|
||||||
|
{
|
||||||
|
this->clear();
|
||||||
|
|
||||||
|
for (const T& val : lst)
|
||||||
|
{
|
||||||
|
this->append(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,5 +111,4 @@ void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst)
|
|||||||
|
|
||||||
#include "LListIO.C"
|
#include "LListIO.C"
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -37,7 +37,7 @@ SourceFiles
|
|||||||
#define LList_H
|
#define LList_H
|
||||||
|
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
#include "uLabel.H"
|
#include <initializer_list>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -121,6 +121,9 @@ public:
|
|||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
LList(const LList<LListBase, T>&);
|
LList(const LList<LListBase, T>&);
|
||||||
|
|
||||||
|
//- Construct from an initializer list
|
||||||
|
LList(std::initializer_list<T>);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~LList();
|
~LList();
|
||||||
@ -206,8 +209,12 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
|
//- Assignment operator
|
||||||
void operator=(const LList<LListBase, T>&);
|
void operator=(const LList<LListBase, T>&);
|
||||||
|
|
||||||
|
//- Assignment to an initializer list
|
||||||
|
void operator=(std::initializer_list<T>);
|
||||||
|
|
||||||
|
|
||||||
// STL type definitions
|
// STL type definitions
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -144,14 +144,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst)
|
|||||||
os << nl << token::BEGIN_LIST << nl;
|
os << nl << token::BEGIN_LIST << nl;
|
||||||
|
|
||||||
// Write contents
|
// Write contents
|
||||||
for
|
for (const T& val : lst)
|
||||||
(
|
|
||||||
typename LList<LListBase, T>::const_iterator iter = lst.begin();
|
|
||||||
iter != lst.end();
|
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
os << iter() << nl;
|
os << val << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write end of contents
|
// Write end of contents
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -21,7 +21,7 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Alias
|
||||||
Foam::SLList
|
Foam::SLList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
@ -39,42 +39,9 @@ Description
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
template<class T>
|
||||||
/*---------------------------------------------------------------------------*\
|
using SLList = LList<SLListBase, T>;
|
||||||
Class SLList Declaration
|
}
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class SLList
|
|
||||||
:
|
|
||||||
public LList<SLListBase, T>
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Null construct
|
|
||||||
SLList()
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct given initial T
|
|
||||||
explicit SLList(T a)
|
|
||||||
:
|
|
||||||
LList<SLListBase, T>(a)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from Istream
|
|
||||||
explicit SLList(Istream& is)
|
|
||||||
:
|
|
||||||
LList<SLListBase, T>(is)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -61,8 +61,11 @@ template<class T, unsigned Size>
|
|||||||
Ostream& operator<<(Ostream&, const FixedList<T, Size>&);
|
Ostream& operator<<(Ostream&, const FixedList<T, Size>&);
|
||||||
|
|
||||||
template<class T> class UList;
|
template<class T> class UList;
|
||||||
template<class T> class SLList;
|
|
||||||
|
|
||||||
|
class SLListBase;
|
||||||
|
template<class LListBase, class T> class LList;
|
||||||
|
template<class T>
|
||||||
|
using SLList = LList<SLListBase, T>;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class FixedList Declaration
|
Class FixedList Declaration
|
||||||
@ -219,16 +222,16 @@ public:
|
|||||||
//- Return element of constant FixedList
|
//- Return element of constant FixedList
|
||||||
inline const T& operator[](const label) const;
|
inline const T& operator[](const label) const;
|
||||||
|
|
||||||
//- Assignment from array operator. Takes linear time
|
//- Assignment to array operator. Takes linear time
|
||||||
inline void operator=(const T v[Size]);
|
inline void operator=(const T v[Size]);
|
||||||
|
|
||||||
//- Assignment from UList operator. Takes linear time
|
//- Assignment to UList operator. Takes linear time
|
||||||
inline void operator=(const UList<T>&);
|
inline void operator=(const UList<T>&);
|
||||||
|
|
||||||
//- Assignment from SLList operator. Takes linear time
|
//- Assignment to SLList operator. Takes linear time
|
||||||
inline void operator=(const SLList<T>&);
|
inline void operator=(const SLList<T>&);
|
||||||
|
|
||||||
//- Assignment from an initializer list. Takes linear time
|
//- Assignment to an initializer list. Takes linear time
|
||||||
inline void operator=(std::initializer_list<T>);
|
inline void operator=(std::initializer_list<T>);
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
//- Assignment of all entries to the given value
|
||||||
|
|||||||
@ -62,7 +62,11 @@ template<class T> Istream& operator>>(Istream&, List<T>&);
|
|||||||
|
|
||||||
template<class T, unsigned Size> class FixedList;
|
template<class T, unsigned Size> class FixedList;
|
||||||
template<class T> class PtrList;
|
template<class T> class PtrList;
|
||||||
template<class T> class SLList;
|
|
||||||
|
class SLListBase;
|
||||||
|
template<class LListBase, class T> class LList;
|
||||||
|
template<class T>
|
||||||
|
using SLList = LList<SLListBase, T>;
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
class DynamicList;
|
class DynamicList;
|
||||||
@ -247,22 +251,22 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
//- Assignment from UList operator. Takes linear time
|
//- Assignment to UList operator. Takes linear time
|
||||||
void operator=(const UList<T>&);
|
void operator=(const UList<T>&);
|
||||||
|
|
||||||
//- Assignment operator. Takes linear time
|
//- Assignment operator. Takes linear time
|
||||||
void operator=(const List<T>&);
|
void operator=(const List<T>&);
|
||||||
|
|
||||||
//- Assignment from SLList operator. Takes linear time
|
//- Assignment to SLList operator. Takes linear time
|
||||||
void operator=(const SLList<T>&);
|
void operator=(const SLList<T>&);
|
||||||
|
|
||||||
//- Assignment from UIndirectList operator. Takes linear time
|
//- Assignment to UIndirectList operator. Takes linear time
|
||||||
void operator=(const UIndirectList<T>&);
|
void operator=(const UIndirectList<T>&);
|
||||||
|
|
||||||
//- Assignment from BiIndirectList operator. Takes linear time
|
//- Assignment to BiIndirectList operator. Takes linear time
|
||||||
void operator=(const BiIndirectList<T>&);
|
void operator=(const BiIndirectList<T>&);
|
||||||
|
|
||||||
//- Construct from an initializer list
|
//- Assignment to an initializer list
|
||||||
void operator=(std::initializer_list<T>);
|
void operator=(std::initializer_list<T>);
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
//- Assignment of all entries to the given value
|
||||||
|
|||||||
@ -157,7 +157,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
|
|||||||
|
|
||||||
vector origin(this->coeffDict().lookup("origin"));
|
vector origin(this->coeffDict().lookup("origin"));
|
||||||
|
|
||||||
radius_ = this->coeffDict().lookup("radius");
|
this->coeffDict().lookup("radius") >> radius_;
|
||||||
nSector_ = readLabel(this->coeffDict().lookup("nSector"));
|
nSector_ = readLabel(this->coeffDict().lookup("nSector"));
|
||||||
|
|
||||||
label nS = nSector_;
|
label nS = nSector_;
|
||||||
|
|||||||
Reference in New Issue
Block a user