ENH: for-range, forAllIters() ... in applications/utilities

- reduced clutter when iterating over containers
This commit is contained in:
Mark Olesen
2019-01-07 09:20:51 +01:00
parent 1458b4f689
commit 14a404170b
76 changed files with 592 additions and 728 deletions

View File

@ -72,7 +72,7 @@ public:
void testCallbackFunction() const
{
forAllConstIter(callbackRegistry, *this, iter)
forAllConstIters(*this, iter)
{
iter().testCallbackFunction();
}

View File

@ -55,7 +55,7 @@ int main(int argc, char *argv[])
Info<< fvc::div(U);
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -54,7 +54,7 @@ int main()
a = h + i + j;
Info<< a << endl;
Info<< "end" << endl;
Info<< "End" << endl;
return 0;
}

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[])
Info<< (gradx4a - gradx4[i])/gradx4a << endl;
}
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
mesh
);
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -65,7 +65,7 @@ int main()
);
phi.write("phi", "xmgr");
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -57,7 +57,7 @@ int main()
"xmgr"
);
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -57,7 +57,7 @@ int main()
graph("r", "x", "r", x, r).write("r", "xmgr");
Info<< "end" << endl;
Info<< "End" << endl;
return 0;
}

View File

@ -59,11 +59,11 @@ int main(int argc, char *argv[])
Pout<< "Adding a particle." << endl;
particles.addParticle(new passiveParticle(mesh, Zero, -1));
forAllConstIter(passiveParticleCloud, particles, iter)
for (const passiveParticle& p : particles)
{
Pout<< " " << iter().position() << " cell:" << iter().cell()
<< " origProc:" << iter().origProc()
<< " origId:" << iter().origId()
Pout<< " " << p.position() << " cell:" << p.cell()
<< " origProc:" << p.origProc()
<< " origId:" << p.origId()
<< endl;
}
@ -80,11 +80,11 @@ int main(int argc, char *argv[])
passiveParticleCloud particles(mesh, cloudName);
Pout<< "Reread particles:" << particles.size() << endl;
forAllConstIter(passiveParticleCloud, particles, iter)
for (const passiveParticle& p : particles)
{
Pout<< " " << iter().position() << " cell:" << iter().cell()
<< " origProc:" << iter().origProc()
<< " origId:" << iter().origId()
Pout<< " " << p.position() << " cell:" << p.cell()
<< " origProc:" << p.origProc()
<< " origId:" << p.origId()
<< endl;
}
}

View File

@ -261,10 +261,10 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
}
// 2. Does sparseData contain more?
forAllConstIter(Map<point>, sparseData, iter)
forAllConstIters(sparseData, iter)
{
const point& sparsePt = iter();
label meshPointi = iter.key();
const label meshPointi = iter.key();
const point& sparsePt = iter.val();
const point& fullPt = fullData[meshPointi];
if (fullPt != sparsePt)
@ -350,9 +350,9 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
{
const edge& e = mesh.edges()[meshEdgeI];
EdgeMap<point>::const_iterator iter = sparseData.find(e);
const auto iter = sparseData.cfind(e);
if (iter != sparseData.end())
if (iter.found())
{
const point& sparsePt = iter();
const point& fullPt = fullData[meshEdgeI];