1 /* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/mc/explo/udpor/EventSet.hpp"
7 #include "src/mc/explo/udpor/Configuration.hpp"
11 namespace simgrid::mc::udpor {
13 void EventSet::remove(UnfoldingEvent* e)
15 this->events_.erase(e);
18 void EventSet::subtract(const EventSet& other)
20 this->events_ = std::move(subtracting(other).events_);
23 void EventSet::subtract(const Configuration& config)
25 subtract(config.get_events());
28 EventSet EventSet::subtracting(const EventSet& other) const
30 std::unordered_set<UnfoldingEvent*> result = this->events_;
32 for (UnfoldingEvent* e : other.events_)
35 return EventSet(std::move(result));
38 EventSet EventSet::subtracting(const Configuration& config) const
40 return subtracting(config.get_events());
43 EventSet EventSet::subtracting(UnfoldingEvent* e) const
45 auto result = this->events_;
47 return EventSet(std::move(result));
50 void EventSet::insert(UnfoldingEvent* e)
52 this->events_.insert(e);
55 void EventSet::form_union(const EventSet& other)
57 this->events_ = std::move(make_union(other).events_);
60 void EventSet::form_union(const Configuration& config)
62 form_union(config.get_events());
65 EventSet EventSet::make_union(UnfoldingEvent* e) const
67 auto result = this->events_;
69 return EventSet(std::move(result));
72 EventSet EventSet::make_union(const EventSet& other) const
74 std::unordered_set<UnfoldingEvent*> result = this->events_;
76 for (UnfoldingEvent* e : other.events_)
79 return EventSet(std::move(result));
82 EventSet EventSet::make_union(const Configuration& config) const
84 return make_union(config.get_events());
87 size_t EventSet::size() const
89 return this->events_.size();
92 bool EventSet::empty() const
94 return this->events_.empty();
97 bool EventSet::contains(UnfoldingEvent* e) const
99 return this->events_.find(e) != this->events_.end();
102 bool EventSet::is_subset_of(const EventSet& other) const
104 // If there is some element not contained in `other`, then
105 // the set difference will contain that element and the
106 // result won't be empty
107 return subtracting(other).empty();
110 } // namespace simgrid::mc::udpor