Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::unique_ptr and remove explicit destructor.
[simgrid.git] / src / mc / udpor_global.cpp
index 9c84d6e..d099ce0 100644 (file)
@@ -5,18 +5,30 @@
 
 #include "udpor_global.hpp"
 #include "xbt/log.h"
+#include <algorithm>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_udpor_global, mc, "udpor_global");
 
 namespace simgrid {
 namespace mc {
 
-bool EvtSetTools::contains(const EventSet events, const UnfoldingEvent* e)
+EventSet EvtSetTools::makeUnion(const EventSet& s1, const EventSet& s2)
 {
-  for (auto evt : events)
-    if (*evt == *e)
-      return true;
-  return false;
+  EventSet res = s1;
+  for (auto evt : s2)
+    EvtSetTools::pushBack(res, evt);
+  return res;
+}
+
+void EvtSetTools::pushBack(EventSet& events, UnfoldingEvent* e)
+{
+  if (not EvtSetTools::contains(events, e))
+    events.push_back(e);
+}
+
+bool EvtSetTools::contains(const EventSet& events, const UnfoldingEvent* e)
+{
+  return std::any_of(events.begin(), events.end(), [e](const UnfoldingEvent* evt) { return *evt == *e; });
 }
 
 } // namespace mc