Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: apply some sonar advices
[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::mc {
13
14 EventSet EvtSetTools::makeUnion(const EventSet& s1, const 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 (not EvtSetTools::contains(events, e))
25     events.push_back(e);
26 }
27
28 bool EvtSetTools::contains(const EventSet& events, const UnfoldingEvent* e)
29 {
30   return std::any_of(events.begin(), events.end(), [e](const UnfoldingEvent* evt) { return *evt == *e; });
31 }
32
33 } // namespace simgrid::mc