it now prints the pathnode tree, from a file arg
This commit is contained in:
parent
68ade68d4e
commit
1bb7b1083b
2 changed files with 13 additions and 3 deletions
|
@ -12,6 +12,9 @@ import java.io.BufferedReader;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.redhat.trie.PathNode;
|
||||||
|
import com.redhat.trie.Util;
|
||||||
|
|
||||||
public class App {
|
public class App {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
FileInputStream fis;
|
FileInputStream fis;
|
||||||
|
@ -45,7 +48,12 @@ public class App {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(contentList.toString());
|
//System.out.println(contentList.toString());
|
||||||
|
|
||||||
|
PathNode root = new PathNode();
|
||||||
|
Util.makePathTree(contentList, root);
|
||||||
|
|
||||||
|
Util.printTree(root, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class Util {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTree(PathNode pn, int tab) {
|
public static void printTree(PathNode pn, int tab) {
|
||||||
StringBuffer nodeRep = new StringBuffer();
|
StringBuffer nodeRep = new StringBuffer();
|
||||||
for (int i = 0; i <= tab; i++) {
|
for (int i = 0; i <= tab; i++) {
|
||||||
nodeRep.append(" ");
|
nodeRep.append(" ");
|
||||||
|
@ -62,12 +62,13 @@ public class Util {
|
||||||
nodeRep.append(cp.getConnection().getId());
|
nodeRep.append(cp.getConnection().getId());
|
||||||
nodeRep.append("} ]");
|
nodeRep.append("} ]");
|
||||||
}
|
}
|
||||||
|
System.out.println(nodeRep);
|
||||||
for (NodePair cp : pn.getChildren()) {
|
for (NodePair cp : pn.getChildren()) {
|
||||||
printTree(cp.getConnection(), tab + 1);
|
printTree(cp.getConnection(), tab + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printTrie(HuffNode hn, int tab) {
|
public static void printTrie(HuffNode hn, int tab) {
|
||||||
StringBuffer nodeRep = new StringBuffer();
|
StringBuffer nodeRep = new StringBuffer();
|
||||||
for (int i = 0; i <= tab; i++) {
|
for (int i = 0; i <= tab; i++) {
|
||||||
nodeRep.append(" ");
|
nodeRep.append(" ");
|
||||||
|
@ -84,6 +85,7 @@ public class Util {
|
||||||
nodeRep.append(hn.getValue());
|
nodeRep.append(hn.getValue());
|
||||||
nodeRep.append("]");
|
nodeRep.append("]");
|
||||||
|
|
||||||
|
System.out.println(nodeRep);
|
||||||
if (hn.getLeft() != null) {
|
if (hn.getLeft() != null) {
|
||||||
printTrie(hn.getLeft(), tab + 1);
|
printTrie(hn.getLeft(), tab + 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue