From: Arnaud Giersch Date: Tue, 14 Nov 2017 12:32:09 +0000 (+0100) Subject: Move simgrid::xbt::HeapComparator in xbt/utility.hpp. X-Git-Tag: v3.18~242^2~37 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a7ece9a7073ae69a657ba432b187a69ef7db23d9 Move simgrid::xbt::HeapComparator in xbt/utility.hpp. --- diff --git a/include/xbt/algorithm.hpp b/include/xbt/algorithm.hpp index 67e4c2ec68..20e148e3c9 100644 --- a/include/xbt/algorithm.hpp +++ b/include/xbt/algorithm.hpp @@ -11,16 +11,6 @@ namespace simgrid { namespace xbt { -/** @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 - * second. Useful to have priority queues with the smallest element on top. - */ -template class HeapComparator { -public: - bool operator()(const Pair& a, const Pair& b) const { return a.first > b.first; } -}; - /** @brief Sorts the elements of the sequence [first, last) according to their color assuming elements can have only * three colors. Since there are only three colors, it is linear and much faster than a classical sort. See for * example http://en.wikipedia.org/wiki/Dutch_national_flag_problem diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index 095130f8a1..e5776312f2 100644 --- a/include/xbt/utility.hpp +++ b/include/xbt/utility.hpp @@ -1,14 +1,27 @@ -/* Copyright (c) 2016. The SimGrid Team. +/* Copyright (c) 2016-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#ifndef XBT_UTILITY_HPP +#define XBT_UTILITY_HPP + #include namespace simgrid { namespace xbt { +/** @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 + * second. Useful to have priority queues with the smallest element on top. + */ +template class HeapComparator { +public: + bool operator()(const Pair& a, const Pair& b) const { return a.first > b.first; } +}; + // integer_sequence and friends from C++14 // We need them to implement `apply` from C++17. @@ -78,3 +91,4 @@ static_assert(std::is_same< index_sequence_for, make_index_seq } } +#endif diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index c652a3903b..ad2d351fa1 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 4f5dcb8734..e63ab96480 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -6,8 +6,8 @@ #ifndef SURF_MODEL_H_ #define SURF_MODEL_H_ -#include "xbt/algorithm.hpp" #include "xbt/signal.hpp" +#include "xbt/utility.hpp" #include "src/surf/surf_private.hpp" #include "surf/surf.hpp"