package rebelsky.dict; /** * Dictionaries (aka Maps aka Tables): Collections of values indexed * by other values. * * @author Samuel A. Rebelsky * @author CSC152 2005S * @version 0 */ public class Dictionary { // +------------------+---------------------------------------- // | Design Decisions | // +------------------+ /* (1) Only one value can be associated with each index. (2) When an index has not been previously used, we find null when use use find. (3) Should indices be homogenous or heterogenous? Right now, we use "Object", so heterogenous. */ // +---------+------------------------------------------------- // | Methods | // +---------+ /** * Associate a particular value with an index. If there * was a value previously associated with the index, * forget about it. */ public void add(Object index, Object value); /** * Determine the value associated with a particular index. * If the index has never been used, return null. */ public Object find(Object index); /** * Determine the number of things in the dictionary. */ public int size(); /** * Get a list of all the indices that have been used so far. */ public Object[] getIndices() /** * Determine whether a particular index has a value. */ public boolean used(Object index); } // class Dictionary