Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add get_name for batteries. update dag_from_json to support wfformat 1.4
[simgrid.git] / src / mc / explo / udpor / History.cpp
index bb24494273466a7f23b4f37d5b94df7a6f76214a..d9d43d313304caa3907a37cddfc06ffaac35be50 100644 (file)
@@ -20,11 +20,11 @@ History::Iterator::Iterator(const EventSet& initial_events, optional_configurati
   // and all subsequent events that are added by the iterator
 }
 
-History::Iterator& History::Iterator::operator++()
+void History::Iterator::increment()
 {
   if (not frontier.empty()) {
     // "Pop" the event at the "front"
-    UnfoldingEvent* e = *frontier.begin();
+    const UnfoldingEvent* e = *frontier.begin();
     frontier.remove(e);
 
     // If there is a configuration and if the
@@ -33,7 +33,7 @@ History::Iterator& History::Iterator::operator++()
     // be searched since the configuration contains
     // them (configuration invariant)
     if (configuration.has_value() && configuration->get().contains(e)) {
-      return *this;
+      return;
     }
 
     // Mark this event as seen
@@ -47,7 +47,19 @@ History::Iterator& History::Iterator::operator++()
     candidates.subtract(current_history);
     frontier.form_union(candidates);
   }
-  return *this;
+}
+
+const UnfoldingEvent* const& History::Iterator::dereference() const
+{
+  return *frontier.begin();
+}
+
+bool History::Iterator::equal(const Iterator& other) const
+{
+  // If what the iterator sees next is the same, we consider them
+  // to be the same iterator. This way, once the iterator has completed
+  // its search, it will be "equal" to an iterator searching nothing
+  return this->frontier == other.frontier;
 }
 
 EventSet History::get_all_events() const
@@ -80,7 +92,7 @@ bool History::contains(const UnfoldingEvent* e) const
 EventSet History::get_event_diff_with(const Configuration& config) const
 {
   auto wrapped_config = std::optional<std::reference_wrapper<const Configuration>>{config};
-  auto first          = Iterator(events_, std::move(wrapped_config));
+  auto first          = Iterator(events_, wrapped_config);
   const auto last     = this->end();
 
   for (; first != last; ++first)