ENH: consistency of HashSet setMany(), insertMany() with packed-list version

- this also provides a better separation of the intent
  (ie, inserting a single value, or inserting multiply values)
This commit is contained in:
Mark Olesen
2018-03-14 21:08:29 +01:00
parent 5d1fb23555
commit d17bc72585
64 changed files with 516 additions and 631 deletions

View File

@ -188,10 +188,10 @@ int main(int argc, char *argv[])
Info<< "setB : " << setB << endl;
labelPair pair(12, 15);
setB.set(pair);
setB.setMany(pair);
Info<< "setB : " << setB << endl;
setB.unset(pair);
setB.unsetMany(pair);
labelHashSet setC(1);
@ -257,7 +257,7 @@ int main(int argc, char *argv[])
someLst[elemI] = elemI*elemI;
}
label added = setD.set(someLst);
label added = setD.setMany(someLst);
Info<< "added " << added << " from " << someLst.size() << endl;
Info<< "setD : " << flatOutput(setD) << endl;

View File

@ -94,7 +94,7 @@ int main(int argc, char *argv[])
e4.start() = e4.end() = -1;
Info<< "insert from list\n";
labelHashSet newIndices({2, -1, 2, 1, 4, 1, 2, 3});
e4.insert(newIndices.toc());
e4.insertMany(newIndices.toc());
printInfo(e4);
e4.start() = e4.end() = -1;
@ -105,12 +105,12 @@ int main(int argc, char *argv[])
FixedList<label, 8> otherIndices{12, 2, -1, 1, 4, 1, 2, 3};
e4.start() = e4.end() = -1;
Info<< "insert from list: " << otherIndices << nl;
e4.insert(otherIndices);
e4.insertMany(otherIndices);
printInfo(e4);
e4.start() = e4.end();
Info<< "erase from list: " << otherIndices << nl;
Info<< "removed " << e4.erase(otherIndices) << " values" << nl;
Info<< "removed " << e4.eraseMany(otherIndices) << " values" << nl;
printInfo(e4);
for (label i : {-1, 0, 1, 3})

View File

@ -32,6 +32,8 @@ Description
#include "dictionary.H"
#include "nil.H"
#include "IOstreams.H"
#include "PstreamBuffers.H"
#include "Time.H"
namespace Foam
{
@ -101,6 +103,9 @@ int main(int argc, char *argv[])
cout<<"string:" << sizeof(Foam::string) << nl;
}
cout<<"IOstream:" << sizeof(Foam::IOstream) << nl;
cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl;
cout<<"Time:" << sizeof(Foam::Time) << nl;
Info << "---\nEnd\n" << endl;

View File

@ -122,10 +122,7 @@ int main(int argc, char *argv[])
const labelList& pCells = mesh.pointCells()[meshPointi];
forAll(pCells, pCelli)
{
cutCells.insert(pCells[pCelli]);
}
cutCells.insertMany(pCells);
}
}

View File

@ -184,11 +184,7 @@ int main(int argc, char *argv[])
const DynamicList<label>& bin = bins[binI];
cellSet cells(mesh, "vol" + name(binI), bin.size());
forAll(bin, i)
{
cells.insert(bin[i]);
}
cells.insertMany(bin);
Info<< " " << lowerLimits[binI] << " .. " << upperLimits[binI]
<< " : writing " << bin.size() << " cells to cellSet "

View File

@ -633,10 +633,7 @@ int main(int argc, char *argv[])
);
cellSet cutSet(mesh, "cutSet", cutCells.size());
forAll(cutCells, i)
{
cutSet.insert(cutCells[i]);
}
cutSet.insertMany(cutCells);
// Gets cuts across cells from cuts through edges.
Info<< "Writing " << cutSet.size() << " cells to cut to cellSet "

View File

@ -956,11 +956,7 @@ int main(int argc, char *argv[])
forAll(dofVertIndices, patchi)
{
const labelList& foamVerts = dofVertIndices[patchi];
forAll(foamVerts, i)
{
dofGroups[patchi].insert(foamVerts[i]);
}
dofGroups[patchi].insertMany(foamVerts);
}
List<DynamicList<face>> dynPatchFaces(dofVertIndices.size());

View File

@ -344,10 +344,7 @@ void writePointCells
{
const labelList& cEdges = mesh.cellEdges()[pCells[i]];
forAll(cEdges, i)
{
allEdges.insert(cEdges[i]);
}
allEdges.insertMany(cEdges);
}

View File

@ -795,10 +795,7 @@ int main(int argc, char *argv[])
forAll(addedCells, facei)
{
const labelList& aCells = addedCells[facei];
forAll(aCells, i)
{
addedCellsSet.insert(aCells[i]);
}
addedCellsSet.insertMany(aCells);
}
}
}

View File

@ -527,10 +527,7 @@ label findUncoveredPatchFace
{
// Make set of extruded faces.
labelHashSet extrudeFaceSet(extrudeMeshFaces.size());
forAll(extrudeMeshFaces, i)
{
extrudeFaceSet.insert(extrudeMeshFaces[i]);
}
extrudeFaceSet.insertMany(extrudeMeshFaces);
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
const labelList& eFaces = mesh.edgeFaces()[meshEdgeI];
@ -564,10 +561,7 @@ label findUncoveredCyclicPatchFace
{
// Make set of extruded faces.
labelHashSet extrudeFaceSet(extrudeMeshFaces.size());
forAll(extrudeMeshFaces, i)
{
extrudeFaceSet.insert(extrudeMeshFaces[i]);
}
extrudeFaceSet.insertMany(extrudeMeshFaces);
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
const labelList& eFaces = mesh.edgeFaces()[meshEdgeI];

View File

@ -1053,10 +1053,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
nInvalidPolyhedra++;
forAll(cells[cI], cFI)
{
wrongFaces.insert(cells[cI][cFI]);
}
wrongFaces.insertMany(cells[cI]);
}
}
@ -1096,11 +1093,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
if (nInternalFaces[cI] <= 1)
{
oneInternalFaceCells++;
forAll(cells[cI], cFI)
{
wrongFaces.insert(cells[cI][cFI]);
}
wrongFaces.insertMany(cells[cI]);
}
}
@ -1132,13 +1125,8 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
// forAll(f, fPtI)
// {
// label ptI = f[fPtI];
// const labelList& pC = ptCells[ptI];
// forAll(pC, pCI)
// {
// limitCells.insert(pC[pCI]);
// }
// limitCells.insertMany(pC);
// }
// }

View File

@ -1366,15 +1366,10 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findRemainingProtrusionSet
mesh.nCells()/1000
);
forAllConstIter(labelHashSet, protrudingBoundaryPoints, iter)
for (const label pointi : protrudingBoundaryPoints)
{
const label pointi = iter.key();
const labelList& pCells = mesh.pointCells()[pointi];
forAll(pCells, pCI)
{
protrudingCells.insert(pCells[pCI]);
}
protrudingCells.insertMany(pCells);
}
label protrudingCellsSize = protrudingCells.size();

View File

