import java.util.ArrayList; /** * A map stores keys and the value that goes with each key, like a Python * dictionary. Lab 06 builds this map with a binary search tree; a later lab * builds it again with a hash table. * * Keys are never null. A value of null means "this key is not in the map", * so the map never stores a null value. */ public interface MapSet { /** * Stores value under key. If key is already in the map, its old value is * replaced. Does nothing if value is null. * * @return the old value for key, or null if key was not in the map */ public V put(K key, V value); /** * @return the value stored under key, or null if key is not in the map */ public V get(K key); /** * @return true if key is in the map */ public boolean containsKey(K key); /** * Removes key and its value from the map. * * @return the value that was stored under key, or null if key was not in the map */ public V remove(K key); /** * @return the number of keys in the map */ public int size(); /** * Removes every key from the map. */ public void clear(); /** * @return a list of all the keys in the map */ public ArrayList keySet(); /** * @return a list of all the values in the map, in the same order as keySet() */ public ArrayList values(); /** * The most entries get may have to look at to find one key. For a tree, * this is the number of levels: an empty tree has 0 and a single node has 1. * * @return the largest number of entries get examines */ public int maxDepth(); }