Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add tests for EventSet equality
[simgrid.git] / src / mc / explo / udpor / EventSet.hpp
index 8539e2460f76c15ebcbb30449116bbd4c597e9ab..b7e2ef5a0e7371150cc90d7e5a4ed88dfd1fbfaf 100644 (file)
@@ -9,6 +9,7 @@
 #include "src/mc/explo/udpor/udpor_forward.hpp"
 
 #include <cstddef>
+#include <initializer_list>
 #include <unordered_set>
 
 namespace simgrid::mc::udpor {
@@ -16,7 +17,6 @@ namespace simgrid::mc::udpor {
 class EventSet {
 private:
   std::unordered_set<UnfoldingEvent*> events_;
-  explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(raw_events) {}
 
 public:
   EventSet()                           = default;
@@ -24,28 +24,33 @@ public:
   EventSet& operator=(const EventSet&) = default;
   EventSet& operator=(EventSet&&)      = default;
   EventSet(EventSet&&)                 = default;
+  explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(raw_events) {}
+  explicit EventSet(std::initializer_list<UnfoldingEvent*> event_list) : events_(std::move(event_list)) {}
 
   inline auto begin() const { return this->events_.begin(); }
   inline auto end() const { return this->events_.end(); }
 
-  void remove(UnfoldingEvent* e);
-  void subtract(const EventSet& other);
-  void subtract(const Configuration& other);
-  EventSet subtracting(UnfoldingEvent* e) const;
-  EventSet subtracting(const EventSet& e) const;
-  EventSet subtracting(const Configuration& e) const;
+  void remove(UnfoldingEvent*);
+  void subtract(const EventSet&);
+  void subtract(const Configuration&);
+  EventSet subtracting(UnfoldingEvent*) const;
+  EventSet subtracting(const EventSet&) const;
+  EventSet subtracting(const Configuration&) const;
 
-  void insert(UnfoldingEvent* e);
+  void insert(UnfoldingEvent*);
   void form_union(const EventSet&);
   void form_union(const Configuration&);
-  EventSet make_union(UnfoldingEvent* e) const;
+  EventSet make_union(UnfoldingEvent*) const;
   EventSet make_union(const EventSet&) const;
-  EventSet make_union(const Configuration& e) const;
+  EventSet make_union(const Configuration&) const;
 
   size_t size() const;
   bool empty() const;
-  bool contains(UnfoldingEvent* e) const;
-  bool is_subset_of(const EventSet& other) const;
+  bool contains(UnfoldingEvent*) const;
+  bool is_subset_of(const EventSet&) const;
+
+  bool operator==(const EventSet& other) const { return this->events_ == other.events_; }
+  bool operator!=(const EventSet& other) const { return this->events_ != other.events_; }
 };
 
 } // namespace simgrid::mc::udpor