@ -349,11 +349,7 @@ int main(int argc, char *argv[])
forAll(oldToNew, oldCelli)
{
const labelList& added = oldToNew[oldCelli];
forAll(added, i)
{
newCells.insert(added[i]);
}
newCells.insertMany(added);
}
Info<< "Writing refined cells ("

View File

@ -301,10 +301,7 @@ void Foam::regionSide::walkAllPointConnectedFaces
const label facei = iter.key();
const labelList& fEdges = mesh.faceEdges()[facei];
forAll(fEdges, fEdgeI)
{
regionEdges.insert(fEdges[fEdgeI]);
}
regionEdges.insertMany(fEdges);
}

View File

@ -311,7 +311,7 @@ int main(int argc, char *argv[])
wordHashSet names;
forAllConstIters(rp, iter)
{
names.insert(iter.object());
names.insertMany(iter.object());
}
regionNames = names.sortedToc();

View File

@ -186,7 +186,7 @@ int main(int argc, char *argv[])
wordHashSet names;
forAllConstIters(rp, iter)
{
names.insert(iter.object());
names.insertMany(iter.object());
}
regionNames = names.sortedToc();

View File

@ -103,9 +103,9 @@ if (timeDirs.size())
fileName::FILE
);
forAll(contents, fileI)
for (const fileName& file : contents)
{
missing.erase(contents[fileI].name());
missing.erase(file.name());
}
volumeFields.erase(missing);

View File

@ -227,7 +227,7 @@ void Foam::vtkPVFoam::updateInfoLagrangian
for (const instant& t : dbPtr_().times())
{
names.insert
names.insertMany
(
readDir
(

View File

@ -123,7 +123,7 @@ Foam::boundaryInfo::boundaryInfo(const Time& runTime, const word& regionName)
if (dict.found("inGroups"))
{
dict.lookup("inGroups") >> groups_[patchI];
allGroupNames_.insert(groups_[patchI]);
allGroupNames_.insertMany(groups_[patchI]);
}
}
}

View File

@ -225,9 +225,9 @@ void syncEdges(const triSurface& p, labelHashSet& markedEdges)
const edgeList& edges = p.edges();
edgeHashSet edgeSet(2*markedEdges.size());
forAllConstIter(labelHashSet, markedEdges, iter)
for (const label edgei : markedEdges)
{
edgeSet.insert(edges[iter.key()]);
edgeSet.insert(edges[edgei]);
}
forAll(edges, edgei)

View File

@ -202,11 +202,7 @@ int main(int argc, char *argv[])
for (const wordRe& zoneName : zoneNames)
{
labelList zoneIDs = findStrings(zoneName, allZoneNames);
forAll(zoneIDs, j)
{
includeFaceZones.insert(zoneIDs[j]);
}
includeFaceZones.insertMany(zoneIDs);
if (zoneIDs.empty())
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,68 +33,36 @@ License
template<class Key, class Hash>
template<class InputIter>
inline Foam::label Foam::HashSet<Key, Hash>::insertMultiple
inline Foam::label Foam::HashSet<Key, Hash>::assignMany
(
const InputIter begIter,
const InputIter endIter
)
{
label changed = 0;
for (InputIter iter = begIter; iter != endIter; ++iter)
{
if (insert(*iter))
{
++changed;
}
}
return changed;
}
template<class Key, class Hash>
template<class InputIter>
inline Foam::label Foam::HashSet<Key, Hash>::assignMultiple
(
const InputIter begIter,
const InputIter endIter,
const label sz
const label nItems,
InputIter first,
InputIter last
)
{
if (!this->capacity())
{
// Could be zero-sized from a previous transfer()?
this->resize(sz);
this->resize(2*nItems);
}
else
{
this->clear();
}
return insertMultiple(begIter, endIter);
return insert(first, last);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Key, class Hash>
Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
:
parent_type(2*lst.size())
{
for (const auto& k : lst)
{
this->insert(k);
}
}
template<class Key, class Hash>
template<unsigned Size>
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst)
Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& list)
:
parent_type(2*lst.size())
parent_type(2*list.size())
{
for (const auto& k : lst)
for (const auto& k : list)
{
this->insert(k);
}
@ -102,11 +70,35 @@ Foam::HashSet<Key, Hash>::HashSet(const FixedList<Key, Size>& lst)
template<class Key, class Hash>
Foam::HashSet<Key, Hash>::HashSet(std::initializer_list<Key> lst)
Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& list)
:
parent_type(2*lst.size())
parent_type(2*list.size())
{
for (const auto& k : lst)
for (const auto& k : list)
{
this->insert(k);
}
}
template<class Key, class Hash>
Foam::HashSet<Key, Hash>::HashSet(const UIndirectList<Key>& list)
:
parent_type(2*list.size())
{
for (const auto& k : list)
{
this->insert(k);
}
}
template<class Key, class Hash>
Foam::HashSet<Key, Hash>::HashSet(std::initializer_list<Key> list)
:
parent_type(2*list.size())
{
for (const auto& k : list)
{
this->insert(k);
}
@ -132,24 +124,116 @@ Foam::HashSet<Key, Hash>::HashSet
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Key, class Hash>
Foam::label Foam::HashSet<Key, Hash>::insert(const UList<Key>& lst)
template<class InputIter>
inline Foam::label Foam::HashSet<Key, Hash>::insert
(
InputIter first,
InputIter last
)
{
return insertMultiple(lst.begin(), lst.end());
label changed = 0;
for (; first != last; ++first)
{
if (insert(*first))
{
++changed;
}
}
return changed;
}
template<class Key, class Hash>
inline Foam::label Foam::HashSet<Key, Hash>::insert
(
std::initializer_list<Key> list
)
{
return insert(list.begin(), list.end());
}
template<class Key, class Hash>
template<unsigned Size>
Foam::label Foam::HashSet<Key, Hash>::insert(const FixedList<Key, Size>& lst)
inline Foam::label Foam::HashSet<Key, Hash>::insertMany
(
const FixedList<Key, Size>& list
)
{
return insertMultiple(lst.begin(), lst.end());
return insert(list.begin(), list.end());
}
template<class Key, class Hash>
Foam::label Foam::HashSet<Key, Hash>::insert(std::initializer_list<Key> lst)
inline Foam::label Foam::HashSet<Key, Hash>::insertMany
(
const UList<Key>& list
)
{
return insertMultiple(lst.begin(), lst.end());
return insert(list.begin(), list.end());
}
template<class Key, class Hash>
inline Foam::label Foam::HashSet<Key, Hash>::insertMany
(
const UIndirectList<Key>& list
)
{
return insert(list.begin(), list.end());
}
template<class Key, class Hash>
template<class InputIter>
inline Foam::label Foam::HashSet<Key, Hash>::unset
(
InputIter first,
InputIter last
)
{
return this->parent_type::erase(first, last);
}
template<class Key, class Hash>
inline Foam::label Foam::HashSet<Key, Hash>::unset
(
std::initializer_list<Key> list
)
{
return unset(list.begin(), list.end());
}
template<class Key, class Hash>
template<unsigned Size>
inline Foam::label Foam::HashSet<Key, Hash>::unsetMany
(
const FixedList<Key, Size>& list
)
{
return unset(list.begin(), list.end());
}
template<class Key, class Hash>
inline Foam::label Foam::HashSet<Key, Hash>::unsetMany
(
const UList<Key>& list
)
{
return unset(list.begin(), list.end());
}
template<class Key, class Hash>
inline Foam::label Foam::HashSet<Key, Hash>::unsetMany
(
const UIndirectList<Key>& list
)
{
return unset(list.begin(), list.end());
}
@ -170,24 +254,24 @@ inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& rhs)
template<unsigned Size>
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& rhs)
{
assignMultiple(rhs.begin(), rhs.end(), 2*rhs.size());
assignMany(rhs.size(), rhs.begin(), rhs.end());
}
template<class Key, class Hash>
template<unsigned Size>
void Foam::HashSet<Key, Hash>::operator=(const FixedList<Key, Size>& rhs)
void Foam::HashSet<Key, Hash>::operator=(const UList<Key>& rhs)
{
assignMultiple(rhs.begin(), rhs.end(), 2*rhs.size());
assignMany(rhs.size(), rhs.begin(), rhs.end());
}
template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator=(std::initializer_list<Key> rhs)
{
assignMultiple(rhs.begin(), rhs.end(), 2*rhs.size());
assignMany(rhs.size(), rhs.begin(), rhs.end());
}

