class TreeMap {

TreeMapNode topNode = null;

public void add(Comparable key, Object value) {

if(topNode == null)                     

topNode= new TreeMapNode(key, value);

else

topNode.add (key, value);

}

public Object get(Comparable key) {

return topNode == null ? null : topNode.find (key) ;

}

}


class TreeMapNode {

private final static int LESS = 0;

private final static int GREATER = 1;

private Comparable itsKey;

private Object itsValue;

private TreeMapNode nodes[] = new TreeMapNode[2];

public TreeMapNode (Comparable key, Object value) {

itsKey = key;

itsValue = value;

}

public Object find(Comparable key) {

if (key. compareTo(itsKey) == 0)

return itsValue;

else System.out.println(itsValue);

return findSubNodeForKey (selectSubNode (key) , key) ;

}

private int selectSubNode(Comparable key) {

return (key. compareTo(itsKey) < 0) ? LESS : GREATER;

}


private Object findSubNodeForKey(int node, Comparable key) {

return nodes[node] == null ? null : nodes[node].find (key);

}

public void add(Comparable key, Object value) {

if (key. compareTo(itsKey) == 0) 

itsValue = value;

else

addSubNode (selectSubNode (key), key, value);

}

private void addSubNode(int node, Comparable key, Object value) {

if (nodes[node] == null)

nodes[node] = new TreeMapNode(key, value) ;

else

nodes[node] .add(key, value);

}

}

public class TreeMapApp {

public static void main(String[] args) {

TreeMap names=new TreeMap();

names.add("martin","martin");

names.add("bob","bob");

names.add("robin","robin");

names.add("alan","alan");

names.add("don","don");

names.add("paul","paul");

names.add("sam","sam");

String result=(String) names.get("martin");

System.out.println(result);

}

}


여기서 노드를 다 출력하게 할려면 도대체 어떻게 해야댐?? 코린이 좀 살려줘