Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
EvtSetTools::makeUnion() implemented
[simgrid.git] / src / mc / udpor_global.cpp
1 /* Copyright (c) 2008-2021. 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
9 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_udpor_global, mc, "udpor_global");
10
11 namespace simgrid {
12 namespace mc {
13
14 EventSet EvtSetTools::makeUnion(EventSet s1, EventSet s2)
15 {
16   EventSet res = s1;
17   for (auto evt : s2)
18     EvtSetTools::pushBack(res, evt);
19   return res;
20 }
21
22 void EvtSetTools::pushBack(EventSet& events, UnfoldingEvent* e)
23 {
24   if (!EvtSetTools::contains(events, e))
25     events.push_back(e);
26 }
27
28 bool EvtSetTools::contains(const EventSet events, const UnfoldingEvent* e)
29 {
30   for (auto evt : events)
31     if (*evt == *e)
32       return true;
33   return false;
34 }
35
36 } // namespace mc
37 } // namespace simgrid