View File

@ -63,6 +63,7 @@ Description
#define HashSet_H
#include "HashTable.H"
#include "UIndirectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -87,21 +88,13 @@ class HashSet
{
// Private Member Functions
//- Insert values, using begin/end iterators.
//- Assign from the input iterator range
template<class InputIter>
inline label insertMultiple
inline label assignMany
(
const InputIter begIter,
const InputIter endIter
);
//- Assign using begin/end iterators.
template<class InputIter>
inline label assignMultiple
(
const InputIter begIter,
const InputIter endIter,
const label sz
const label nItems,
InputIter first,
InputIter last
);
@ -140,15 +133,18 @@ public:
parent_type(is)
{}
//- Construct from UList of Key
explicit HashSet(const UList<Key>& lst);
//- Construct from FixedList of Key
template<unsigned Size>
explicit HashSet(const FixedList<Key, Size>& lst);
explicit HashSet(const FixedList<Key, Size>& list);
//- Construct from UList of Key
explicit HashSet(const UList<Key>& list);
//- Construct from an indirect list
explicit HashSet(const UIndirectList<Key>& list);
//- Construct from an initializer list of Key
HashSet(std::initializer_list<Key> lst);
HashSet(std::initializer_list<Key> list);
//- Copy construct
HashSet(const this_type& hs)
@ -180,44 +176,12 @@ public:
return this->parent_type::insert(key, zero::null());
}
//- Insert keys from the list of Key
// \return The number of new elements inserted
label insert(const UList<Key>& lst);
//- Insert keys from the list of Key
// \return The number of new elements inserted
template<unsigned Size>
label insert(const FixedList<Key, Size>& lst);
//- Insert keys from a initializer list of Key
// \return The number of new elements inserted
label insert(std::initializer_list<Key> lst);
//- Same as insert (no value to overwrite)
bool set(const Key& key)
{
return insert(key);
}
//- Same as insert (no value to overwrite)
label set(const UList<Key>& lst)
{
return insert(lst);
}
//- Same as insert (no value to overwrite)
template<unsigned Size>
label set(const FixedList<Key, Size>& lst)
{
return insert(lst);
}
//- Same as insert (no value to overwrite)
label set(std::initializer_list<Key> lst)
{
return insert(lst);
}
//- Unset the specified key - same as erase
// \return True if the entry existed and was removed
bool unset(const Key& key)
@ -225,51 +189,84 @@ public:
return this->parent_type::erase(key);
}
// Convenience
//- Insert keys from the input iterator range
// \return The number of new elements inserted
template<class InputIter>
inline label insert(InputIter first, InputIter last);
//- Insert keys from a initializer list of Key
// \return The number of new elements inserted
inline label insert(std::initializer_list<Key> list);
//- Insert keys from the list of Key
// \return The number of new elements inserted
template<unsigned Size>
inline label insertMany(const FixedList<Key, Size>& list);
//- Insert keys from the list of Key
// \return The number of new elements inserted
inline label insertMany(const UList<Key>& list);
//- Insert keys from the list of Key
// \return The number of new elements inserted
inline label insertMany(const UIndirectList<Key>& list);
//- Same as insert (no value to overwrite)
template<class InputIter>
inline label set(InputIter first, InputIter last)
{
return insert(first, last);
}
//- Same as insert (no value to overwrite)
inline label set(std::initializer_list<Key> list)
{
return insert(list);
}
//- Same as insert (no value to overwrite)
template<unsigned Size>
inline label setMany(const FixedList<Key, Size>& list)
{
return insertMany(list);
}
//- Same as insertMany (no value to overwrite)
inline label setMany(const UList<Key>& list)
{
return insertMany(list);
}
//- Same as insertMany (no value to overwrite)
inline label setMany(const UIndirectList<Key>& list)
{
return insertMany(list);
}
//- Unset the keys listed in the input iterator range
// \return The number of items removed
template<class InputIter>
inline label unset(InputIter first, const InputIter last);
//- Unset the listed keys - same as erase
// \return The number of items removed
label unset(const UList<Key>& lst)
{
return this->parent_type::erase(lst);
}
inline label unset(std::initializer_list<Key> list);
//- Unset the listed keys - same as erase
// \return The number of items removed
template<unsigned Size>
label unset(const FixedList<Key, Size>& lst)
{
return this->parent_type::erase(lst);
}
inline label unsetMany(const FixedList<Key, Size>& list);
//- Unset the listed keys - same as erase
// \return The number of items removed
label unset(std::initializer_list<Key> lst)
{
return this->parent_type::erase(lst);
}
inline label unsetMany(const UList<Key>& list);
//- Not applicable for HashSet
template<class UnaryPredicate>
List<Key> tocValues(const UnaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class BinaryPredicate>
List<Key> tocEntries(const BinaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class UnaryPredicate>
label countValues(const UnaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class BinaryPredicate>
label countEntries(const BinaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class UnaryPredicate>
label filterValues(const UnaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class BinaryPredicate>
label filterEntries(const BinaryPredicate&, const bool) = delete;
//- Unset the listed keys - same as erase
// \return The number of items removed
inline label unsetMany(const UIndirectList<Key>& list);
// STL iterators
@ -330,7 +327,7 @@ public:
// Assignment
//- Assignment from a UList of keys
void operator=(const UList<Key>& lst);
void operator=(const UList<Key>& rhs);
//- Assignment from a FixedList of keys
template<unsigned Size>
@ -369,6 +366,33 @@ public:
const HashSet<Key, Hash>& tbl
);
// Housekeeping
//- Not applicable for HashSet
template<class UnaryPredicate>
List<Key> tocValues(const UnaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class BinaryPredicate>
List<Key> tocEntries(const BinaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class UnaryPredicate>
label countValues(const UnaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class BinaryPredicate>
label countEntries(const BinaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class UnaryPredicate>
label filterValues(const UnaryPredicate&, const bool) = delete;
//- Not applicable for HashSet
template<class BinaryPredicate>
label filterEntries(const BinaryPredicate&, const bool) = delete;
};

View File

@ -30,35 +30,6 @@ License
#include "List.H"
#include "FixedList.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class T, class Key, class Hash>
template<class InputIter>
Foam::label Foam::HashTable<T, Key, Hash>::eraseMultiple
(
const InputIter begIter,
const InputIter endIter
)
{
const label nTotal = this->size();
label changed = 0;
for
(
InputIter iter = begIter;
changed < nTotal && iter != endIter; // terminate early
++iter
)
{
if (this->erase(*iter))
{
++changed;
}
}
return changed;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, class Key, class Hash>
@ -435,30 +406,60 @@ bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
template<class T, class Key, class Hash>
Foam::label Foam::HashTable<T, Key, Hash>::erase(const UList<Key>& keys)
template<class InputIter>
inline Foam::label Foam::HashTable<T, Key, Hash>::erase
(
InputIter first,
InputIter last
)
{
return eraseMultiple(keys.cbegin(), keys.cend());
label changed = 0;
for
(
const label nTotal = this->size();
changed < nTotal && first != last; // terminate early
++first
)
{
if (this->erase(*first))
{
++changed;
}
}
return changed;
}
template<class T, class Key, class Hash>
inline Foam::label Foam::HashTable<T, Key, Hash>::erase
(
std::initializer_list<Key> keys
)
{
return erase(keys.begin(), keys.end());
}
template<class T, class Key, class Hash>
template<unsigned Size>
Foam::label Foam::HashTable<T, Key, Hash>::erase
inline Foam::label Foam::HashTable<T, Key, Hash>::eraseMany
(
const FixedList<Key, Size>& keys
)
{
return eraseMultiple(keys.cbegin(), keys.cend());
return erase(keys.cbegin(), keys.cend());
}
template<class T, class Key, class Hash>
Foam::label Foam::HashTable<T, Key, Hash>::erase
inline Foam::label Foam::HashTable<T, Key, Hash>::eraseMany
(
std::initializer_list<Key> keys
const UList<Key>& keys
)
{
return eraseMultiple(keys.begin(), keys.end());
return erase(keys.cbegin(), keys.cend());
}

View File

@ -311,18 +311,6 @@ protected:
//- An iterator with non-const access to HashTable internals.
friend class Iterator<false>;
// Protected Member Functions
//- Remove using begin/end iterators of listed keys
template<class InputIter>
inline label eraseMultiple
(
const InputIter begIter,
const InputIter endIter
);
public:
// Constructors
@ -495,19 +483,6 @@ public:
// \return True if the entry existed and was removed
bool erase(const Key& key);
//- Remove table entries given by the listed keys
// \return The number of items removed
label erase(const UList<Key>& keys);
//- Remove table entries given by the listed keys
// \return The number of items removed
template<unsigned Size>
label erase(const FixedList<Key, Size>& keys);
//- Remove table entries given by the listed keys
// \return The number of items removed
label erase(std::initializer_list<Key> keys);
//- Remove table entries given by keys of the other hash-table.
//
// The other hash-table must have the same type of key, but the
@ -517,6 +492,23 @@ public:
template<class AnyType, class AnyHash>
label erase(const HashTable<AnyType, Key, AnyHash>& other);
//- Remove table entries given by the listed keys
// \return The number of items removed
inline label erase(std::initializer_list<Key> keys);
//- Remove multiple entries using an iterator range of keys
template<class InputIter>
inline label erase(InputIter first, InputIter last);
//- Remove table entries given by the listed keys
// \return The number of items removed
template<unsigned Size>
inline label eraseMany(const FixedList<Key, Size>& keys);
//- Remove table entries given by the listed keys
// \return The number of items removed
inline label eraseMany(const UList<Key>& keys);
//- Retain table entries given by keys of the other hash-table.
//
// The other hash-table must have the same type of key, but the

View File

@ -305,7 +305,7 @@ bool Foam::functionObjectList::readFunctionObject
else if (args.size() > 1)
{
funcDict.set("fields", args);
requiredFields.insert(args);
requiredFields.insertMany(args);
}
else if (funcDict.found("field"))
{
@ -313,7 +313,7 @@ bool Foam::functionObjectList::readFunctionObject
}
else if (funcDict.found("fields"))
{
requiredFields.insert(wordReList(funcDict.lookup("fields")));
requiredFields.insertMany(wordReList(funcDict.lookup("fields")));
}
// Insert named arguments

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,25 +62,6 @@ class edge
:
public labelPair
{
// Private Member Functions
//- Insert values, using begin/end iterators.
template<class InputIter>
inline label insertMultiple
(
const InputIter begIter,
const InputIter endIter
);
//- Remove values, using begin/end iterators.
template<class InputIter>
inline label eraseMultiple
(
const InputIter begIter,
const InputIter endIter
);
public:
// Static data members
@ -100,13 +81,13 @@ public:
inline edge(const labelPair& pair);
//- Construct from list
inline edge(const FixedList<label, 2>& lst);
inline edge(const FixedList<label, 2>& list);
//- Construct from two point labels, sorted with first less-than second
inline edge(const label from, const label to, const bool doSort);
//- Construct from list, sorted with first less-than second
inline edge(const FixedList<label, 2>& lst, const bool doSort);
inline edge(const FixedList<label, 2>& list, const bool doSort);
//- Construct from Istream
inline edge(Istream& is);
@ -194,6 +175,7 @@ public:
//- 'Clears' edge by setting both ends to invalid point labels.
inline void clear();
//- Fill any open slot with the index if it did not previously exist.
// Returns true on success. A negative label never inserts.
// Similar to a HashTable::insert().
@ -203,20 +185,25 @@ public:
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
inline label insert(const labelUList& lst);
inline label insert(std::initializer_list<label> list);
//- Insert values, using begin/end iterators.
template<class InputIter>
inline label insert(InputIter begIter, InputIter endIter);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
// Similar to a HashTable::insertMany().
template<unsigned Size>
inline label insert(const FixedList<label, Size>& lst);
inline label insertMany(const FixedList<label, Size>& list);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
inline label insert(std::initializer_list<label> lst);
// Similar to a HashTable::insertMany().
inline label insertMany(const labelUList& list);
//- Remove an existing index from the edge and set its location to '-1'.
// Returns the number of changes. A negative label never removes.
@ -225,16 +212,20 @@ public:
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
inline label erase(const labelUList& lst);
inline label erase(std::initializer_list<label> list);
//- Remove values, using begin/end iterators.
template<class InputIter>
inline label erase(InputIter begIter, InputIter endIter);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
template<unsigned Size>
inline label erase(const FixedList<label, Size>& lst);
inline label eraseMany(const FixedList<label, Size>& list);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
inline label erase(std::initializer_list<label> lst);
inline label eraseMany(const labelUList& list);
// Geometric functions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,66 +33,6 @@ inline int Foam::edge::compare(const edge& a, const edge& b)
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class InputIter>
inline Foam::label Foam::edge::insertMultiple
(
const InputIter begIter,
const InputIter endIter
)
{
// Available slots.
// Don't use count() since it has special treatment for duplicates
const int maxChange = (first() < 0 ? 1 : 0) + (second() < 0 ? 1 : 0);
int changed = 0;
if (maxChange)
{
for (InputIter iter = begIter; iter != endIter; ++iter)
{
if (insert(*iter))
{
if (++changed >= maxChange)
{
break;
}
}
}
}
return changed;
}
template<class InputIter>
inline Foam::label Foam::edge::eraseMultiple
(
const InputIter begIter,
const InputIter endIter
)
{
// Occupied slots.
// Don't use count() since it has special treatment for duplicates
const int maxChange = (first() >= 0 ? 1 : 0) + (second() >= 0 ? 1 : 0);
int changed = 0;
if (maxChange)
{
for (InputIter iter = begIter; iter != endIter; ++iter)
{
changed += erase(*iter);
if (changed >= maxChange)
{
break;
}
}
}
return changed;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::edge::edge()
@ -113,9 +53,9 @@ inline Foam::edge::edge(const labelPair& pair)
{}
inline Foam::edge::edge(const FixedList<label, 2>& lst)
inline Foam::edge::edge(const FixedList<label, 2>& list)
:
labelPair(lst.first(), lst.last())
labelPair(list.first(), list.last())
{}
@ -125,9 +65,9 @@ inline Foam::edge::edge(const label from, const label to, const bool doSort)
{}
inline Foam::edge::edge(const FixedList<label, 2>& lst, const bool doSort)
inline Foam::edge::edge(const FixedList<label, 2>& list, const bool doSort)
:
labelPair(lst, doSort)
labelPair(list, doSort)
{}
@ -329,22 +269,46 @@ inline bool Foam::edge::insert(const label index)
}
inline Foam::label Foam::edge::insert(const labelUList& lst)
template<class InputIter>
inline Foam::label Foam::edge::insert
(
InputIter begIter,
InputIter endIter
)
{
return insertMultiple(lst.begin(), lst.end());
// Available slots.
// Don't use count() since it has special treatment for duplicates
const int maxChange = ((first() < 0 ? 1 : 0) + (second() < 0 ? 1 : 0));
int changed = 0;
for (; changed < maxChange && begIter != endIter; ++begIter)
{
if (insert(*begIter))
{
++changed;
}
}
return changed;
}
inline Foam::label Foam::edge::insert(std::initializer_list<label> list)
{
return insert(list.begin(), list.end());
}
template<unsigned Size>
inline Foam::label Foam::edge::insert(const FixedList<label, Size>& lst)
inline Foam::label Foam::edge::insertMany(const FixedList<label, Size>& list)
{
return insertMultiple(lst.begin(), lst.end());
return insert(list.begin(), list.end());
}
inline Foam::label Foam::edge::insert(std::initializer_list<label> lst)
inline Foam::label Foam::edge::insertMany(const labelUList& list)
{
return insertMultiple(lst.begin(), lst.end());
return insert(list.begin(), list.end());
}
@ -374,22 +338,43 @@ inline Foam::label Foam::edge::erase(const label index)
}
inline Foam::label Foam::edge::erase(const labelUList& lst)
template<class InputIter>
inline Foam::label Foam::edge::erase
(
InputIter begIter,
InputIter endIter
)
{
return eraseMultiple(lst.begin(), lst.end());
// Occupied slots.
// Don't use count() since it has special treatment for duplicates
const int maxChange = ((first() >= 0 ? 1 : 0) + (second() >= 0 ? 1 : 0));
int changed = 0;
for (; changed < maxChange && begIter != endIter; ++begIter)
{
changed += erase(*begIter);
}
return changed;
}
inline Foam::label Foam::edge::erase(std::initializer_list<label> list)
{
return erase(list.begin(), list.end());
}
template<unsigned Size>
inline Foam::label Foam::edge::erase(const FixedList<label, Size>& lst)
inline Foam::label Foam::edge::eraseMany(const FixedList<label, Size>& list)
{
return eraseMultiple(lst.begin(), lst.end());
return erase(list.begin(), list.end());
}
inline Foam::label Foam::edge::erase(std::initializer_list<label> lst)
inline Foam::label Foam::edge::eraseMany(const labelUList& list)
{
return eraseMultiple(lst.begin(), lst.end());
return erase(list.begin(), list.end());
}

View File

@ -784,11 +784,7 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
// Treat the given patch names as wild-cards and search the set
// of all patch names for matches
labelList patchIDs = findStrings(patchName, allPatchNames);
forAll(patchIDs, j)
{
ids.insert(patchIDs[j]);
}
ids.insertMany(patchIDs);
if (patchIDs.empty())
{
@ -803,11 +799,7 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
{
const word& name = allGroupNames[groupIDs[i]];
const labelList& extraPatchIDs = groupPatchIDs()[name];
forAll(extraPatchIDs, extraI)
{
ids.insert(extraPatchIDs[extraI]);
}
ids.insertMany(extraPatchIDs);
}
if (groupIDs.empty() && warnNotFound)

View File

@ -75,7 +75,7 @@ const Foam::labelList& Foam::primitiveMesh::cellPoints
for (const label facei : cFaces)
{
set.insert(fcs[facei]);
set.insertMany(fcs[facei]);
}
storage.clear();

View File

@ -646,7 +646,7 @@ const Foam::labelList& Foam::primitiveMesh::cellEdges
for (const label facei : cFaces)
{
set.insert(faceEdges(facei));
set.insertMany(faceEdges(facei));
}
storage.clear();

View File

@ -124,9 +124,9 @@ void Foam::vtk::vtuSizing::reset
bool first = true;
const cell& cFaces = mesh.cells()[celli];
forAll(cFaces, cFaceI)
for (const label facei : cFaces)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
const face& f = mesh.faces()[facei];
// Face decomposed into triangles and quads
// Tri -> Tet, Quad -> Pyr
@ -160,12 +160,12 @@ void Foam::vtk::vtuSizing::reset
// number of faces, size of each face, vertices per face
// [nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...]
forAll(cFaces, cFaceI)
for (const label facei : cFaces)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
const face& f = mesh.faces()[facei];
nFaceLabels_ += f.size();
hashUniqId.insert(f);
hashUniqId.insertMany(f);
}
// Legacy format only uses the face-stream.

View File

@ -545,10 +545,7 @@ void Foam::vtk::vtuSizing::populateArrays
const face& f = mesh.faces()[cFaces[cFaceI]];
const bool isOwner = (owner[cFaces[cFaceI]] == celli);
forAll(f, fp)
{
hashUniqId.insert(f[fp]);
}
hashUniqId.insertMany(f);
// number of labels for this face
faceOutput[faceIndexer++] = f.size();

View File

@ -329,11 +329,7 @@ void Foam::attachDetach::detachInterface
{ // Protection and memory management
// Make a map of master cells for quick reject
labelHashSet mcMap(2*mc.size());
forAll(mc, mcI)
{
mcMap.insert(mc[mcI]);
}
mcMap.insertMany(mc);
// Go through all the faces in the masterCellFaceMap. If the
// cells around them are not already used, add all of their
@ -349,11 +345,7 @@ void Foam::attachDetach::detachInterface
{
// Cell not found. Add its faces to the map
const cell& curFaces = cells[ownCell];
forAll(curFaces, facei)
{
masterCellFaceMap.insert(curFaces[facei]);
}
masterCellFaceMap.insertMany(curFaces);
}
// Do the neighbour side if face is internal
@ -365,11 +357,7 @@ void Foam::attachDetach::detachInterface
{
// Cell not found. Add its faces to the map
const cell& curFaces = cells[neiCell];
forAll(curFaces, facei)
{
masterCellFaceMap.insert(curFaces[facei]);
}
masterCellFaceMap.insertMany(curFaces);
}
}
}

View File

@ -228,10 +228,7 @@ Foam::wordList Foam::fvMeshDistribute::mergeWordList(const wordList& procNames)
wordHashSet mergedNames;
forAll(allNames, proci)
{
forAll(allNames[proci], i)
{
mergedNames.insert(allNames[proci][i]);
}
mergedNames.insertMany(allNames[proci]);
}
return mergedNames.toc();
}

View File

@ -99,7 +99,7 @@ Foam::labelHashSet Foam::motionSmootherAlgo::getPoints
for (const label faceId : faceLabels)
{
usedPoints.insert(mesh_.faces()[faceId]);
usedPoints.insertMany(mesh_.faces()[faceId]);
}
return usedPoints;
@ -115,7 +115,7 @@ Foam::labelHashSet Foam::motionSmootherAlgo::getPoints
for (const label faceId : faceLabels)
{
usedPoints.insert(mesh_.faces()[faceId]);
usedPoints.insertMany(mesh_.faces()[faceId]);
}
return usedPoints;
@ -217,11 +217,11 @@ void Foam::motionSmootherAlgo::scaleField
pointScalarField& fld
) const
{
forAllConstIter(labelHashSet, pointLabels, iter)
for (const label pointi : pointLabels)
{
if (isInternalPoint(iter.key()))
if (isInternalPoint(pointi))
{
fld[iter.key()] *= scale;
fld[pointi] *= scale;
}
}
@ -239,10 +239,8 @@ void Foam::motionSmootherAlgo::scaleField
pointScalarField& fld
) const
{
forAll(meshPoints, i)
for (const label pointi : meshPoints)
{
label pointi = meshPoints[i];
if (pointLabels.found(pointi))
{
fld[pointi] *= scale;
@ -330,10 +328,7 @@ void Foam::motionSmootherAlgo::getAffectedFacesAndPoints
{
const cell& cFaces = mesh_.cells()[pCells[pCelli]];
forAll(cFaces, cFacei)
{
nbrFaces.insert(cFaces[cFacei]);
}
nbrFaces.insertMany(cFaces);
}
}
nbrFaces.sync(mesh_);
@ -949,20 +944,14 @@ bool Foam::motionSmootherAlgo::scaleMesh
label own = mesh_.faceOwner()[iter.key()];
const cell& ownFaces = mesh_.cells()[own];
forAll(ownFaces, cfI)
{
newWrongFaces.insert(ownFaces[cfI]);
}
newWrongFaces.insertMany(ownFaces);
if (iter.key() < mesh_.nInternalFaces())
{
label nei = mesh_.faceNeighbour()[iter.key()];
const cell& neiFaces = mesh_.cells()[nei];
forAll(neiFaces, cfI)
{
newWrongFaces.insert(neiFaces[cfI]);
}
newWrongFaces.insertMany(neiFaces);
}
}
wrongFaces.transfer(newWrongFaces);

View File

@ -262,10 +262,7 @@ void Foam::perfectInterface::setRefinement
{
const labelList& pFaces = mesh.pointFaces()[meshPointi];
forAll(pFaces, pFacei)
{
affectedFaces.insert(pFaces[pFacei]);
}
affectedFaces.insertMany(pFaces);
}
}
forAll(pp1, i)

View File

@ -5523,10 +5523,7 @@ void Foam::hexRef8::setUnrefinement
{
const labelList& pCells = mesh_.pointCells(splitPointLabels[i]);
forAll(pCells, j)
{
cSet.insert(pCells[j]);
}
cSet.insertMany(pCells);
}
cSet.write();
@ -5550,10 +5547,7 @@ void Foam::hexRef8::setUnrefinement
{
const labelList& pFaces = mesh_.pointFaces()[splitPointLabels[i]];
forAll(pFaces, j)
{
splitFaces.insert(pFaces[j]);
}
splitFaces.insertMany(pFaces);
}
// Check with faceRemover what faces will get removed. Note that this

View File

@ -343,10 +343,7 @@ void Foam::removePoints::setRefinement
// Store faces affected
const labelList& pFaces = mesh_.pointFaces()[pointi];
forAll(pFaces, i)
{
facesAffected.insert(pFaces[i]);
}
facesAffected.insertMany(pFaces);
}
}

View File

@ -186,10 +186,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
// edges
for (const label slaveEdgei : curSlaveEdges)
{
usedMasterEdges[slaveEdgei].insert
(
curMasterEdges
);
usedMasterEdges[slaveEdgei].insertMany(curMasterEdges);
}
}
else if (slavePointEdgeHits[pointi] > -1)
@ -214,7 +211,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
{
const labelList& curMasterEdges = masterPointEdges[masterPointi];
usedMasterEdges[masterPointEdgeHits[masterPointi]].insert
usedMasterEdges[masterPointEdgeHits[masterPointi]].insertMany
(
curMasterEdges
);
@ -574,10 +571,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const
// << masterPatch.localFaces()[facei]
// << endl;
curMasterEdgesMap.insert
(
masterFaceEdges[facei]
);
curMasterEdgesMap.insertMany(masterFaceEdges[facei]);
}
const labelList curMasterEdges(curMasterEdgesMap.toc());

View File

@ -880,8 +880,7 @@ bool Foam::slidingInterface::projectPoints() const
for (const label facei : curFaceMap)
{
const face& f = masterLocalFaces[facei];
curPointMap.insert(f); // Insert all face points
curPointMap.insertMany(f); // Insert all face points
}
const labelList curMasterPoints = curPointMap.toc();

View File

@ -1455,10 +1455,8 @@ void Foam::faMesh::calcPointAreaNormalsByQuadricsFit() const
procPatch.neighbPoints()[nonGlobalPatchPoints[pointI]];
labelHashSet faceSet;
forAll(pointFaces[curPoint], faceI)
{
faceSet.insert(pointFaces[curPoint][faceI]);
}
faceSet.insertMany(pointFaces[curPoint]);
labelList curFaces = faceSet.toc();
labelHashSet pointSet;

View File

@ -34,13 +34,10 @@ void Foam::functionObjects::fieldSelection::addRegistered
wordHashSet& set
) const
{
DynamicList<word> names;
for (const wordRe& name : *this)
{
names.append(obr_.names<Type>(name));
set.insertMany(obr_.names<Type>(name));
}
set.insert(names);
}

View File

@ -26,7 +26,6 @@ License
#include "IOobjectList.H"
#include "GeometricField.H"
#include "fvMesh.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
@ -37,14 +36,10 @@ void Foam::functionObjects::fileFieldSelection::addFromFile
wordHashSet& set
) const
{
DynamicList<word> names(this->size());
for (const wordRe& fieldName : *this)
{
names.append(allFileObjects.names(Type::typeName, fieldName));
set.insertMany(allFileObjects.names(Type::typeName, fieldName));
}
set.insert(names);
}

