/** * The ColorKey is both the key and the value in our enhanced * binary tree. */ class ColorKey implements SearchKey { String key; String colorValue; public ColorKey(String k, String v) { key = k; colorValue = v; } private void verifyType(SearchKey k) { if (! (k instanceof ColorKey)) throw new RuntimeException("You cannot mix keys here."); } public int compareKey(SearchKey b) { verifyType(b); return key.compareTo(((ColorKey) b).key); } public boolean equalKey(SearchKey o) { return (compareKey(o) == 0); } public String toString() { return "ColorKey:: '"+key+"' ==> '"+colorValue+"'"; } }