qt5base-lts/tests/auto/corelib/tools/qhashfunctions
Marc Mutz 08373fb02d Add qHashRange and qHashRangeCommutative
qHashRange() takes an (input iterator) range and hashes each element, combining
the hash values using the hash combiner from Boost/N1837 with the magic number
0x9e3779b9, as described here:
http://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine

qHashRangeCommutative() does the same but with a cummutative combiner (unsigned
addition) to create hash values that are order-independent, e.g. for hashed
containers. The obvious combiner, XOR, is a bad one because it eliminates
duplicate elements. Signed addition cannot be used, since signed overflow
leads to undefined behavior.

[ChangeLog][QtCore] Added qHashRange() and qHashRangeCommutative() functions to aid
implementing qHash() overloads for custom types.

Change-Id: I3c2bbc9ce4bd0455262a70e0cf248486525e534f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-01-09 12:05:35 +01:00
..
.gitignore tst_QHash: Factor qHash()-related test cases into a separate test 2015-01-05 20:18:51 +01:00
qhashfunctions.pro tst_QHash: Factor qHash()-related test cases into a separate test 2015-01-05 20:18:51 +01:00
tst_qhashfunctions.cpp Add qHashRange and qHashRangeCommutative 2015-01-09 12:05:35 +01:00