mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add missing Hash function for List/UList (issue #966)
- there were previously no hashing mechanisms for lists so they would fall back to the definition for primitives and hash the memory location of the allocated List object. - provide a UList::Hash<> sub-class for inheritance, and also a global specialization for UList<T>, List<T> such that the hash value for List<List<T>> cascades properly. - provide similar function in triFace to ensure that it remains similar in behaviour to face. - added SymmHash to Pair, for use when order is unimportant. STYLE: use string::hash() more consistently - no particular reason to use Hash<word>() which forwards to string::hash() anyhow
This commit is contained in:
@ -598,6 +598,20 @@ int main(int argc, char *argv[])
|
||||
<< "-wordList: " << flatOutput(wLst) << nl
|
||||
<< "-stringList: " << flatOutput(sLst) << endl;
|
||||
|
||||
// Hash values
|
||||
{
|
||||
labelList list1(identity(5));
|
||||
labelList list2(identity(5));
|
||||
|
||||
Info<<"hash of " << flatOutput(list1)
|
||||
<< " = " << Hash<labelList>()(list1) << " or "
|
||||
<< labelList::Hash<>()(list1) << nl;
|
||||
|
||||
Info<<"hash of " << flatOutput(list2) << " = "
|
||||
<< Hash<labelList>()(list2) << " or "
|
||||
<< labelList::Hash<>()(list2) << nl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user