Commit 87412035 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: use forAllIter, forAllConstIter in more places

ENH: change some iterator -> const_iterator access

BUG: found some places with forAllIter and ::iterator !
parent 5636df2b
......@@ -51,12 +51,7 @@ int main(int argc, char *argv[])
Info<< nl << "And again using STL iterator: " << nl << endl;
for
(
DLList<scalar>::iterator iter = myList.begin();
iter != myList.end();
++iter
)
forAllIter(DLList<scalar>, myList, iter)
{
Info<< "element:" << *iter << endl;
}
......@@ -64,12 +59,7 @@ int main(int argc, char *argv[])
Info<< nl << "And again using the same STL iterator: " << nl << endl;
for
(
DLList<scalar>::iterator iter = myList.begin();
iter != myList.end();
++iter
)
forAllIter(DLList<scalar>, myList, iter)
{
Info<< "Removing " << myList.remove(iter) << endl;
}
......@@ -82,12 +72,7 @@ int main(int argc, char *argv[])
const DLList<scalar>& const_myList = myList;
for
(
DLList<scalar>::const_iterator iter = const_myList.begin();
iter != const_myList.end();
++iter
)
forAllConstIter(DLList<scalar>, const_myList, iter)
{
Info<< "element:" << *iter << endl;
}
......@@ -95,12 +80,7 @@ int main(int argc, char *argv[])
myList.swapUp(myList.DLListBase::first());
myList.swapUp(myList.DLListBase::last());
for
(
DLList<scalar>::const_iterator iter = const_myList.begin();
iter != const_myList.end();
++iter
)
forAllConstIter(DLList<scalar>, const_myList, iter)
{
Info<< "element:" << *iter << endl;
}
......@@ -108,19 +88,14 @@ int main(int argc, char *argv[])
myList.swapDown(myList.DLListBase::first());
myList.swapDown(myList.DLListBase::last());
for
(
DLList<scalar>::const_iterator iter = const_myList.begin();
iter != const_myList.end();
++iter
)
forAllConstIter(DLList<scalar>, const_myList, iter)
{
Info<< "element:" << *iter << endl;
}
Info<< nl << "Testing transfer: " << nl << endl;
Info<< "original: " << myList << endl;
Info<< nl << "Testing transfer: " << nl << nl
<< "original: " << myList << endl;
DLList<scalar> newList;
newList.transfer(myList);
......
......@@ -114,12 +114,7 @@ int main(int argc, char *argv[])
dict.swapDown(dict.first());
for
(
Dictionary<ent>::const_iterator iter = dict.begin();
iter != dict.end();
++iter
)
forAllConstIter(Dictionary<ent>, dict, iter)
{
Info<< "element : " << *iter;
}
......@@ -159,12 +154,7 @@ int main(int argc, char *argv[])
}
Info<< nl << "scalarDict1: " << endl;
for
(
PtrDictionary<Scalar>::const_iterator iter = scalarDict.begin();
iter != scalarDict.end();
++iter
)
forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter)
{
Info<< " = " << iter() << endl;
}
......@@ -176,12 +166,7 @@ int main(int argc, char *argv[])
scalarDict2.insert(key, new Scalar(1.3*i));
}
Info<< nl << "scalarDict2: " << endl;
for
(
PtrDictionary<Scalar>::const_iterator iter = scalarDict2.begin();
iter != scalarDict2.end();
++iter
)
forAllConstIter(PtrDictionary<Scalar>, scalarDict2, iter)
{
Info<< "elem = " << *iter << endl;
}
......
......@@ -78,12 +78,7 @@ int main(int argc, char *argv[])
Info<< nl << "And again using STL iterator: " << nl << endl;
for
(
SLList<scalar>::iterator iter = myList.begin();
iter != myList.end();
++iter
)
forAllIter(SLList<scalar>, myList, iter)
{
Info<< "element:" << *iter << endl;
}
......@@ -92,14 +87,9 @@ int main(int argc, char *argv[])
const ISLList<Scalar>& const_myList = myList;
for
(
SLList<scalar>::const_iterator iter2 = const_myList.begin();
iter2 != const_myList.end();
++iter2
)
forAllConstIter(SLList<scalar>, const_myList, iter)
{
Info<< "element:" << *iter2 << endl;
Info<< "element:" << *iter << endl;
}
......
......@@ -188,12 +188,7 @@ int main(int argc, char *argv[])
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
for
(
PackedBoolList::iterator it = packed.begin();
it != packed.end();
++it
)
forAllIter(PackedBoolList, packed, it)
{
sum += it;
}
......@@ -207,12 +202,7 @@ int main(int argc, char *argv[])
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
for
(
PackedBoolList::const_iterator cit = packed.cbegin();
cit != packed.cend();
++cit
)
forAllConstIter(PackedBoolList, packed, cit)
{
sum += cit();
}
......@@ -333,12 +323,7 @@ int main(int argc, char *argv[])
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
for
(
PackedBoolList::iterator it = packed.begin();
it != packed.end();
++it
)
forAllIter(PackedBoolList, packed, it)
{
it() = 1;
}
......
......@@ -51,12 +51,7 @@ int main(int argc, char *argv[])
Info<< nl << "And again using STL iterator: " << nl << endl;
for
(
SLList<scalar>::iterator iter = myList.begin();
iter != myList.end();
++iter
)
forAllIter(SLList<scalar>, myList, iter)
{
Info<< "element:" << *iter << endl;
}
......@@ -65,39 +60,23 @@ int main(int argc, char *argv[])
const SLList<scalar>& const_myList = myList;
for
(
SLList<scalar>::const_iterator iter2 = const_myList.begin();
iter2 != const_myList.end();
++iter2
)
forAllConstIter(SLList<scalar>, const_myList, iter)
{
Info<< "element:" << *iter2 << endl;
Info<< "element:" << *iter << endl;
}
for
(
SLList<scalar>::iterator iter = myList.begin();
iter != myList.end();
++iter
)
forAllIter(SLList<scalar>, myList, iter)
{
Info<< "Removing element:" << *iter << endl;
myList.remove(iter);
}
for
(
SLList<scalar>::const_iterator iter2 = const_myList.begin();
iter2 != const_myList.end();
++iter2
)
forAllConstIter(SLList<scalar>, const_myList, iter)
{
Info<< "element:" << *iter2 << endl;
Info<< "element:" << *iter << endl;
}
for (int i = 0; i<10; i++)
{
myList.append(1.3*i);
......
......@@ -81,12 +81,7 @@ int main(int argc, char *argv[])
dict.swapDown(dict.first());
for
(
UDictionary<ent>::const_iterator iter = dict.begin();
iter != dict.end();
++iter
)
forAllConstIter(UDictionary<ent>, dict, iter)
{
Info<< "element : " << *iter;
}
......
......@@ -441,12 +441,7 @@ if (pFaces[WEDGE].size() && pFaces[WEDGE][0].size())
{
pFaces[CYCLIC].setSize(1);
pFaces[CYCLIC][0] = pFaces[WEDGE][0];
for
(
SLList<face>::iterator iterb = pFaces[WEDGE][1].begin();
iterb != pFaces[WEDGE][1].end();
++iterb
)
forAllIter(SLList<face>, pFaces[WEDGE][1], iterb)
{
pFaces[CYCLIC][0].append(iterb());
}
......
......@@ -143,12 +143,7 @@ void addPatchFields(fvMesh& mesh, const word& patchFieldType)
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
......@@ -183,12 +178,7 @@ void trimPatchFields(fvMesh& mesh, const label nPatches)
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
......@@ -209,12 +199,7 @@ void reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
......@@ -1461,7 +1446,7 @@ int main(int argc, char *argv[])
mesh.setInstance(meshInstance);
}
// Change master and slave boundary conditions on originating mesh
......
......@@ -99,12 +99,7 @@ void addPatchFields(fvMesh& mesh, const word& patchFieldType)
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
......@@ -139,12 +134,7 @@ void trimPatchFields(fvMesh& mesh, const label nPatches)
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
......@@ -165,12 +155,7 @@ void reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
{
const GeoField& fld = *iter();
......
......@@ -506,7 +506,7 @@ void Foam::domainDecomposition::decomposeMesh()
// Add internal and boundary faces
// Remember to increment the index by one such that the
// turning index works properly.
forAllIter(SLList<label>, curProcFaces, curProcFacesIter)
forAllConstIter(SLList<label>, curProcFaces, curProcFacesIter)
{
curProcFaceAddressing[nFaces] = curProcFacesIter() + 1;
nFaces++;
......@@ -559,7 +559,7 @@ void Foam::domainDecomposition::decomposeMesh()
// add faces for this processor boundary
forAllIter
forAllConstIter
(
SLList<label>,
curInterProcBFacesIter(),
......
......@@ -55,7 +55,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
{
SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
forAllIter(SLList<indexedParticle*>, particlePtrs, iter)
forAllConstIter(SLList<indexedParticle*>, particlePtrs, iter)
{
const indexedParticle& ppi = *iter();
particleIndices_[pi++] = ppi.index();
......
......@@ -50,7 +50,7 @@ void readFields
label nFields = fields.size();
fields.setSize(nFields + fieldObjects.size());
forAllIter(IOobjectList::iterator, fieldObjects, iter)
forAllIter(IOobjectList, fieldObjects, iter)
{
if (selectedFields.empty() || selectedFields.found(iter()->name()))
{
......
......@@ -502,7 +502,7 @@ Foam::wordList Foam::dictionary::toc() const
wordList keys(size());
label nKeys = 0;
forAllConstIter(IDLList<entry>::const_iterator, *this, iter)
forAllConstIter(IDLList<entry>, *this, iter)
{
keys[nKeys++] = iter().keyword();
}
......
......@@ -54,7 +54,7 @@ Foam::dlLibraryTable::readDlLibrary::readDlLibrary
Foam::dlLibraryTable::~dlLibraryTable()
{
forAllIter(dlLibraryTable, *this, iter)
forAllConstIter(dlLibraryTable, *this, iter)
{
dlclose(iter.key());
}
......
......@@ -49,12 +49,7 @@ inline void mapClouds(const objectRegistry& db, const mapPolyMesh& mapper)
{
HashTable<const cloud*> clouds(db.lookupClass<cloud>());
for
(
HashTable<const cloud*>::iterator iter = clouds.begin();
iter != clouds.end();
++iter
)
forAllIter(HashTable<const cloud*>, clouds, iter)
{
cloud& c = const_cast<cloud&>(*iter());
......
......@@ -163,7 +163,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
{
faceCells_[nCoarseFaces] = contents[masterI];
forAllIter(SLList<label>, faceFacesIter(), facesIter)
forAllConstIter(SLList<label>, faceFacesIter(), facesIter)
{
faceRestrictAddressing_[facesIter()] = nCoarseFaces;
}
......@@ -192,7 +192,7 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
{
faceCells_[nCoarseFaces] = nbrsIter();
forAllIter(SLList<label>, faceFacesIter(), facesIter)
forAllConstIter(SLList<label>, faceFacesIter(), facesIter)
{
faceRestrictAddressing_[facesIter() + sizeBy2] = nCoarseFaces;
}
......
......@@ -180,7 +180,7 @@ Foam::processorGAMGInterface::processorGAMGInterface
{
faceCells_[nCoarseFaces] = contents[masterI];
forAllIter(SLList<label>, faceFacesIter(), facesIter)
forAllConstIter(SLList<label>, faceFacesIter(), facesIter)
{
faceRestrictAddressing_[facesIter()] = nCoarseFaces;
}
......@@ -213,7 +213,7 @@ Foam::processorGAMGInterface::processorGAMGInterface
{
faceCells_[nCoarseFaces] = nbrsIter();
forAllIter(SLList<label>, faceFacesIter(), facesIter)
forAllConstIter(SLList<label>, faceFacesIter(), facesIter)
{
faceRestrictAddressing_[facesIter()] = nCoarseFaces;
}
......
......@@ -1411,7 +1411,7 @@ void Foam::globalPoints::calculateSharedPoints
// Sort procPoints in incremental order. This will make the master the
// first element.
forAllIter(Map<label>, meshToProcPoint_, iter)
forAllConstIter(Map<label>, meshToProcPoint_, iter)
{
sort(procPoints_[iter()]);
}
......
......@@ -371,9 +371,9 @@ Foam::mapDistribute::mapDistribute
label i = 0;
forAllIter(Map<label>, compactMap[procI], iter)
{
const label compactI = compactStart[procI] + iter();
remoteElem[i] = iter.key();
label compactI = compactStart[procI]+iter();
localElem[i] = compactI;
localElem[i] = compactI;
iter() = compactI;
i++;
}
......@@ -525,9 +525,9 @@ Foam::mapDistribute::mapDistribute
label i = 0;
forAllIter(Map<label>, compactMap[procI], iter)
{
const label compactI = compactStart[procI] + iter();
remoteElem[i] = iter.key();
label compactI = compactStart[procI]+iter();
localElem[i] = compactI;
localElem[i] = compactI;
iter() = compactI;
i++;
}
......
......@@ -201,12 +201,7 @@ void Foam::syncTools::syncPointMap
// Only update those values which come from neighbour
forAllConstIter
(
typename Map<T>,
nbrPatchInfo,
nbrIter
)
forAllConstIter(typename Map<T>, nbrPatchInfo, nbrIter)
{
combine
(
......@@ -550,12 +545,7 @@ void Foam::syncTools::syncEdgeMap
// Only update those values which come from neighbour
forAllConstIter
(
typename EdgeMap<T>,
nbrPatchInfo,
nbrIter
)
forAllConstIter(typename EdgeMap<T>, nbrPatchInfo, nbrIter)
{
const edge& e = nbrIter.key();
const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment