import java.util.Collection; import java.util.Map; import java.util.Set; public class TreeMap implements Map { private TreeNode root; private TreeComparator comparator; public TreeMap() { } public TreeComparator getComparator() { return comparator; } public void setComparator(TreeComparator comparator) { this.comparator = comparator; } @Override public void clear() { root = null; } @Override public boolean containsKey(Object key) { if (root == null) return false; else return root.containsKey((K)key); } @Override public boolean containsValue(Object value) { return false; } @Override public Set> entrySet() { return null; } @Override public V get(Object key) { if (root == null) return null; return root.get((K)key); } @Override public boolean isEmpty() { return root == null; } @Override public Set keySet() { return null; } @Override public V put(K key, V value) { if (root == null) { root = new TreeNode(this, key, value); return null; } return root.put(key, value); } @Override public void putAll(Map m) { } @Override public V remove(Object key) { if (root == null) return null; else if (comparator.compare(root.getKey(), (K)key) == 0) { V value = root.getValue(); root = null; return value; } else { return root.remove((K)key); } } @Override public int size() { return 0; } @Override public Collection values() { return null; } }