View File

@ -1050,10 +1050,7 @@ void Foam::isoAdvection::writeSurfaceCells() const
)
);
forAll(surfCells_, i)
{
cSet.insert(surfCells_[i]);
}
cSet.insertMany(surfCells_);
cSet.write();
}

View File

@ -248,10 +248,7 @@ void Foam::cellToCellStencil::unionEqOp::operator()
else
{
labelHashSet set(x);
forAll(y, i)
{
set.insert(y[i]);
}
set.insertMany(y);
x = set.toc();
}
}

View File

@ -249,10 +249,7 @@ void Foam::cellToFaceStencil::unionEqOp::operator()
else
{
labelHashSet set(x);
forAll(y, i)
{
set.insert(y[i]);
}
set.insertMany(y);
x = set.toc();
}
}
@ -391,19 +388,11 @@ void Foam::cellToFaceStencil::calcFaceStencil
const labelList& ownCCells = globalCellCells[own[facei]];
label globalOwn = ownCCells[0];
// Insert cellCells
forAll(ownCCells, i)
{
faceStencilSet.insert(ownCCells[i]);
}
faceStencilSet.insertMany(ownCCells); // Insert cellCells
const labelList& neiCCells = globalCellCells[nei[facei]];
label globalNei = neiCCells[0];
// Insert cellCells
forAll(neiCCells, i)
{
faceStencilSet.insert(neiCCells[i]);
}
faceStencilSet.insertMany(neiCCells); // Insert cellCells
// Guarantee owner first, neighbour second.
faceStencil[facei].setSize(faceStencilSet.size());
@ -433,19 +422,13 @@ void Foam::cellToFaceStencil::calcFaceStencil
const labelList& ownCCells = globalCellCells[own[facei]];
label globalOwn = ownCCells[0];
forAll(ownCCells, i)
{
faceStencilSet.insert(ownCCells[i]);
}
faceStencilSet.insertMany(ownCCells);
// And the neighbours of the coupled cell
const labelList& neiCCells =
neiGlobalCellCells[facei-mesh_.nInternalFaces()];
label globalNei = neiCCells[0];
forAll(neiCCells, i)
{
faceStencilSet.insert(neiCCells[i]);
}
faceStencilSet.insertMany(neiCCells);
// Guarantee owner first, neighbour second.
faceStencil[facei].setSize(faceStencilSet.size());
@ -475,10 +458,7 @@ void Foam::cellToFaceStencil::calcFaceStencil
const labelList& ownCCells = globalCellCells[own[facei]];
label globalOwn = ownCCells[0];
forAll(ownCCells, i)
{
faceStencilSet.insert(ownCCells[i]);
}
faceStencilSet.insertMany(ownCCells);
// Guarantee owner first
faceStencil[facei].setSize(faceStencilSet.size());

