STYLE: prefer push_uniq() to appendUniq

- more consistency with push_back etc.
This commit is contained in:
Mark Olesen
2023-08-21 16:56:35 +02:00
parent 2395e493d1
commit 698e05eeb3
20 changed files with 42 additions and 78 deletions

View File

@ -468,8 +468,8 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
forAll(c1Procs, aPI) forAll(c1Procs, aPI)
{ {
procsAttached.appendUniq(c1Procs[aPI]); procsAttached.push_uniq(c1Procs[aPI]);
procsAttached.appendUniq(c2Procs[aPI]); procsAttached.push_uniq(c2Procs[aPI]);
} }
return List<label>(procsAttached); return List<label>(procsAttached);

View File

@ -46,8 +46,8 @@ void Foam::shortEdgeFilter2D::assignBoundaryPointRegions
const edge& e = iter.key(); const edge& e = iter.key();
const label regi = iter.val(); const label regi = iter.val();
boundaryPointRegions[e.start()].appendUniq(regi); boundaryPointRegions[e.first()].push_uniq(regi);
boundaryPointRegions[e.end()].appendUniq(regi); boundaryPointRegions[e.second()].push_uniq(regi);
} }
} }
@ -66,7 +66,7 @@ void Foam::shortEdgeFilter2D::updateEdgeRegionMap
const edgeList& edges = surfMesh.edges(); const edgeList& edges = surfMesh.edges();
const labelList& meshPoints = surfMesh.meshPoints(); const labelList& meshPoints = surfMesh.meshPoints();
patchSizes.setSize(patchNames_.size(), 0); patchSizes.resize_nocopy(patchNames_.size());
patchSizes = 0; patchSizes = 0;
forAll(edges, edgeI) forAll(edges, edgeI)
@ -78,15 +78,13 @@ void Foam::shortEdgeFilter2D::updateEdgeRegionMap
const edge& e = edges[edgeI]; const edge& e = edges[edgeI];
const label startI = meshPoints[e[0]];
const label endI = meshPoints[e[1]];
label region = -1; label region = -1;
const DynamicList<label> startPtRegions = const DynamicList<label>& startPtRegions =
boundaryPtRegions[surfPtToBoundaryPt[startI]]; boundaryPtRegions[surfPtToBoundaryPt[meshPoints[e.first()]]];
const DynamicList<label> endPtRegions =
boundaryPtRegions[surfPtToBoundaryPt[endI]]; const DynamicList<label>& endPtRegions =
boundaryPtRegions[surfPtToBoundaryPt[meshPoints[e.second()]]];
if (startPtRegions.size() > 1 && endPtRegions.size() > 1) if (startPtRegions.size() > 1 && endPtRegions.size() > 1)
{ {

View File

@ -518,7 +518,7 @@ void Foam::meshDualiser::createFacesAroundEdge
if (startDual != -1) if (startDual != -1)
{ {
verts.appendUniq(startDual); verts.push_uniq(startDual);
} }
} }
break; break;

View File

@ -497,7 +497,7 @@ bool Foam::fileMonitor::removeWatch(const label watchFd)
<< watchFile_[watchFd] << endl; << watchFile_[watchFd] << endl;
} }
freeWatchFds_.appendUniq(watchFd); freeWatchFds_.push_uniq(watchFd);
return watcher_->removeWatch(watchFd); return watcher_->removeWatch(watchFd);
} }

View File

@ -493,7 +493,7 @@ bool Foam::fileMonitor::removeWatch(const label watchFd)
<< watchFile_[watchFd] << endl; << watchFile_[watchFd] << endl;
} }
freeWatchFds_.appendUniq(watchFd); freeWatchFds_.push_uniq(watchFd);
return watcher_->removeWatch(watchFd); return watcher_->removeWatch(watchFd);
} }

View File

@ -524,8 +524,8 @@ public:
//FOAM_DEPRECATED_FOR(2022-10, "push_back()") //FOAM_DEPRECATED_FOR(2022-10, "push_back()")
void append(const UList<T>& list) { this->push_back(list); } void append(const UList<T>& list) { this->push_back(list); }
//- Append an element if not already in the buffer. //- Same as push_uniq()
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq()") FOAM_DEPRECATED_STRICT(2022-10, "push_uniq()")
label appendUniq(const T& val) { return this->push_uniq(val); } label appendUniq(const T& val) { return this->push_uniq(val); }
}; };

