* Models' SubstitutionMaps are now attached to the user context
[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, 2010, 2011 The Analysis of Computer Systems Group (ACSys)
9 ** Courant Institute of Mathematical Sciences
10 ** New York University
11 ** See the file COPYING in the top-level source directory for licensing
12 ** information.\endverbatim
13 **
14 ** \brief [[ Add one-line brief description here ]]
15 **
16 ** [[ Add lengthier description here ]]
17 ** \todo document this file
18 **/
19
20 #include "cvc4_public.h"
21
22 #ifndef __CVC4__HASH_H
23 #define __CVC4__HASH_H
24
25 // in case it's not been declared as a namespace yet
26 namespace __gnu_cxx {}
27
28 #include <ext/hash_map>
29 #include <ext/hash_set>
30
31 namespace __gnu_cxx {
32
33 #ifdef CVC4_NEED_HASH_UINT64_T
34 // on some versions and architectures of GNU C++, we need a
35 // specialization of hash for 64-bit values
36 template <>
37 struct hash<uint64_t> {
38 size_t operator()(uint64_t v) const {
39 return v;
40 }
41 };/* struct hash<uint64_t> */
42 #endif /* CVC4_NEED_HASH_UINT64_T */
43
44 }/* __gnu_cxx namespace */
45
46 // hackish: treat hash stuff as if it were in std namespace
47 namespace std { using namespace __gnu_cxx; }
48
49 namespace CVC4 {
50
51 struct StringHashFunction {
52 size_t operator()(const std::string& str) const {
53 return std::hash<const char*>()(str.c_str());
54 }
55 };/* struct StringHashFunction */
56
57 template <class T, class U, class HashT = std::hash<T>, class HashU = std::hash<U> >
58 struct PairHashFunction {
59 size_t operator()(const std::pair<T, U>& pr) const {
60 return HashT()(pr.first) ^ HashU()(pr.second);
61 }
62 };/* struct PairHashFunction */
63
64 }/* CVC4 namespace */
65
66 #endif /* __CVC4__HASH_H */