Standardizing copyright notice. Touches **ALL** sources, guys, sorry.. it's
[cvc5.git] / src / util / hash.h
1 /********************* */
2 /*! \file hash.h
3 ** \verbatim
4 ** Original author: cconway
5 ** Major contributors: mdeters
6 ** Minor contributors (to current version): taking
7 ** This file is part of the CVC4 prototype.
8 ** Copyright (c) 2009-2012 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
11 **
12 ** \brief [[ Add one-line brief description here ]]
13 **
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
16 **/
17
18 #include "cvc4_public.h"
19
20 #ifndef __CVC4__HASH_H
21 #define __CVC4__HASH_H
22
23 // in case it's not been declared as a namespace yet
24 namespace __gnu_cxx {}
25
26 #include <ext/hash_map>
27 #include <ext/hash_set>
28
29 namespace __gnu_cxx {
30
31 #ifdef CVC4_NEED_HASH_UINT64_T
32 // on some versions and architectures of GNU C++, we need a
33 // specialization of hash for 64-bit values
34 template <>
35 struct hash<uint64_t> {
36 size_t operator()(uint64_t v) const {
37 return v;
38 }
39 };/* struct hash<uint64_t> */
40 #endif /* CVC4_NEED_HASH_UINT64_T */
41
42 }/* __gnu_cxx namespace */
43
44 // hackish: treat hash stuff as if it were in std namespace
45 namespace std { using namespace __gnu_cxx; }
46
47 namespace CVC4 {
48
49 struct StringHashFunction {
50 size_t operator()(const std::string& str) const {
51 return std::hash<const char*>()(str.c_str());
52 }
53 };/* struct StringHashFunction */
54
55 template <class T, class U, class HashT = std::hash<T>, class HashU = std::hash<U> >
56 struct PairHashFunction {
57 size_t operator()(const std::pair<T, U>& pr) const {
58 return HashT()(pr.first) ^ HashU()(pr.second);
59 }
60 };/* struct PairHashFunction */
61
62 }/* CVC4 namespace */
63
64 #endif /* __CVC4__HASH_H */