X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b5a4a95b58b13589c25e3cee3b725694437df8a7..5f4fec5323389b31285cd4e19a6abda90e63a555:/src/mc/explo/udpor/Configuration.cpp diff --git a/src/mc/explo/udpor/Configuration.cpp b/src/mc/explo/udpor/Configuration.cpp index 8fa1dd6285..70f4659f0b 100644 --- a/src/mc/explo/udpor/Configuration.cpp +++ b/src/mc/explo/udpor/Configuration.cpp @@ -6,6 +6,7 @@ #include "src/mc/explo/udpor/Configuration.hpp" #include "src/mc/explo/udpor/History.hpp" #include "src/mc/explo/udpor/UnfoldingEvent.hpp" +#include "xbt/asserts.h" #include #include @@ -13,18 +14,19 @@ namespace simgrid::mc::udpor { -Configuration::Configuration(std::initializer_list events) : Configuration(EventSet(std::move(events))) +Configuration::Configuration(std::initializer_list events) + : Configuration(EventSet(std::move(events))) { } -Configuration::Configuration(EventSet events) : events_(events) +Configuration::Configuration(const EventSet& events) : events_(events) { if (!events_.is_valid_configuration()) { throw std::invalid_argument("The events do not form a valid configuration"); } } -void Configuration::add_event(UnfoldingEvent* e) +void Configuration::add_event(const UnfoldingEvent* e) { if (e == nullptr) { throw std::invalid_argument("Expected a nonnull `UnfoldingEvent*` but received NULL instead"); @@ -45,22 +47,24 @@ void Configuration::add_event(UnfoldingEvent* e) } } -std::vector Configuration::get_topologically_sorted_events() const +std::vector Configuration::get_topologically_sorted_events() const { if (events_.empty()) { - return std::vector(); + return std::vector(); } - std::stack event_stack; - std::vector topological_ordering; - EventSet unknown_events = events_, temporarily_marked_events, permanently_marked_events; + std::stack event_stack; + std::vector topological_ordering; + EventSet unknown_events = events_; + EventSet temporarily_marked_events; + EventSet permanently_marked_events; while (not unknown_events.empty()) { EventSet discovered_events; event_stack.push(*unknown_events.begin()); while (not event_stack.empty()) { - UnfoldingEvent* evt = event_stack.top(); + const UnfoldingEvent* evt = event_stack.top(); discovered_events.insert(evt); if (not temporarily_marked_events.contains(evt)) { @@ -106,7 +110,7 @@ std::vector Configuration::get_topologically_sorted_events() co return topological_ordering; } -std::vector Configuration::get_topologically_sorted_events_of_reverse_graph() const +std::vector Configuration::get_topologically_sorted_events_of_reverse_graph() const { // The method exploits the property that // a topological sorting S^R of the reverse graph G^R