Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make destructors useless.
[simgrid.git] / examples / s4u / dht-kademlia / routing_table.hpp
index 08656fd..4d8258a 100644 (file)
@@ -8,6 +8,7 @@
 #define _KADEMLIA_ROUTING_TABLE_HPP
 #include "s4u-dht-kademlia.hpp"
 #include <deque>
+#include <vector>
 
 namespace kademlia {
 
@@ -16,21 +17,19 @@ class Bucket {
   unsigned int id_; // bucket id
 public:
   std::deque<unsigned int> nodes; // Nodes in the bucket.
-  unsigned int getId() { return id_; }
+  unsigned int getId() const { return id_; }
   explicit Bucket(unsigned int id) : id_(id) {}
-  ~Bucket() = default;
 };
 
 /* Node routing table */
 class RoutingTable {
   unsigned int id_; // node id of the client's routing table
 public:
-  Bucket** buckets; // Node bucket list - 160 sized.
+  std::vector<Bucket> buckets; // Node bucket list - 160 sized.
   explicit RoutingTable(unsigned int node_id);
   RoutingTable(const RoutingTable&) = delete;
   RoutingTable& operator=(const RoutingTable&) = delete;
-  ~RoutingTable();
-  void print();
+  void print() const;
   Bucket* findBucket(unsigned int id);
   bool contains(unsigned int node_id);
 };