-/* Copyright (c) 2012-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2022. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
int Peer::nbInterestedPeers() const
{
- int nb = 0;
- for (auto const& kv : connected_peers)
- if (kv.second.interested)
- nb++;
- return nb;
+ return static_cast<int>(std::count_if(connected_peers.begin(), connected_peers.end(),
+ [](const auto& kv) { return kv.second.interested; }));
}
void Peer::leech()