diff --git a/src/main/java/com/hashbangbash/trie/App.java b/src/main/java/com/hashbangbash/trie/App.java index 0a6df63..0990c8a 100644 --- a/src/main/java/com/hashbangbash/trie/App.java +++ b/src/main/java/com/hashbangbash/trie/App.java @@ -12,6 +12,9 @@ import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; +import com.redhat.trie.PathNode; +import com.redhat.trie.Util; + public class App { public static void main(String[] args) { FileInputStream fis; @@ -45,7 +48,12 @@ public class App { continue; } - System.out.println(contentList.toString()); + //System.out.println(contentList.toString()); + + PathNode root = new PathNode(); + Util.makePathTree(contentList, root); + + Util.printTree(root, 0); } } } diff --git a/src/main/java/com/redhat/trie/Util.java b/src/main/java/com/redhat/trie/Util.java index bff373d..f4e7cc6 100644 --- a/src/main/java/com/redhat/trie/Util.java +++ b/src/main/java/com/redhat/trie/Util.java @@ -41,7 +41,7 @@ public class Util { return parent; } - public void printTree(PathNode pn, int tab) { + public static void printTree(PathNode pn, int tab) { StringBuffer nodeRep = new StringBuffer(); for (int i = 0; i <= tab; i++) { nodeRep.append(" "); @@ -62,12 +62,13 @@ public class Util { nodeRep.append(cp.getConnection().getId()); nodeRep.append("} ]"); } + System.out.println(nodeRep); for (NodePair cp : pn.getChildren()) { printTree(cp.getConnection(), tab + 1); } } - public void printTrie(HuffNode hn, int tab) { + public static void printTrie(HuffNode hn, int tab) { StringBuffer nodeRep = new StringBuffer(); for (int i = 0; i <= tab; i++) { nodeRep.append(" "); @@ -84,6 +85,7 @@ public class Util { nodeRep.append(hn.getValue()); nodeRep.append("]"); + System.out.println(nodeRep); if (hn.getLeft() != null) { printTrie(hn.getLeft(), tab + 1); }