View File

@ -146,16 +146,16 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
}
else
{
fieldSet_.insert(wordList(dict.lookup("fields")));
fieldSet_.insertMany(wordList(dict.lookup("fields")));
}
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
{
Info<< "storing fields:" << nl;
forAllConstIter(wordHashSet, fieldSet_, iter)
for (const word& f : fieldSet_)
{
Info<< " " << modelName << ':' << iter.key() << nl;
Info<< " " << modelName << ':' << f << nl;
}
Info<< endl;
}
@ -177,9 +177,8 @@ bool Foam::functionObjects::turbulenceFields::execute()
const compressible::turbulenceModel& model =
obr_.lookupObject<compressible::turbulenceModel>(modelName);
forAllConstIter(wordHashSet, fieldSet_, iter)
for (const word& f : fieldSet_)
{
const word& f = iter.key();
switch (compressibleFieldNames_[f])
{
case cfK:
@ -250,9 +249,8 @@ bool Foam::functionObjects::turbulenceFields::execute()
const incompressible::turbulenceModel& model =
obr_.lookupObject<incompressible::turbulenceModel>(modelName);
forAllConstIter(wordHashSet, fieldSet_, iter)
for (const word& f : fieldSet_)
{
const word& f = iter.key();
switch (incompressibleFieldNames_[f])
{
case ifK:
@ -315,9 +313,9 @@ bool Foam::functionObjects::turbulenceFields::execute()
bool Foam::functionObjects::turbulenceFields::write()
{
forAllConstIter(wordHashSet, fieldSet_, iter)
for (const word& f : fieldSet_)
{
const word fieldName = modelName + ':' + iter.key();
const word fieldName = modelName + ':' + f;
writeObject(fieldName);
}

View File

@ -92,7 +92,7 @@ Foam::ParticleErosion<CloudType>::ParticleErosion
<< endl;
}
uniqIds.insert(ids);
uniqIds.insertMany(ids);
}
patchIDs_ = uniqIds.sortedToc();

View File

@ -149,7 +149,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
<< endl;
}
uniqIds.insert(ids);
uniqIds.insertMany(ids);
}
patchIDs_ = uniqIds.sortedToc();

View File

@ -1011,7 +1011,7 @@ Foam::label Foam::meshRefinement::splitFacesUndo
{
const labelList grownFaces(growFaceCellFace(errorFaces));
errorFaces.clear();
errorFaces.insert(grownFaces);
errorFaces.insertMany(grownFaces);
}

View File

@ -625,10 +625,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
{
const cell& ownFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
forAll(ownFaces, i)
{
baffledFacesSet.insert(ownFaces[i]);
}
baffledFacesSet.insertMany(ownFaces);
}
}
// Pick up neighbour side of baffle (added faces)
@ -640,10 +637,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
{
const cell& ownFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
forAll(ownFaces, i)
{
baffledFacesSet.insert(ownFaces[i]);
}
baffledFacesSet.insertMany(ownFaces);
}
}
baffledFacesSet.sync(mesh_);

