]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/cpp-btree: drop btree::dump() 32692/head
authorKefu Chai <kchai@redhat.com>
Fri, 17 Jan 2020 05:14:09 +0000 (13:14 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 17 Jan 2020 05:15:44 +0000 (13:15 +0800)
btree::dump() is a helper for printing out all the leaf nodes in a
btree, it's used by "operator<<()". but this operator is not used.
let's remove it.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/cpp-btree/btree.h
src/include/cpp-btree/btree_container.h

index df2415867dcec262927d92452ce2af916df5ee4c..bacb034839fc538f5a884d5a8b542fa29d99c4e3 100644 (file)
@@ -51,7 +51,6 @@
 #include <cstring>
 #include <experimental/type_traits>
 #include <functional>
-#include <iosfwd>
 #include <iterator>
 #include <limits>
 #include <new>
@@ -1145,14 +1144,6 @@ class btree {
     return compare_result_as_less_than(key_comp()(x, y));
   }
 
-  // Dump the btree to the specified ostream. Requires that operator<< is
-  // defined for Key and Value.
-  void dump(std::ostream &os) const {
-    if (root() != NULL) {
-      internal_dump(os, root(), 0);
-    }
-  }
-
   // Verifies the structure of the btree.
   void verify() const;
 
@@ -1385,9 +1376,6 @@ class btree {
   // Deletes a node and all of its children.
   void internal_clear(node_type *node);
 
-  // Dumps a node and all of its children to the specified ostream.
-  void internal_dump(std::ostream &os, const node_type *node, int level) const;
-
   // Verifies the tree structure of node.
   int internal_verify(const node_type *node,
                       const key_type *lo, const key_type *hi) const;
@@ -2526,23 +2514,6 @@ void btree<P>::internal_clear(node_type *node) {
   }
 }
 
-template <typename P>
-void btree<P>::internal_dump(
-    std::ostream &os, const node_type *node, int level) const {
-  for (int i = 0; i < node->count(); ++i) {
-    if (!node->leaf()) {
-      internal_dump(os, node->child(i), level + 1);
-    }
-    for (int j = 0; j < level; ++j) {
-      os << "  ";
-    }
-    os << node->key(i) << " [" << level << "]\n";
-  }
-  if (!node->leaf()) {
-    internal_dump(os, node->child(node->count()), level + 1);
-  }
-}
-
 template <typename P>
 int btree<P>::internal_verify(
     const node_type *node, const key_type *lo, const key_type *hi) const {
index 2cd964ce01fe5c4a49a4b594f9f8413d5ffff4d8..bcbd1ff4511da5948efecc93a994b94b32f0cc86 100644 (file)
@@ -142,7 +142,6 @@ class btree_container {
   void clear() { tree_.clear(); }
   void swap(btree_container &x) { tree_.swap(x.tree_); }
   void verify() const { tree_.verify(); }
-  void dump(std::ostream &os) const { tree_.dump(os); }
 
   // Size routines.
   size_type size() const { return tree_.size(); }
@@ -185,12 +184,6 @@ class btree_container {
   Tree tree_;
 };
 
-template <typename T>
-inline std::ostream& operator<<(std::ostream &os, const btree_container<T> &b) {
-  b.dump(os);
-  return os;
-}
-
 // A common base class for btree_set and btree_map.
 template <typename Tree>
 class btree_set_container : public btree_container<Tree> {