From 85123d65e06f07e8e82dd5464e428816541a8902 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 11 Jul 2019 10:22:32 +0200 Subject: [PATCH] Move extended hash to xbt/utility. --- include/xbt/utility.hpp | 17 +++++++++++++++++ src/mc/compare.cpp | 23 +---------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index 2a2c38260e..ea36639c67 100644 --- a/include/xbt/utility.hpp +++ b/include/xbt/utility.hpp @@ -12,6 +12,23 @@ 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 hash : public std::hash { +}; + +template class hash> { +public: + std::size_t operator()(std::pair const& x) const + { + hash h1; + hash 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 diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index 6948be571b..e2adf2dc52 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -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 hash : public std::hash { -}; - -template class hash> { -public: - std::size_t operator()(std::pairconst& x) const - { - hash h1; - hash h2; - return h1(x.first) ^ h2(x.second); - } -}; - -} - class StateComparator { public: s_xbt_mheap_t std_heap_copy; std::size_t heaplimit; std::array processStates; - std::unordered_set, hash>> compared_pointers; + std::unordered_set, simgrid::xbt::hash>> compared_pointers; void clear() { -- 2.20.1