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()
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != route.gw_src)
get_global_route(src, route.gw_src, links, latency);
- for (auto const& link : route.link_list)
- links.push_back(link);
+ links.insert(links.end(), begin(route.link_list), end(route.link_list));
/* If dest gateway is not our destination, we have to recursively find our way from this point */
if (route.gw_dst != dst)
* Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and save them into a vector.
* Additionally, we need to know how many ranks we have in total
*/
- for (auto const& group : dimensions)
- dimensions_.push_back(surf_parse_get_int(group));
-
+ std::transform(begin(dimensions), end(dimensions), std::back_inserter(dimensions_), surf_parse_get_int);
set_num_links_per_node(dimensions_.size());
}
}