MCPcopy Create free account
hub / github.com/KDE/kdevelop / KDevHash

Class KDevHash

kdevplatform/language/util/kdevhash.h:26–60  ·  view source on GitHub ↗

* A helper class to implement hashing for aggregate types. * * @code * class MyType { * ... * uint hash() const * { * KDevHash hash; * return hash << m_1 << m_2 << ...; * } * }; * @endcode */

Source from the content-addressed store, hash-verified

24 * @endcode
25 */
26class KDevHash
27{
28public:
29 enum {
30 DEFAULT_SEED = 2166136261u
31 };
32
33 explicit KDevHash(uint hash = DEFAULT_SEED)
34 : m_hash(hash)
35 {}
36
37 KDevHash(const KDevHash&) = delete;
38 KDevHash& operator=(const KDevHash&) = delete;
39
40 inline operator uint() const
41 {
42 return m_hash;
43 }
44
45 template <typename T>
46 inline KDevHash& operator<<(T value)
47 {
48 m_hash = hash_combine(m_hash, qHash(value));
49 return *this;
50 }
51
52 static inline uint hash_combine(uint seed, uint hash)
53 {
54 // this is copied from boost::hash_combine
55 return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2));
56 }
57
58private:
59 uint m_hash;
60};
61
62#endif //KDEVPLATFORM_KDEVHASH_H

Callers 15

hashMethod · 0.85
bench_kdevhashMethod · 0.85
hashFunction · 0.85
hashFunction · 0.85
hashFunction · 0.85
hashMethod · 0.85
hashMethod · 0.85
hashMethod · 0.85
hashMethod · 0.85
hashMethod · 0.85
hashMethod · 0.85
hashMethod · 0.85

Calls 1

qHashFunction · 0.70

Tested by 1

bench_kdevhashMethod · 0.68