Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move simgrid::xbt::HeapComparator in xbt/utility.hpp.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 14 Nov 2017 12:32:09 +0000 (13:32 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 14 Nov 2017 12:32:50 +0000 (13:32 +0100)
include/xbt/algorithm.hpp
include/xbt/utility.hpp
src/simix/smx_global.cpp
src/surf/surf_interface.hpp

index 67e4c2e..20e148e 100644 (file)
 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 Pair> 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
index 095130f..e577631 100644 (file)
@@ -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 <tuple>
 
 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 Pair> 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<int,double,float>, make_index_seq
 
 }
 }
+#endif
index c652a39..ad2d351 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <xbt/algorithm.hpp>
 #include <xbt/functional.hpp>
+#include <xbt/utility.hpp>
 
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
index 4f5dcb8..e63ab96 100644 (file)
@@ -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"