Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_HashUtils.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11// *******************************************************************
12// This file contains a copy of hash support code from boost that
13// didn't make it into the stl. We only needed two lines code so
14// copied it here. Below is boost copyright.
15// *******************************************************************
16
17// Copyright 2005-2014 Daniel James.
18// Distributed under the Boost Software License, Version 1.0. (See accompanying
19// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
20
21// Based on Peter Dimov's proposal
22// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
23// issue 6.18.
24//
25// This also contains public domain code from MurmurHash. From the
26// MurmurHash header:
27
28// MurmurHash3 was written by Austin Appleby, and is placed in the public
29// domain. The author hereby disclaims copyright to this source code.
30
31// *******************************************************************
32// *******************************************************************
33
34#ifndef PANZER_HASH_UTILS_HPP
35#define PANZER_HASH_UTILS_HPP
36
37namespace panzer {
38
39 template <class T>
40 inline void hash_combine(std::size_t& seed, const T& v)
41 {
42 std::hash<T> hasher;
43 seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
44 }
45
46 struct pair_hash
47 {
48 template<typename T1, typename T2>
49 std::size_t operator()(const std::pair<T1,T2>& v) const
50 {
51 std::size_t seed = 0;
52 panzer::hash_combine(seed, v.first);
53 panzer::hash_combine(seed, v.second);
54 return seed;
55 }
56 };
57
58}
59
60namespace std
61{
62template <typename T1, typename T2>
63struct hash<std::pair<T1,T2> >
64{
65 std::size_t operator()(const std::pair<T1,T2>& v) const
66 {
67 std::size_t seed = 0;
68 panzer::hash_combine(seed, v.first);
69 panzer::hash_combine(seed, v.second);
70 return seed;
71 }
72};
73}
74
75#endif
void hash_combine(std::size_t &seed, const T &v)
std::size_t operator()(const std::pair< T1, T2 > &v) const
std::size_t operator()(const std::pair< T1, T2 > &v) const