ATLAS Offline Software
Loading...
Searching...
No Matches
HashTools.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef TRIGTOOLS_TRIG_VSI_HASHTOOLS
5#define TRIGTOOLS_TRIG_VSI_HASHTOOLS
6
11#include <cstdint>
12
13namespace TrigVSI {
14
15 // The Function to make new hash from some existed hashes
16 // from: Boost.ContainerHash https://github.com/boostorg/container_hash/blob/develop/include/boost/container_hash/hash.hpp
17 inline void HashCombineImpl(size_t& h, size_t k) noexcept
18 {
19 constexpr std::uint64_t m = 0xc6a4a7935bd1e995;
20 constexpr int r = 47;
21 k *= m;
22 k ^= k >> r;
23 k *= m;
24 h ^= k;
25 h *= m;
26 // Completely arbitrary number, to prevent 0's
27 // from hashing to 0.
28 h += 0xe6546b64;
29 }
30
31 // Combines hashes to make new hash
32 template <class Type>
33 inline void HashCombine(std::size_t& h, const Type& value) noexcept
34 {
35 HashCombineImpl(h, std::hash<Type>{}(value));
36 }
37
38 // hash func for std::pair
39 template<typename T1, typename T2>
40 struct PairHash
41 {
42 size_t operator() (const std::pair<T1,T2>& p) const noexcept
43 {
44 size_t seed = 0;
45 HashCombine(seed, p.first);
46 HashCombine(seed, p.second);
47 return seed;
48 }
49 };
50
51} // end of namespace bracket TrigVSI
52
53#endif
Header file for AthHistogramAlgorithm.
int r
Definition globals.cxx:22
void HashCombineImpl(size_t &h, size_t k) noexcept
Definition HashTools.h:17
void HashCombine(std::size_t &h, const Type &value) noexcept
Definition HashTools.h:33
size_t operator()(const std::pair< T1, T2 > &p) const noexcept
Definition HashTools.h:42