Ejemplo n.º 1
0
  private void print(Stack<Node> stack, Node n) {
    if (n.isLeaf()) {
      assert n.value != null;
      for (Node node : stack) {
        System.out.print(node.key + "->");
      }
      System.out.print(n.value);
      System.out.println();

      return;
    }
    for (Map.Entry<Character, Node> e : n.children.entrySet()) {
      stack.push(e.getValue());
      print(stack, e.getValue());
      stack.pop();
    }
  }
Ejemplo n.º 2
0
 public void printAll() {
   Stack<Node> stack = new Stack<Node>();
   stack.push(root);
   print(stack, root);
 }