UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
hash_functions.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program 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 *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef HASH_FUNCTIONS_H_
21 #define HASH_FUNCTIONS_H_
22 
23 // WARNING this is not a nice fix, but has to be done because of problems with ADL lookup
24 namespace std
25 {
26 
30  template<typename T> struct hash<unordered_set<T>> {
31 
35  inline size_t operator()(const unordered_set<T> & s) const
36  {
37  std::hash<T> hasher;
38  size_t seed = 0;
39  for(typename unordered_set<T>::const_iterator it = s.cbegin(); it != s.cend(); ++it) {
40  seed ^= hasher(*it);
41  }
42  return (seed << s.size()) + (seed >> s.size());
43  }
44 
45  };
46 
47 }
48 
49 #endif /* HASH_FUNCTIONS_H_ */
size_t operator()(const unordered_set< T > &s) const
This operator serves as an implementation of its encapsulating struct.
Definition: hash_functions.h:35