View File

@ -227,19 +227,13 @@ Foam::label Foam::meshRefinement::mergePatchFaces
//
// const cell& ownFaces = cells[mesh_.faceOwner()[faceI]];
//
// forAll(ownFaces, i)
// {
// retestFaces.insert(ownFaces[i]);
// }
// retestFaces.insertMany(ownFaces);
//
// if (mesh_.isInternalFace(faceI))
// {
// const cell& neiFaces = cells[mesh_.faceNeighbour()[faceI]];
//
// forAll(neiFaces, i)
// {
// retestFaces.insert(neiFaces[i]);
// }
// retestFaces.insertMany(neiFaces);
// }
// }
// updateMesh(map, retestFaces.toc());
@ -337,10 +331,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
faceSet allSets(mesh_, "allFaceSets", allFaceSets.size());
forAll(allFaceSets, setI)
{
forAll(allFaceSets[setI], i)
{
allSets.insert(allFaceSets[setI][i]);
}
allSets.insertMany(allFaceSets[setI]);
}
Pout<< "Writing all faces to be merged to set "
<< allSets.objectPath() << endl;

View File

@ -300,10 +300,7 @@ void Foam::cellClassification::markCells
// Mark faces of celli
const labelList& myFaces = mesh_.cells()[celli];
forAll(myFaces, myFacei)
{
outsideFacesMap.insert(myFaces[myFacei]);
}
outsideFacesMap.insertMany(myFaces);
}
}