View File

@ -443,8 +443,8 @@ public:
this->push_back(std::move(list)); this->push_back(std::move(list));
} }
//- Append an element if not already in the list. //- Same as push_uniq()
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq()") FOAM_DEPRECATED_STRICT(2022-10, "push_uniq()")
label appendUniq(const T& val) { return this->push_uniq(val); } label appendUniq(const T& val) { return this->push_uniq(val); }
}; };

View File

@ -395,8 +395,8 @@ public:
this->push_back(list); this->push_back(list);
} }
//- Append an element if not already in the list. //- Same as push_uniq()
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq()") FOAM_DEPRECATED_STRICT(2022-10, "push_uniq()")
label appendUniq(const T& val) { return this->push_uniq(val); } label appendUniq(const T& val) { return this->push_uniq(val); }

View File

@ -1065,14 +1065,9 @@ void Foam::ListOps::appendEqOp<T>::operator()
{ {
if (y.size()) if (y.size())
{ {
label len = x.size(); if (x.size())
if (len)
{ {
x.resize(len + y.size()); x.push_back(y);
for (const T& val : y)
{
x[len++] = val;
}
} }
else else
{ {
@ -1095,11 +1090,7 @@ void Foam::ListOps::uniqueEqOp<T>::operator()
{ {
for (const T& val : y) for (const T& val : y)
{ {
// --> x.push_uniq(val) x.push_uniq(val);
if (!x.contains(val))
{
x.push_back(val);
}
} }
} }
else else

View File

@ -239,7 +239,7 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
for (const labelPair& connection : nbrData) for (const labelPair& connection : nbrData)
{ {
allComms.appendUniq(connection); allComms.push_uniq(connection);
} }
} }
} }

View File

@ -184,16 +184,16 @@ public:
//- Same as contains(), searches the hash. //- Same as contains(), searches the hash.
bool found(const word& val) const { return this->contains(val); } bool found(const word& val) const { return this->contains(val); }
//- Append an element if not already in the list. //- Same as push_uniq()
FOAM_DEPRECATED_FOR(2022-05, "push_uniq method") FOAM_DEPRECATED_FOR(2022-05, "push_uniq method")
void append(const word& val) { this->push_uniq(val); } void append(const word& val) { this->push_uniq(val); }
//- Append an element if not already in the list. //- Same as push_uniq()
FOAM_DEPRECATED_FOR(2022-10, "push_uniq method") FOAM_DEPRECATED_FOR(2022-10, "push_uniq method")
void push_back(const word& val) { this->push_uniq(val); } void push_back(const word& val) { this->push_uniq(val); }
//- Append an element if not already in the list. //- Same as push_uniq()
//FOAM_DEPRECATED_FOR(2022-10, "push_uniq method") FOAM_DEPRECATED_STRICT(2022-10, "push_uniq method")
label appendUniq(const word& val) { return this->push_uniq(val); } label appendUniq(const word& val) { return this->push_uniq(val); }
}; };

View File

@ -212,7 +212,7 @@ Foam::wordList Foam::fvMeshDistribute::mergeWordList(const wordList& procNames)
{ {
for (const word& name : names) for (const word& name : names)
{ {
mergedNames.appendUniq(name); mergedNames.push_uniq(name);
} }
} }
} }

View File

@ -262,7 +262,7 @@ bool Foam::combineFaces::faceNeighboursValid
} }
else else
{ {
neighbourFaces.appendUniq(nbrI); neighbourFaces.push_uniq(nbrI);
} }
} }

View File

@ -1837,26 +1837,11 @@ bool Foam::hexRef8::matchHexShape
{ {
// Add to pointFaces for any level+1 point (this might be // Add to pointFaces for any level+1 point (this might be
// a midpoint of a split face) // a midpoint of a split face)
forAll(f, fp) for (const label pointi : f)
{ {
label pointi = f[fp];
if (pointLevel_[pointi] == cellLevel+1) if (pointLevel_[pointi] == cellLevel+1)
{ {
auto iter = pointFaces.find(pointi); pointFaces(pointi).push_uniq(facei);
if (iter.good())
{
labelList& pFaces = iter.val();
pFaces.appendUniq(facei);
}
else
{
pointFaces.insert
(
pointi,
labelList(one{}, facei)
);
}
} }
} }
} }

