Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / mc / udpor_global.cpp
1 /* Copyright (c) 2008-2022. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "udpor_global.hpp"
7 #include "xbt/log.h"
8 #include <algorithm>
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_udpor_global, mc, "udpor_global");
11
12 namespace simgrid {
13 namespace mc {
14
15 EventSet EvtSetTools::makeUnion(const EventSet& s1, const EventSet& s2)
16 {
17   EventSet res = s1;
18   for (auto evt : s2)
19     EvtSetTools::pushBack(res, evt);
20   return res;
21 }
22
23 void EvtSetTools::pushBack(EventSet& events, UnfoldingEvent* e)
24 {
25   if (not EvtSetTools::contains(events, e))
26     events.push_back(e);
27 }
28
29 bool EvtSetTools::contains(const EventSet& events, const UnfoldingEvent* e)
30 {
31   return std::any_of(events.begin(), events.end(), [e](const UnfoldingEvent* evt) { return *evt == *e; });
32 }
33
34 } // namespace mc
35 } // namespace simgrid