View File

@ -172,11 +172,7 @@ Foam::label Foam::cellDistFuncs::getPointNeighbours
forAll(f, fp)
{
const labelList& pointNbs = patch.pointFaces()[f[fp]];
forAll(pointNbs, i)
{
nbs.insert(pointNbs[i]);
}
nbs.insertMany(pointNbs);
}
// Subtract ours.

View File

@ -301,11 +301,7 @@ void Foam::meshTools::writeOBJ
forAll(cellLabels, i)
{
const cell& cFaces = cells[cellLabels[i]];
forAll(cFaces, j)
{
usedFaces.insert(cFaces[j]);
}
usedFaces.insertMany(cFaces);
}
writeOBJ(os, faces, points, usedFaces.toc());

View File

@ -160,10 +160,7 @@ void Foam::normalToFace::applyToSet
}
}
forAll(toBeRemoved, i)
{
set.erase(toBeRemoved[i]);
}
set.eraseMany(toBeRemoved);
}
}

View File

@ -384,11 +384,7 @@ Foam::labelHashSet Foam::triSurfaceTools::getCollapsedFaces
const labelList& myFaces = surf.edgeFaces()[edgeI];
labelHashSet facesToBeCollapsed(2*myFaces.size());
forAll(myFaces, myFacei)
{
facesToBeCollapsed.insert(myFaces[myFacei]);
}
facesToBeCollapsed.insertMany(myFaces);
// From faces using v1 check if they share an edge with faces
// using v2.

