Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use boost::range algorithms
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 31 May 2016 09:29:58 +0000 (11:29 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 31 May 2016 09:29:58 +0000 (11:29 +0200)
src/mc/LivenessChecker.cpp
src/mc/VisitedState.cpp
src/mc/mc_base.cpp
src/mc/mc_dwarf.cpp
src/mc/mc_state.cpp
src/simgrid/util.hpp
src/surf/host_clm03.cpp
src/surf/network_ib.cpp
src/surf/vm_hl13.cpp

index 3853e2b..e8eba86 100644 (file)
@@ -6,10 +6,11 @@
 
 #include <cstring>
 
 
 #include <cstring>
 
-#include <algorithm>
 #include <memory>
 #include <list>
 
 #include <memory>
 #include <list>
 
+#include <boost/range/algorithm.hpp>
+
 #include <unistd.h>
 #include <sys/wait.h>
 
 #include <unistd.h>
 #include <sys/wait.h>
 
@@ -124,7 +125,7 @@ std::shared_ptr<VisitedPair> LivenessChecker::insertAcceptancePair(simgrid::mc::
     pair->num, pair->automaton_state, pair->atomic_propositions,
     pair->graph_state);
 
     pair->num, pair->automaton_state, pair->atomic_propositions,
     pair->graph_state);
 
