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:
@ -139,13 +139,16 @@ int main(int argc, char *argv[])
|
||||
FixedList<label, 4> list1{2, 3, 4, 5};
|
||||
|
||||
Info<< "list1:" << list1
|
||||
<< " hash:" << FixedList<label, 4>::Hash<>()(list1) << nl;
|
||||
<< " hash:" << FixedList<label,4>::Hash<>()(list1) << nl
|
||||
<< " hash:" << Hash<FixedList<label,4>>()(list1) << nl;
|
||||
|
||||
label a[4] = {0, 1, 2, 3};
|
||||
FixedList<label, 4> list2(a);
|
||||
|
||||
Info<< "list2:" << list2
|
||||
<< " hash:" << FixedList<label, 4>::Hash<>()(list2) << nl;
|
||||
<< " hash:" << FixedList<label,4>::Hash<>()(list2) << nl
|
||||
<< " hash:" << Hash<FixedList<label,4>>()(list2) << nl;
|
||||
|
||||
|
||||
// Using FixedList for content too
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user