* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/mc/explo/udpor/EventSet.hpp"
+#include "src/mc/explo/udpor/Configuration.hpp"
-#include <algorithm>
#include <iterator>
-#include <set>
namespace simgrid::mc::udpor {
this->events_ = std::move(subtracting(other).events_);
}
+void EventSet::subtract(const Configuration& config)
+{
+ subtract(config.get_events());
+}
+
EventSet EventSet::subtracting(const EventSet& other) const
{
- std::set<UnfoldingEvent*> result;
- std::set_difference(this->events_.begin(), this->events_.end(), other.events_.begin(), other.events_.end(),
- std::inserter(result, result.end()));
+ std::unordered_set<UnfoldingEvent*> result = this->events_;
+
+ for (UnfoldingEvent* e : other.events_)
+ result.erase(e);
+
return EventSet(std::move(result));
}
+EventSet EventSet::subtracting(const Configuration& config) const
+{
+ return subtracting(config.get_events());
+}
+
EventSet EventSet::subtracting(UnfoldingEvent* e) const
{
auto result = this->events_;
void EventSet::insert(UnfoldingEvent* e)
{
- // TODO: Potentially react if the event is already inserted
this->events_.insert(e);
}
this->events_ = std::move(make_union(other).events_);
}
+void EventSet::form_union(const Configuration& config)
+{
+ form_union(config.get_events());
+}
+
EventSet EventSet::make_union(UnfoldingEvent* e) const
{
auto result = this->events_;
EventSet EventSet::make_union(const EventSet& other) const
{
- std::set<UnfoldingEvent*> result;
- std::set_union(this->events_.begin(), this->events_.end(), other.events_.begin(), other.events_.end(),
- std::inserter(result, result.end()));
+ std::unordered_set<UnfoldingEvent*> result = this->events_;
+
+ for (UnfoldingEvent* e : other.events_)
+ result.insert(e);
+
return EventSet(std::move(result));
}
+EventSet EventSet::make_union(const Configuration& config) const
+{
+ return make_union(config.get_events());
+}
+
size_t EventSet::size() const
{
return this->events_.size();