Use loops for this method but do not use the keys() method. Note: You are modifying the implementation of the methods, but not their interface or contract.
/**
* Returns the value associated with the given key in this symbol table.
* Takes advantage of the fact that the keys appear in increasing order to terminate
* early when possible.
*
* @param key the key
* @return the value associated with the given key if the key is in the symbol table
* and {@code null} if the key is not in the symbol table
* @throws IllegalArgumentException if {@code key} is {@code null}
*/
public Value get(Key key) {
// TODO
// Change this code to make use of the fact the list is sorted to terminate early
// when possible.
if (key == null) throw new IllegalArgumentException("argument to get() is null");
return null;
}
Use loops for this method but do not use the keys() method. Note: You are modifying the implementation of the methods, but not their interface or contract.
Step by step
Solved in 3 steps