package dict; import java.lang.*; /** * Implements a key/value pair for use by a Dictionary. */ public class DictionaryPair implements Comparable { private Comparable _key; private Object _value; /** * Initialize a key/value pair. */ public DictionaryPair(Comparable key, Object value) { _key = key; _value = value; } /** * Delegate compareTo() to the key. */ public int compareTo(Object other) { return _key.compareTo(((DictionaryPair)other)._key); } /** * Returns the key. */ public Comparable getKey() { return _key; } /** * Returns the value. */ public Object getValue() { return _value; } /** * Converts the key/value pair into a string * of the form "(key,value)". */ public String toString() { return "(" + _key + "," + _value + ")"; } }