libMesh
hashing.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_HASHING_H
19 #define LIBMESH_HASHING_H
20 
21 #include <functional>
22 
23 namespace libMesh
24 {
25 namespace boostcopy
26 {
27 
28 inline void hash_combine_impl(std::size_t & seed, std::size_t value)
29 {
30  seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2);
31 }
32 
33 template <typename T>
34 inline void hash_combine(std::size_t & seed, const T & value)
35 {
36  using std::hash;
38 }
39 
40 }
41 
42 
43 // Fix for STL laziness
44 struct hash {
45 public:
46  template <typename T1, typename T2>
47  std::size_t operator()(const std::pair<T1, T2> & x) const
48  {
49  // Hopefully argument-based lookup lets us recurse with this
50  using std::hash;
51 
52  std::size_t returnval = hash<T1>()(x.first);
53  boostcopy::hash_combine(returnval, x.second);
54 
55  return returnval;
56  }
57 };
58 
59 
60 }
61 
62 #endif // LIBMESH_HASHING_H
void hash_combine_impl(std::size_t &seed, std::size_t value)
Definition: hashing.h:28
void hash_combine(std::size_t &seed, const T &value)
Definition: hashing.h:34
The libMesh namespace provides an interface to certain functionality in the library.
std::size_t operator()(const std::pair< T1, T2 > &x) const
Definition: hashing.h:47
static const bool value
Definition: xdr_io.C:54