-  auto res = std::equal_range(acceptancePairs_.begin(), acceptancePairs_.end(),
+  auto res = boost::range::equal_range(acceptancePairs,
     new_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   if (pair->search_cycle) for (auto i = res.first; i != res.second; ++i) {
     new_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   if (pair->search_cycle) for (auto i = res.first; i != res.second; ++i) {
@@ -245,7 +246,7 @@ int LivenessChecker::insertVisitedPair(std::shared_ptr<VisitedPair> visited_pair
       pair->num, pair->automaton_state, pair->atomic_propositions,
       pair->graph_state);
 
       pair->num, pair->automaton_state, pair->atomic_propositions,
       pair->graph_state);
 
-  auto range = std::equal_range(visitedPairs_.begin(), visitedPairs_.end(),
+  auto range = boost::range::equal_range(visitedPairs_,
     visited_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   for (auto i = range.first; i != range.second; ++i) {
     visited_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   for (auto i = range.first; i != range.second; ++i) {
@@ -277,8 +278,7 @@ void LivenessChecker::purgeVisitedPairs()
 {
   if (_sg_mc_visited != 0 && visitedPairs_.size() > (std::size_t) _sg_mc_visited) {
     // Remove the oldest entry with a linear search:
 {
   if (_sg_mc_visited != 0 && visitedPairs_.size() > (std::size_t) _sg_mc_visited) {
     // Remove the oldest entry with a linear search:
-    visitedPairs_.erase(std::min_element(
-      visitedPairs_.begin(), visitedPairs_.end(),
+    visitedPairs_.erase(boost::min_element(visitedPairs_,
       [](std::shared_ptr<VisitedPair> const a, std::shared_ptr<VisitedPair> const& b) {
         return a->num < b->num; } ));
   }
       [](std::shared_ptr<VisitedPair> const a, std::shared_ptr<VisitedPair> const& b) {
         return a->num < b->num; } ));
   }
index 6d0e87e..3aa0e5f 100644 (file)
@@ -8,7 +8,8 @@
 #include <sys/wait.h>
 
 #include <memory>
 #include <sys/wait.h>
 
 #include <memory>
-#include <algorithm>
+
+#include <boost/range/algorithm.hpp>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
@@ -62,7 +63,7 @@ void VisitedStates::prune()
 {
   while (states_.size() > (std::size_t) _sg_mc_visited) {
     XBT_DEBUG("Try to remove visited state (maximum number of stored states reached)");
 {
   while (states_.size() > (std::size_t) _sg_mc_visited) {
     XBT_DEBUG("Try to remove visited state (maximum number of stored states reached)");
-    auto min_element = std::min_element(states_.begin(), states_.end(),
+    auto min_element = boost::range::min_element(states_,
       [](std::unique_ptr<simgrid::mc::VisitedState>& a, std::unique_ptr<simgrid::mc::VisitedState>& b) {
         return a->num < b->num;
       });
       [](std::unique_ptr<simgrid::mc::VisitedState>& a, std::unique_ptr<simgrid::mc::VisitedState>& b) {
         return a->num < b->num;
       });
@@ -85,7 +86,7 @@ std::unique_ptr<simgrid::mc::VisitedState> VisitedStates::addVisitedState(
   XBT_DEBUG("Snapshot %p of visited state %d (exploration stack state %d)",
     new_state->system_state.get(), new_state->num, graph_state->num);
 
   XBT_DEBUG("Snapshot %p of visited state %d (exploration stack state %d)",
     new_state->system_state.get(), new_state->num, graph_state->num);
 
-  auto range = std::equal_range(states_.begin(), states_.end(),
+  auto range = boost::range::equal_range(states_,
     new_state.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   if (compare_snpashots)
     new_state.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   if (compare_snpashots)
index 708f3c5..df068fa 100644 (file)
@@ -6,8 +6,6 @@
 
 #include <cassert>
 
 
 #include <cassert>
 
-#include <algorithm>
-
 #include <simgrid_config.h>
 
 #include <xbt/log.h>
 #include <simgrid_config.h>
 
 #include <xbt/log.h>
index 30b5f38..64b71b0 100644 (file)
@@ -7,10 +7,11 @@
 #include <cinttypes>
 #include <cstdint>
 
 #include <cinttypes>
 #include <cstdint>
 
-#include <algorithm>
 #include <memory>
 #include <utility>
 
 #include <memory>
 #include <utility>
 
+#include <boost/range/algorithm.hpp>
+
 #include <fcntl.h>
 #include <cstdlib>
 #define DW_LANG_Objc DW_LANG_ObjC       /* fix spelling error in older dwarf.h */
 #include <fcntl.h>
 #include <cstdlib>
 #define DW_LANG_Objc DW_LANG_ObjC       /* fix spelling error in older dwarf.h */
@@ -934,8 +935,7 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar
 
   // We sort them in order to have an (somewhat) efficient by name
   // lookup:
 
   // We sort them in order to have an (somewhat) efficient by name
   // lookup:
-  std::sort(frame.variables.begin(), frame.variables.end(),
-    MC_compare_variable);
+  boost::range::sort(frame.variables, MC_compare_variable);
 
   // Register it:
   if (klass == simgrid::dwarf::TagClass::Subprogram)
 
   // Register it:
   if (klass == simgrid::dwarf::TagClass::Subprogram)
@@ -1252,7 +1252,7 @@ static void MC_make_functions_index(simgrid::mc::ObjectInformation* info)
   info->functions_index.shrink_to_fit();
 
   // Sort the array by low_pc:
   info->functions_index.shrink_to_fit();
 
   // Sort the array by low_pc:
-  std::sort(info->functions_index.begin(), info->functions_index.end(),
+  boost::range::sort(info->functions_index,
         [](simgrid::mc::FunctionIndexEntry const& a,
           simgrid::mc::FunctionIndexEntry const& b)
         {
         [](simgrid::mc::FunctionIndexEntry const& a,
           simgrid::mc::FunctionIndexEntry const& b)
         {
@@ -1263,8 +1263,7 @@ static void MC_make_functions_index(simgrid::mc::ObjectInformation* info)
 static void MC_post_process_variables(simgrid::mc::ObjectInformation* info)
 {
   // Someone needs this to be sorted but who?
 static void MC_post_process_variables(simgrid::mc::ObjectInformation* info)
 {
   // Someone needs this to be sorted but who?
-  std::sort(info->global_variables.begin(), info->global_variables.end(),
-    MC_compare_variable);
+  boost::range::sort(info->global_variables, MC_compare_variable);
 
   for(simgrid::mc::Variable& variable : info->global_variables)
     if (variable.type_id)
 
   for(simgrid::mc::Variable& variable : info->global_variables)
     if (variable.type_id)
index 4f467f2..8975d96 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <assert.h>
 
 
 #include <assert.h>
 
-#include <algorithm>
+#include <boost/range/algorithm.hpp>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
@@ -56,8 +56,8 @@ State::State()
 
 std::size_t State::interleaveSize() const
 {
 
 std::size_t State::interleaveSize() const
 {
-  return std::count_if(this->processStates.begin(), this->processStates.end(),
-    [](simgrid::mc::ProcessState const& state) { return state.isToInterleave(); });
+  return boost::range::count_if(this->processStates,
+    simgrid::mc::ProcessState::isToInterleave),
 }
 
 Transition State::getTransition() const
 }
 
 Transition State::getTransition() const
index 1950707..03d81b8 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef SIMGRID_UTIL_HTPP
 #define SIMGRID_UTIL_HTPP
 
 #ifndef SIMGRID_UTIL_HTPP
 #define SIMGRID_UTIL_HTPP
 
-#include <algorithm>
-
 #include <xbt/base.h>
 
 namespace simgrid {
 #include <xbt/base.h>
 
 namespace simgrid {
index 4c9c6b8..e76df1d 100644 (file)
@@ -60,7 +60,7 @@ double HostCLM03Model::next_occuring_event(double now){
       typeid(surf_network_model).name(), min_by_net,
       typeid(surf_storage_model).name(), min_by_sto);
 
       typeid(surf_network_model).name(), min_by_net,
       typeid(surf_storage_model).name(), min_by_sto);
 
-  double res = std::max(std::max(min_by_cpu, min_by_net), min_by_sto);
+  double res = std::max({min_by_cpu, min_by_net, min_by_sto});
   if (min_by_cpu >= 0.0 && min_by_cpu < res)
     res = min_by_cpu;
   if (min_by_net >= 0.0 && min_by_net < res)
   if (min_by_cpu >= 0.0 && min_by_cpu < res)
     res = min_by_cpu;
   if (min_by_net >= 0.0 && min_by_net < res)
index ff2211b..69baee9 100644 (file)
@@ -4,7 +4,6 @@
 /* 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. */
 
 /* 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. */
 
-#include <algorithm>
 #include <utility>
 
 #include "network_ib.hpp"
 #include <utility>
 
 #include "network_ib.hpp"
index 8d54b3c..e655127 100644 (file)
@@ -4,8 +4,6 @@
 /* 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. */
 
 /* 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. */
 
-#include <algorithm>
-
 #include <simgrid/host.h>
 
 #include "cpu_cas01.hpp"
 #include <simgrid/host.h>
 
 #include "cpu_cas01.hpp"