View File

@ -57,12 +57,10 @@ void Foam::enrichedPatch::calcPointPoints() const
DynamicList<label>& curPp = pp[curFace[pointi]]; DynamicList<label>& curPp = pp[curFace[pointi]];
// Do next label // Do next label
const label next = curFace.nextLabel(pointi); curPp.push_uniq(curFace.nextLabel(pointi));
curPp.appendUniq(next);
// Do previous label // Do previous label
const label prev = curFace.prevLabel(pointi); curPp.push_uniq(curFace.prevLabel(pointi));
curPp.appendUniq(prev);
} }
} }

View File

@ -176,7 +176,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
label nbrGlobali = globalNumbering().toGlobal(nbrFacei); label nbrGlobali = globalNumbering().toGlobal(nbrFacei);
// Note:should use hashset? // Note:should use hashset?
allGlobalFaces.appendUniq(nbrGlobali); allGlobalFaces.push_uniq(nbrGlobali);
} }
} }
} }
@ -188,7 +188,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
for (const label nbrGlobali : nbrGlobalFaces) for (const label nbrGlobali : nbrGlobalFaces)
{ {
// Note:should use hashset? // Note:should use hashset?
allGlobalFaces.appendUniq(nbrGlobali); allGlobalFaces.push_uniq(nbrGlobali);
} }
} }
} }

View File

@ -1967,16 +1967,8 @@ void Foam::snappyLayerDriver::getPatchDisplacement
// const label patchFacei = pFaces[pFacei]; // const label patchFacei = pFaces[pFacei];
// const label meshFacei = pp.addressing()[patchFacei]; // const label meshFacei = pp.addressing()[patchFacei];
// const label celli = mesh.faceOwner()[meshFacei]; // const label celli = mesh.faceOwner()[meshFacei];
// Map<labelList>::iterator faceFnd = cellToFaces.find(celli); //
// if (faceFnd.good()) // cellToFaces(celli).push_uniq(patchFacei);
// {
// labelList& faces = faceFnd();
// faces.appendUniq(patchFacei);
// }
// else
// {
// cellToFaces.insert(celli, labelList(one{}, patchFacei));
// }
// } // }
// //
// forAllConstIters(cellToFaces, iter) // forAllConstIters(cellToFaces, iter)

View File

@ -107,7 +107,7 @@ void Foam::cellDistFuncs::getPointNeighbours
for (const label nbr : faceNeighbours) for (const label nbr : faceNeighbours)
{ {
neighbours.appendUniq(nbr); neighbours.push_uniq(nbr);
} }
// Add all point-only neighbours by linear searching in edge neighbours. // Add all point-only neighbours by linear searching in edge neighbours.
@ -125,7 +125,7 @@ void Foam::cellDistFuncs::getPointNeighbours
for (const label facei : pointNbs) for (const label facei : pointNbs)
{ {
// Check for facei in edge-neighbours part of neighbours // Check for facei in edge-neighbours part of neighbours
neighbours.appendUniq(facei); neighbours.push_uniq(facei);
} }
} }

View File

@ -166,9 +166,9 @@ void Foam::meshToMeshMethod::appendNbrCells
// filter out cells already visited from cell neighbours // filter out cells already visited from cell neighbours
for (const label nbrCelli : nbrCells) for (const label nbrCelli : nbrCells)
{ {
if (!visitedCells.found(nbrCelli)) if (!visitedCells.contains(nbrCelli))
{ {
nbrCellIDs.appendUniq(nbrCelli); nbrCellIDs.push_uniq(nbrCelli);
} }
} }
} }

View File

@ -93,7 +93,7 @@ Foam::solidReaction<ReactionThermo>::solidReaction
speciesTable allSpecies(species); speciesTable allSpecies(species);
for (const word& gasName : pyrolisisGases_) for (const word& gasName : pyrolisisGases_)
{ {
allSpecies.appendUniq(gasName); allSpecies.push_uniq(gasName);
} }
List<specieCoeffs> dummyLhs; List<specieCoeffs> dummyLhs;
List<specieCoeffs> dummyRhs; List<specieCoeffs> dummyRhs;