mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use std::pair (not Tuple2) in conjunction with std::initializer_list
- no penalty compared to Tuple2, potential future benefits with C++ constructor forwarding.
This commit is contained in:
@ -900,12 +900,10 @@ void Foam::conformalVoronoiMesh::writeMesh
|
|||||||
mesh.addFvPatches(patches);
|
mesh.addFvPatches(patches);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add zones to the mesh
|
// Add zones to the mesh
|
||||||
addZones(mesh, cellCentres);
|
addZones(mesh, cellCentres);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Info<< indent << "Add pointZones" << endl;
|
Info<< indent << "Add pointZones" << endl;
|
||||||
{
|
{
|
||||||
label sz = mesh.pointZones().size();
|
label sz = mesh.pointZones().size();
|
||||||
@ -914,6 +912,9 @@ void Foam::conformalVoronoiMesh::writeMesh
|
|||||||
|
|
||||||
forAll(dualMeshPointTypeNames_, typeI)
|
forAll(dualMeshPointTypeNames_, typeI)
|
||||||
{
|
{
|
||||||
|
const word& znName =
|
||||||
|
dualMeshPointTypeNames_[dualMeshPointType(typeI)];
|
||||||
|
|
||||||
forAll(boundaryPts, ptI)
|
forAll(boundaryPts, ptI)
|
||||||
{
|
{
|
||||||
const label& bPtType = boundaryPts[ptI];
|
const label& bPtType = boundaryPts[ptI];
|
||||||
@ -928,14 +929,14 @@ void Foam::conformalVoronoiMesh::writeMesh
|
|||||||
|
|
||||||
Info<< incrIndent << indent
|
Info<< incrIndent << indent
|
||||||
<< "Adding " << bPts.size()
|
<< "Adding " << bPts.size()
|
||||||
<< " points of type " << dualMeshPointTypeNames_.words()[typeI]
|
<< " points of type " << znName
|
||||||
<< decrIndent << endl;
|
<< decrIndent << endl;
|
||||||
|
|
||||||
mesh.pointZones().append
|
mesh.pointZones().append
|
||||||
(
|
(
|
||||||
new pointZone
|
new pointZone
|
||||||
(
|
(
|
||||||
dualMeshPointTypeNames_.words()[typeI],
|
znName,
|
||||||
bPts,
|
bPts,
|
||||||
sz + typeI,
|
sz + typeI,
|
||||||
mesh.pointZones()
|
mesh.pointZones()
|
||||||
|
|||||||
@ -29,7 +29,6 @@ License
|
|||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
#include "FixedList.H"
|
#include "FixedList.H"
|
||||||
#include "Tuple2.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -112,14 +111,14 @@ Foam::HashTable<T, Key, Hash>::HashTable
|
|||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
Foam::HashTable<T, Key, Hash>::HashTable
|
Foam::HashTable<T, Key, Hash>::HashTable
|
||||||
(
|
(
|
||||||
std::initializer_list<Tuple2<Key, T>> lst
|
std::initializer_list<std::pair<Key, T>> lst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
HashTable<T, Key, Hash>(2*lst.size())
|
HashTable<T, Key, Hash>(2*lst.size())
|
||||||
{
|
{
|
||||||
for (const Tuple2<Key, T>& pair : lst)
|
for (const auto& pair : lst)
|
||||||
{
|
{
|
||||||
insert(pair.first(), pair.second());
|
insert(pair.first, pair.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,7 +888,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
|
|||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
void Foam::HashTable<T, Key, Hash>::operator=
|
void Foam::HashTable<T, Key, Hash>::operator=
|
||||||
(
|
(
|
||||||
std::initializer_list<Tuple2<Key, T>> lst
|
std::initializer_list<std::pair<Key, T>> lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Could be zero-sized from a previous transfer()
|
// Could be zero-sized from a previous transfer()
|
||||||
@ -904,7 +903,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
|
|||||||
|
|
||||||
for (const auto& pair : lst)
|
for (const auto& pair : lst)
|
||||||
{
|
{
|
||||||
insert(pair.first(), pair.second());
|
insert(pair.first, pair.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -73,7 +74,6 @@ namespace Foam
|
|||||||
template<class T> class List;
|
template<class T> class List;
|
||||||
template<class T> class UList;
|
template<class T> class UList;
|
||||||
template<class T, unsigned Size> class FixedList;
|
template<class T, unsigned Size> class FixedList;
|
||||||
template<class T1, class T2> class Tuple2;
|
|
||||||
template<class T, class Key, class Hash> class HashTable;
|
template<class T, class Key, class Hash> class HashTable;
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
@ -212,7 +212,7 @@ private:
|
|||||||
|
|
||||||
// Private data type for table entries
|
// Private data type for table entries
|
||||||
|
|
||||||
//- Structure to hold a hashed entry, with a SLList for collisions
|
//- Structure to hold a hashed entry, with a linked-list for collisions
|
||||||
struct hashedEntry
|
struct hashedEntry
|
||||||
{
|
{
|
||||||
//- The lookup key
|
//- The lookup key
|
||||||
@ -224,7 +224,7 @@ private:
|
|||||||
//- Pointer to next hashedEntry in sub-list
|
//- Pointer to next hashedEntry in sub-list
|
||||||
hashedEntry* next_;
|
hashedEntry* next_;
|
||||||
|
|
||||||
//- Construct from key, next pointer and object
|
//- Construct from key, object, next pointer
|
||||||
inline hashedEntry(const Key& key, const T& obj, hashedEntry* next);
|
inline hashedEntry(const Key& key, const T& obj, hashedEntry* next);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -296,7 +296,7 @@ public:
|
|||||||
HashTable(const Xfer<HashTable<T, Key, Hash>>& ht);
|
HashTable(const Xfer<HashTable<T, Key, Hash>>& ht);
|
||||||
|
|
||||||
//- Construct from an initializer list
|
//- Construct from an initializer list
|
||||||
HashTable(std::initializer_list<Tuple2<Key, T>> lst);
|
HashTable(std::initializer_list<std::pair<Key, T>> lst);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -558,7 +558,7 @@ public:
|
|||||||
void operator=(const HashTable<T, Key, Hash>& rhs);
|
void operator=(const HashTable<T, Key, Hash>& rhs);
|
||||||
|
|
||||||
//- Assignment from an initializer list
|
//- Assignment from an initializer list
|
||||||
void operator=(std::initializer_list<Tuple2<Key, T>> lst);
|
void operator=(std::initializer_list<std::pair<Key, T>> lst);
|
||||||
|
|
||||||
//- Equality. Hash tables are equal if the keys and values are equal.
|
//- Equality. Hash tables are equal if the keys and values are equal.
|
||||||
// Independent of table storage size and table order.
|
// Independent of table storage size and table order.
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from an initializer list
|
//- Construct from an initializer list
|
||||||
Map(std::initializer_list<Tuple2<label, T>> map)
|
Map(std::initializer_list<std::pair<label, T>> map)
|
||||||
:
|
:
|
||||||
parent_type(map)
|
parent_type(map)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@ -54,6 +54,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "profilingTrigger.H"
|
#include "profilingTrigger.H"
|
||||||
#include "HashPtrTable.H"
|
#include "HashPtrTable.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
#include "LIFOStack.H"
|
#include "LIFOStack.H"
|
||||||
#include "Map.H"
|
#include "Map.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
|||||||
Reference in New Issue
Block a user