Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix some long -> double faulty convertions reported by sonar
[simgrid.git] / examples / s4u / dht-kademlia / routing_table.cpp
index c94ae3c..3bd9e5e 100644 (file)
@@ -14,9 +14,9 @@ namespace kademlia {
 /** @brief Initialization of a node routing table.  */
 RoutingTable::RoutingTable(unsigned int node_id) : id_(node_id)
 {
-  buckets.reserve(IDENTIFIER_SIZE + 1);
+  buckets_.reserve(IDENTIFIER_SIZE + 1);
   for (unsigned int i = 0; i < IDENTIFIER_SIZE + 1; i++)
-    buckets.emplace_back(i);
+    buckets_.emplace_back(i);
 }
 
 void RoutingTable::print() const
@@ -24,10 +24,10 @@ void RoutingTable::print() const
   XBT_INFO("Routing table of %08x:", id_);
 
   for (unsigned int i = 0; i <= IDENTIFIER_SIZE; i++) {
-    if (not buckets[i].nodes.empty()) {
+    if (not buckets_[i].nodes_.empty()) {
       XBT_INFO("Bucket number %u: ", i);
       int j = 0;
-      for (auto value : buckets[i].nodes) {
+      for (auto value : buckets_[i].nodes_) {
         XBT_INFO("Element %d: %08x", j, value);
         j++;
       }
@@ -44,13 +44,13 @@ Bucket* RoutingTable::findBucket(unsigned int id)
   unsigned int xor_number = id_ ^ id;
   unsigned int prefix     = get_node_prefix(xor_number, IDENTIFIER_SIZE);
   xbt_assert(prefix <= IDENTIFIER_SIZE, "Tried to return a  bucket that doesn't exist.");
-  return &buckets[prefix];
+  return &buckets_[prefix];
 }
 
 /** Returns if the routing table contains the id. */
 bool RoutingTable::contains(unsigned int node_id)
 {
   const Bucket* bucket = findBucket(node_id);
-  return std::find(bucket->nodes.begin(), bucket->nodes.end(), node_id) != bucket->nodes.end();
-}
+  return std::find(bucket->nodes_.begin(), bucket->nodes_.end(), node_id) != bucket->nodes_.end();
 }
+} // namespace kademlia