Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move extended hash to xbt/utility.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 11 Jul 2019 08:22:32 +0000 (10:22 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 11 Jul 2019 10:18:37 +0000 (12:18 +0200)
include/xbt/utility.hpp
src/mc/compare.cpp

index 2a2c382..ea36639 100644 (file)
 namespace simgrid {
 namespace xbt {
 
+/** @brief A hash which works with more stuff
+ *
+ *  It can hash pairs: the standard hash currently doesn't include this.
+ */
+template <class X> class hash : public std::hash<X> {
+};
+
+template <class X, class Y> class hash<std::pair<X, Y>> {
+public:
+  std::size_t operator()(std::pair<X, Y> const& x) const
+  {
+    hash<X> h1;
+    hash<X> h2;
+    return h1(x.first) ^ h2(x.second);
+  }
+};
+
 /** @brief Comparator class for using with std::priority_queue or boost::heap.
  *
  * Compare two std::pair by their first element (of type double), and return true when the first is greater than the
index 6948be5..e2adf2d 100644 (file)
@@ -75,34 +75,13 @@ public:
 static int compare_heap_area(StateComparator& state, const void* area1, const void* area2, Snapshot* snapshot1,
                              Snapshot* snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level);
 
-namespace {
-
-/** A hash which works with more stuff
- *
- *  It can hash pairs: the standard hash currently doesn't include this.
- */
-template <class X> class hash : public std::hash<X> {
-};
-
-template <class X, class Y> class hash<std::pair<X, Y>> {
-public:
-  std::size_t operator()(std::pair<X,Y>const& x) const
-  {
-    hash<X> h1;
-    hash<X> h2;
-    return h1(x.first) ^ h2(x.second);
-  }
-};
-
-}
-
 class StateComparator {
 public:
   s_xbt_mheap_t std_heap_copy;
   std::size_t heaplimit;
   std::array<ProcessComparisonState, 2> processStates;
 
-  std::unordered_set<std::pair<void*, void*>, hash<std::pair<void*, void*>>> compared_pointers;
+  std::unordered_set<std::pair<void*, void*>, simgrid::xbt::hash<std::pair<void*, void*>>> compared_pointers;
 
   void clear()
   {