BUG: incorrect HashTable / HashSet instances

- Eg instead of using labelHashSet, used HashSet<label> which uses
  the string::hash for hashing. Other places inadvertently using the
  string::hash instead of Hash<label> for hashing.

STYLE: use Map<..> instead of HashTable<.., label, Hash<label>>

- reduces clutter
This commit is contained in:
Mark Olesen
2018-02-09 09:30:02 +01:00
parent 806b668418
commit 09a6e94073
15 changed files with 47 additions and 88 deletions

View File

@ -853,7 +853,7 @@ int main(int argc, char *argv[])
labelList own(boundaryFaces.size(), -1);
labelList nei(boundaryFaces.size(), -1);
HashTable<label, label> faceToCell[2];
Map<label> faceToCell[2];
{
HashTable<label, face, Hash<face>> faceToFaceID(boundaryFaces.size());

View File

@ -54,13 +54,6 @@ Foam::PrintTable<KeyType, DataType>::PrintTable
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class KeyType, class DataType>
Foam::PrintTable<KeyType, DataType>::~PrintTable()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class KeyType, class DataType>
@ -71,7 +64,7 @@ void Foam::PrintTable<KeyType, DataType>::print
const bool printAverage
) const
{
HashTable<HashTable<DataType, label>, KeyType> combinedTable;
HashTable<Map<DataType>, KeyType> combinedTable;
List<HashTableData> procData(Pstream::nProcs(), HashTableData());
@ -90,36 +83,25 @@ void Foam::PrintTable<KeyType, DataType>::print
{
const HashTableData& procIData = procData[proci];
for
(
typename HashTableData::const_iterator iter = procIData.begin();
iter != procIData.end();
++iter
)
forAllConstIters(procIData, iter)
{
if (!combinedTable.found(iter.key()))
{
combinedTable.insert
(
iter.key(),
HashTable<DataType, label>()
Map<DataType>()
);
}
HashTable<DataType, label>& key = combinedTable[iter.key()];
Map<DataType>& key = combinedTable[iter.key()];
key.insert(proci, iter());
key.insert(proci, iter.object());
for
(
typename HashTable<DataType, label>
::const_iterator dataIter = key.begin();
dataIter != key.end();
++dataIter
)
forAllConstIters(key, dataIter)
{
std::ostringstream buf;
buf << dataIter();
buf << dataIter.object();
largestDataLength = max
(
@ -172,7 +154,7 @@ void Foam::PrintTable<KeyType, DataType>::print
forAll(sortedTable, keyI)
{
const HashTable<DataType, label>& procDataList
const Map<DataType>& procDataList
= combinedTable[sortedTable[keyI]];
os.width(largestKeyLength);

View File

@ -101,7 +101,7 @@ public:
//- Destructor
~PrintTable();
~PrintTable() = default;
// Member Functions

View File

@ -33,18 +33,12 @@ Foam::pointFeatureEdgesTypes::pointFeatureEdgesTypes
const label pointLabel
)
:
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>(),
HashTable<label, extendedFeatureEdgeMesh::edgeStatus, Hash<label>>(),
feMesh_(feMesh),
pointLabel_(pointLabel)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointFeatureEdgesTypes::~pointFeatureEdgesTypes()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::List<Foam::extendedFeatureEdgeMesh::edgeStatus>
@ -79,18 +73,12 @@ Foam::Ostream& Foam::operator<<
{
os << "Point = " << p.pointLabel_ << endl;
for
(
HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
::const_iterator iter = p.cbegin();
iter != p.cend();
++iter
)
forAllConstIters(p, iter)
{
os << " "
<< extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()]
<< " = "
<< iter()
<< iter.object()
<< endl;
}

View File

@ -58,7 +58,7 @@ Ostream& operator<<(Ostream&, const pointFeatureEdgesTypes&);
//- Hold the types of feature edges attached to the point.
class pointFeatureEdgesTypes
:
public HashTable<label, extendedFeatureEdgeMesh::edgeStatus>
public HashTable<label, extendedFeatureEdgeMesh::edgeStatus, Hash<label>>
{
// Private data
@ -82,7 +82,7 @@ public:
//- Destructor
~pointFeatureEdgesTypes();
~pointFeatureEdgesTypes() = default;
// Member Functions