/* File: MultiHashtable.java * Contains: A table associating each key with more than one value * Author: Jeff Dalton * Created: August 1998 * Updated: Sun Aug 23 23:04:22 1998 by Jeff Dalton * Copyright: (c) 1998, AIAI, University of Edinburgh */ package ix.util; import java.util.Hashtable; import java.util.Vector; /** * A MultiHashtable is (by weak analogy with "multiset") a Hashtable * that maps each key to a collection of values. For now, the collection * will always be a Vector, and there'll be no check for duplicate values. * Eventually, this should be generalized. */ public class MultiHashtable extends Hashtable { public MultiHashtable() { super(); } public synchronized Object put(Object key, Object value) { Vector already = (Vector)get(key); if (already == null) { already = new Vector(); super.put(key, already); } already.addElement(value); return already; } }