Frobby  0.9.0
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 #ifdef __GNUC__ // Only GCC defines this macro
39 #include "hash_map/hash_map"
40 #include <string>
41 
42 template<>
43 class FrobbyHash<string> : public __gnu_cxx::hash<string> {
44 };
45 
46 template<class Key, class Value>
47 class HashMap : public __gnu_cxx::hash_map<Key, Value,
48  FrobbyHash<Key> > {
49 };
50 
51 #else
52 
53 // *********************************************************
54 #ifdef _MSC_VER // Only Microsoft C++ defines this macro
55 #include <hash_map>
56 #include <string>
57 
58 template<class Key>
59 class HashWrapper : public stdext::hash_compare<Key, ::std::less<Key> >, FrobbyHash<Key> {
60 public:
61  size_t operator()(const Key& key) const {
63  }
64 
65  bool operator()(const Key& a, const Key& b) const {
66  return stdext::hash_compare<Key, ::std::less<Key> >::operator()(a, b);
67  }
68 };
69 
70 template<>
71 class HashWrapper<string> : public stdext::hash_compare<string, ::std::less<string> > {
72 };
73 
74 template<class Key, class Value>
75 class HashMap : public stdext::hash_map<Key, Value, HashWrapper<Key> > {
76 };
77 
78 // *********************************************************
79 #else // Fall-back for unknown compilers
80 #include <map>
81 template<class Key, class Value>
82 class HashMap : public std::map<Key, Value> {
83 };
84 #endif
85 #endif
86 
87 
88 #endif
HashMap
Definition: HashMap.h:82
FrobbyHash
Definition: HashMap.h:35
__gnu_cxx::hash
Definition: hash_fun.h:71