home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / OSpace / jgl.exe / jgl_2_0 / src / COM / objectspace / jgl / HashMultiMap.java < prev    next >
Encoding:
Java Source  |  1997-03-14  |  3.3 KB  |  115 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package COM.objectspace.jgl;
  5.  
  6. import java.util.Dictionary;
  7. import java.util.Enumeration;
  8.  
  9. /**
  10.  * A HashMultiMap is an associative container that manages a set of key/value pairs.
  11.  * A pair is stored in a hashing structure based on the hash code of its key, which
  12.  * is obtained by using the standard hashCode() function. Keys are matched using
  13.  * a BinaryPredicate which is EqualTo() by default. Duplicates keys are allowed.
  14.  * <p>
  15.  * A HashMultiMap is useful for implementing a collection of one-to-many
  16.  * mappings.
  17.  * <p>
  18.  * Insertion can invalidate iterators.
  19.  * <p>
  20.  * Removal can invalidate iterators.
  21.  * <p>
  22.  * @see COM.objectspace.jgl.HashMap
  23.  * @see COM.objectspace.jgl.examples.HashMapExamples
  24.  * @version 2.0.2
  25.  * @author ObjectSpace, Inc.
  26.  * @deprecated
  27.  * @see COM.objectspace.jgl.HashMap
  28.  */
  29.  
  30. public class HashMultiMap extends HashMap
  31.   {
  32.   /**
  33.    * Construct myself to be an empty HashMultiMap that compares key using equals().
  34.    */
  35.   public HashMultiMap()
  36.     {
  37.     super( new EqualTo(), true, DEFAULT_SIZE, DEFAULT_RATIO );
  38.     }
  39.  
  40.   /**
  41.    * Construct myself to be an empty HashMultiMap that compares keys using the specified
  42.    * binary predicate.
  43.    * @param comparator The predicate for comparing keys.
  44.    */
  45.   public HashMultiMap( BinaryPredicate comparator )
  46.     {
  47.     super( comparator, true, DEFAULT_SIZE, DEFAULT_RATIO );
  48.     }
  49.  
  50.   /**
  51.    * Construct myself to be an empty HashMultiMap that compares keys using the specified
  52.    * binary predicate. The initial buckets and load ratio must also be specified.
  53.    * @param comparator The predicate for comparing keys.
  54.    * @param capacity The initial number of hash buckets to reserve.
  55.    * @param loadRatio The maximum load ratio.
  56.    */
  57.   public HashMultiMap( BinaryPredicate comparator, int capacity, float loadRatio )
  58.     {
  59.     super( comparator, true, capacity, loadRatio );
  60.     }
  61.  
  62.   /**
  63.    * Construct myself to be a shallow copy of an existing HashMultiMap.
  64.    * @param map The HashMultiMap to copy.
  65.    */
  66.   public HashMultiMap( HashMultiMap map )
  67.     {
  68.     copy( map );
  69.     }
  70.  
  71.   /**
  72.    * Return a shallow copy of myself.
  73.    */
  74.   public synchronized Object clone()
  75.     {
  76.     return new HashMultiMap( this );
  77.     }
  78.  
  79.   /**
  80.    * Return a string that describes me.
  81.    */
  82.   public synchronized String toString()
  83.     {
  84.     return Printing.toString( this, "HashMultiMap" );
  85.     }
  86.  
  87.   /**
  88.    * Return true if I'm equal to another object.
  89.    * @param object The object to compare myself against.
  90.    */
  91.   public boolean equals( Object object )
  92.     {
  93.     return object instanceof HashMultiMap && equals( (HashMultiMap) object );
  94.     }
  95.  
  96.   /**
  97.    * Return true if I contain exactly the same key/value pairs as another HashMultiMap.
  98.    * Use equals() to compare values.
  99.    * @param map The HashMultiMap to compare myself against.
  100.    */
  101.   public synchronized boolean equals( HashMultiMap map )
  102.     {
  103.     return super.equals( map );
  104.     }
  105.  
  106.   /**
  107.    * Swap my contents with another HashMultiMap.
  108.    * @param map The HashMultiMap that I will swap my contents with.
  109.    */
  110.   public synchronized void swap( HashMultiMap map )
  111.     {
  112.     super.swap( map );
  113.     }
  114.   }
  115.