printBPlusTree<K> function

dynamic printBPlusTree<K>(
  1. {BPlusTree<K> bptree,
  2. String message = "NO_MESSAGE"}
)

Prints BPLus tree beautifully: DO NOT CHANGE THIS, create one for your own if needed

Implementation

printBPlusTree<K>({BPlusTree<K> bptree, String message = "NO_MESSAGE"}) {
  StringBuffer sb = StringBuffer();
  sb.write(message);
  sb.write("\n");
  var startNode = bptree.root;
  do {
    BPlusNode<K> level_seed = startNode;
    int cells = 0;
    int nodes = 0;
    do {
      sb.write("[$level_seed] ");
      cells = cells + level_seed.node.internalCellTree.size;
      nodes = nodes + 1;
      level_seed = level_seed.node?.rightSibling;
    } while (level_seed != null);
    startNode = startNode.node?.leftMostChild;
    int total = cells + nodes;
    sb.write(" <$total> \n");
  } while (startNode != null);
  sb.write("_________________________________________\n");

  print(sb.toString());
}