Frobby  0.9.5
HashMap.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2009 University of Aarhus
3  Contact Bjarke Hammersholt Roune for license information (www.broune.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see http://www.gnu.org/licenses/.
17 */
18 #ifndef HASH_MAP_GUARD
19 #define HASH_MAP_GUARD
20 
34 template<class Key>
35 class FrobbyHash {};
36 
37 // *********************************************************
38 #if defined(__GNUC__) || defined(__clang__)
39 #if 0
40 #include "hash_map/hash_map"
41 #include <string>
42 #endif
43 #include <unordered_map>
44 template<class Key, class Value>
45  class HashMap : public std::unordered_map<Key, Value, FrobbyHash<Key>> { };
46 
47 #if 0
48 template<>
49 class FrobbyHash<string> : public __gnu_cxx::hash<string> {
50 };
51 
52 template<class Key, class Value>
53 class HashMap : public __gnu_cxx::hash_map<Key, Value,
54  FrobbyHash<Key> > {
55 };
56 #endif
57 #else
58 // *********************************************************
59 #ifdef _MSC_VER // Only Microsoft C++ defines this macro
60 #include <hash_map>
61 #include <string>
62 
63 template<class Key>
64 class HashWrapper : public stdext::hash_compare<Key, ::std::less<Key> >, FrobbyHash<Key> {
65 public:
66  size_t operator()(const Key& key) const {
68  }
69 
70  bool operator()(const Key& a, const Key& b) const {
71  return stdext::hash_compare<Key, ::std::less<Key> >::operator()(a, b);
72  }
73 };
74 
75 template<>
76 class HashWrapper<string> : public stdext::hash_compare<string, ::std::less<string> > {
77 };
78 
79 template<class Key, class Value>
80 class HashMap : public stdext::hash_map<Key, Value, HashWrapper<Key> > {
81 };
82 
83 // *********************************************************
84 #else // Fall-back for unknown compilers
85 #include <map>
86 template<class Key, class Value>
87 class HashMap :
88  #if __cplusplus < 201103
89  public std::map<Key, Value>
90  #else
91  public std::unordered_map<Key, Value>
92 #endif
93 {};
94 #endif
95 #endif
96 
97 
98 #endif