Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Various sonar cleanups
[simgrid.git] / src / mc / api / ClockVector.cpp
1 /* Copyright (c) 2015-2023. 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 "src/mc/api/ClockVector.hpp"
7
8 namespace simgrid::mc {
9
10 ClockVector ClockVector::max(const ClockVector& cv1, const ClockVector& cv2)
11 {
12   auto max_vector = ClockVector();
13
14   for (const auto& [aid, value] : cv1.contents)
15     max_vector[aid] = std::max(value, cv2.get(aid).value_or(0));
16
17   for (const auto& [aid, value] : cv2.contents)
18     max_vector[aid] = std::max(value, cv1.get(aid).value_or(0));
19
20   return max_vector;
21 }
22
23 } // namespace simgrid::mc