View File

@ -85,7 +85,7 @@ Foam::labelList Foam::structuredDecomp::decompose
labelHashSet patchCells(2*nFaces);
for (const label patchi : patchIDs)
{
patchCells.insert(pbm[patchi].faceCells());
patchCells.insertMany(pbm[patchi].faceCells());
}
// Subset the layer of cells next to the patch

View File

@ -62,11 +62,7 @@ injectionModelList::injectionModelList
{
const wordList activeModels(dict.lookup("injectionModels"));
wordHashSet models;
forAll(activeModels, i)
{
models.insert(activeModels[i]);
}
wordHashSet models(activeModels);
Info<< " Selecting film injection models" << endl;
if (models.size() > 0)
@ -74,9 +70,8 @@ injectionModelList::injectionModelList
this->setSize(models.size());
label i = 0;
forAllConstIter(wordHashSet, models, iter)
for (const word& model : models)
{
const word& model = iter.key();
set(i, injectionModel::New(film, dict, model));
i++;
}

View File

@ -65,11 +65,7 @@ transferModelList::transferModelList
dict.lookupOrDefault("transferModels", wordList())
);
wordHashSet models;
forAll(activeModels, i)
{
models.insert(activeModels[i]);
}
wordHashSet models(activeModels);
Info<< " Selecting film transfer models" << endl;
if (models.size() > 0)
@ -77,9 +73,8 @@ transferModelList::transferModelList
this->setSize(models.size());
label i = 0;
forAllConstIter(wordHashSet, models, iter)
for (const word& model : models)
{
const word& model = iter.key();
set(i, transferModel::New(film, dict, model));
i++;
}

View File

@ -158,13 +158,9 @@ Foam::labelList Foam::structuredRenumber::renumber
// Extract a submesh.
labelHashSet patchCells(2*nFaces);
forAllConstIter(labelHashSet, patchIDs, iter)
for (const label patchId : patchIDs)
{
const labelUList& fc = pbm[iter.key()].faceCells();
forAll(fc, i)
{
patchCells.insert(fc[i]);
}
patchCells.insertMany(pbm[patchId].faceCells());
}
label nTotalSeeds = returnReduce(patchCells.size(), sumOp<label>());

View File

@ -177,17 +177,17 @@ Foam::label Foam::probes::prepare()
{
wordHashSet currentFields;
currentFields.insert(scalarFields_);
currentFields.insert(vectorFields_);
currentFields.insert(sphericalTensorFields_);
currentFields.insert(symmTensorFields_);
currentFields.insert(tensorFields_);
currentFields.insertMany(scalarFields_);
currentFields.insertMany(vectorFields_);
currentFields.insertMany(sphericalTensorFields_);
currentFields.insertMany(symmTensorFields_);
currentFields.insertMany(tensorFields_);
currentFields.insert(surfaceScalarFields_);
currentFields.insert(surfaceVectorFields_);
currentFields.insert(surfaceSphericalTensorFields_);
currentFields.insert(surfaceSymmTensorFields_);
currentFields.insert(surfaceTensorFields_);
currentFields.insertMany(surfaceScalarFields_);
currentFields.insertMany(surfaceVectorFields_);
currentFields.insertMany(surfaceSphericalTensorFields_);
currentFields.insertMany(surfaceSymmTensorFields_);
currentFields.insertMany(surfaceTensorFields_);
DebugInfo
<< "Probing fields: " << currentFields << nl
@ -229,10 +229,8 @@ Foam::label Foam::probes::prepare()
}
// currentFields now just has the new fields - open streams for them
forAllConstIter(wordHashSet, currentFields, iter)
for (const word& fieldName : currentFields)
{
const word& fieldName = iter.key();
// Create directory if does not exist.
mkDir(probeDir);

View File

@ -236,11 +236,11 @@ bool Foam::surfMeshSamplers::execute()
// The acceptable fields
wordHashSet acceptable(added);
acceptable.insert(acceptType<scalar>());
acceptable.insert(acceptType<vector>());
acceptable.insert(acceptType<sphericalTensor>());
acceptable.insert(acceptType<symmTensor>());
acceptable.insert(acceptType<tensor>());
acceptable.insertMany(acceptType<scalar>());
acceptable.insertMany(acceptType<vector>());
acceptable.insertMany(acceptType<sphericalTensor>());
acceptable.insertMany(acceptType<symmTensor>());
acceptable.insertMany(acceptType<tensor>());
const wordList fields = acceptable.sortedToc();
if (!fields.empty())