Skip to content

Commit 132c9bf

Browse files
waywardmonkeyszayenz
authored andcommitted
Always use unordered_map.
`ext/hash_map` has been deprecated in some compilers that supported it and `std::unordered_map` is part of C++11 and we require C++17.
1 parent c0de254 commit 132c9bf

File tree

6 files changed

+4
-83
lines changed

6 files changed

+4
-83
lines changed

CMakeLists.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,6 @@ else ()
220220
set(GECODE_USE_CLOCK 1)
221221
endif ()
222222

223-
include(CheckCXXSourceCompiles)
224-
check_cxx_source_compiles("
225-
#include <ext/hash_map>
226-
int main() {}" HAVE_EXT_HASH_MAP)
227-
if (HAVE_EXT_HASH_MAP)
228-
set(GECODE_HAS_GNU_HASH_MAP "/**/")
229-
endif ()
230-
231-
check_cxx_source_compiles("
232-
#include <unordered_map>
233-
int main() {}" HAVE_UNORDERED_MAP)
234-
if (HAVE_UNORDERED_MAP)
235-
set(GECODE_HAS_UNORDERED_MAP "/**/")
236-
endif ()
237-
238223
# Check for inline.
239224
include(CheckCSourceCompiles)
240225
check_c_source_compiles("

configure

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11769,24 +11769,6 @@ fi
1176911769
;;
1177011770
esac
1177111771

11772-
ac_fn_cxx_check_header_mongrel "$LINENO" "ext/hash_map" "ac_cv_header_ext_hash_map" "$ac_includes_default"
11773-
if test "x$ac_cv_header_ext_hash_map" = xyes; then :
11774-
11775-
$as_echo "#define GECODE_HAS_GNU_HASH_MAP /**/" >>confdefs.h
11776-
11777-
fi
11778-
11779-
11780-
11781-
ac_fn_cxx_check_header_mongrel "$LINENO" "unordered_map" "ac_cv_header_unordered_map" "$ac_includes_default"
11782-
if test "x$ac_cv_header_unordered_map" = xyes; then :
11783-
11784-
$as_echo "#define GECODE_HAS_UNORDERED_MAP /**/" >>confdefs.h
11785-
11786-
fi
11787-
11788-
11789-
1179011772

1179111773
# Check whether --enable-doc-dot was given.
1179211774
if test "${enable_doc_dot+set}" = set; then :

configure.ac

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,6 @@ microsoft)
227227
;;
228228
esac
229229

230-
dnl check whether we can use GNU hash_map
231-
AC_CHECK_HEADER([ext/hash_map],
232-
[AC_DEFINE([GECODE_HAS_GNU_HASH_MAP],[],
233-
[Whether GNU hash_map is available])])
234-
235-
dnl check whether we can use unordered_map
236-
AC_CHECK_HEADER([unordered_map],
237-
[AC_DEFINE([GECODE_HAS_UNORDERED_MAP],[],
238-
[Whether unordered_map is available])])
239-
240230
dnl find out what parts the user wants to build
241231

242232
AC_GECODE_DOC_SWITCHES

configure.ac.in

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,6 @@ microsoft)
223223
;;
224224
esac
225225

226-
dnl check whether we can use GNU hash_map
227-
AC_CHECK_HEADER([ext/hash_map],
228-
[AC_DEFINE([GECODE_HAS_GNU_HASH_MAP],[],
229-
[Whether GNU hash_map is available])])
230-
231-
dnl check whether we can use unordered_map
232-
AC_CHECK_HEADER([unordered_map],
233-
[AC_DEFINE([GECODE_HAS_UNORDERED_MAP],[],
234-
[Whether unordered_map is available])])
235-
236226
dnl find out what parts the user wants to build
237227

238228
AC_GECODE_DOC_SWITCHES

gecode/flatzinc/symboltable.hh

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,16 @@
3434
#ifndef GECODE_FLATZINC_SYMBOLTABLE_HH
3535
#define GECODE_FLATZINC_SYMBOLTABLE_HH
3636

37-
#include <vector>
38-
39-
#ifdef GECODE_HAS_UNORDERED_MAP
4037
#include <unordered_map>
41-
#elif defined(GECODE_HAS_GNU_HASH_MAP)
42-
#include <ext/hash_map>
43-
#else
44-
#include <map>
45-
#endif
38+
#include <vector>
4639

4740
namespace Gecode { namespace FlatZinc {
4841

4942
/// Symbol table mapping identifiers (strings) to values
5043
template<class Val>
5144
class SymbolTable {
5245
private:
53-
#ifdef GECODE_HAS_UNORDERED_MAP
54-
typedef std::unordered_map<std::string,Val> mymap;
55-
#elif defined(GECODE_HAS_GNU_HASH_MAP)
56-
class hashString {
57-
public:
58-
size_t operator ()(const std::string& x) const {
59-
return __gnu_cxx::hash<const char*>()(x.c_str());
60-
}
61-
};
62-
typedef __gnu_cxx::hash_map<std::string,Val,hashString> mymap;
63-
#else
64-
typedef std::map<std::string,Val> mymap;
65-
#endif
66-
mymap m;
46+
std::unordered_map<std::string,Val> m;
6747
public:
6848
/// Insert \a val with \a key
6949
bool put(const std::string& key, const Val& val);
@@ -74,7 +54,7 @@ namespace Gecode { namespace FlatZinc {
7454
template<class Val>
7555
bool
7656
SymbolTable<Val>::put(const std::string& key, const Val& val) {
77-
typename mymap::const_iterator i = m.find(key);
57+
const auto& i = m.find(key);
7858
bool fresh = (i == m.end());
7959
m[key] = val;
8060
return fresh;
@@ -83,7 +63,7 @@ namespace Gecode { namespace FlatZinc {
8363
template<class Val>
8464
bool
8565
SymbolTable<Val>::get(const std::string& key, Val& val) const {
86-
typename mymap::const_iterator i = m.find(key);
66+
const auto& i = m.find(key);
8767
if (i == m.end())
8868
return false;
8969
val = i->second;

gecode/support/config.hpp.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@
7272
/* Whether Gist is available */
7373
#undef GECODE_HAS_GIST
7474

75-
/* Whether GNU hash_map is available */
76-
#undef GECODE_HAS_GNU_HASH_MAP
77-
7875
/* Whether to build INT variables */
7976
#undef GECODE_HAS_INT_VARS
8077

@@ -90,9 +87,6 @@
9087
/* Whether to build SET variables */
9188
#undef GECODE_HAS_SET_VARS
9289

93-
/* Whether unordered_map is available */
94-
#undef GECODE_HAS_UNORDERED_MAP
95-
9690
/* Gecode version */
9791
#undef GECODE_LIBRARY_VERSION
9892

0 commit comments

Comments
 (0)