home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / applets / collectn / hashtabl.jav < prev    next >
Encoding:
Text File  |  1995-10-14  |  2.1 KB  |  83 lines

  1. /*
  2.   File: HashTableParams.java
  3.  
  4.   Originally written by Doug Lea and released into the public domain. 
  5.   Thanks for the assistance and support of Sun Microsystems Labs, Agorics 
  6.   Inc, Loral, and everyone contributing, testing, and using this code.
  7.  
  8.   History:
  9.   Date     Who                What
  10.   24Sep95  dl@cs.oswego.edu   Create from collections.java  working file
  11.  
  12. */
  13.   
  14. package collections;
  15.  
  16. import java.util.Enumeration;
  17. import java.util.NoSuchElementException;
  18.  
  19. /**
  20.  *
  21.  * Base interface for hash table based collections.
  22.  * Provides common ways of dealing with buckets and threshholds.
  23.  * (It would be nice to share some of the code too, but this
  24.  * would require multiple inheritance here.)
  25.  * @author Doug Lea
  26.  * @version 0.93
  27.  *
  28.  * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>.
  29.  *
  30. **/
  31.  
  32.  
  33. public interface HashTableParams {
  34.  
  35. /**
  36.  * The default initial number of buckets of a non-empty HT
  37. **/
  38.  
  39.   public static final int defaultInitialBuckets = 31;
  40.  
  41. /**
  42.  * The default load factor for a non-empty HT. When the proportion
  43.  * of elements per buckets exceeds this, the table is resized.
  44. **/
  45.  
  46.   public static final float defaultLoadFactor = 0.75f;
  47.  
  48. /**
  49.  * return the current number of hash table buckets
  50. **/
  51.  
  52.   public int buckets();
  53.  
  54. /**
  55.  * Set the desired number of buckets in the hash table.
  56.  * Any value greater than or equal to one is OK.
  57.  * if different than current buckets, causes a version change
  58.  * @exception IllegalArgumentException if newCap less than 1
  59. **/
  60.  
  61.   public void buckets(int newCap) 
  62.     throws IllegalArgumentException;
  63.  
  64. /**
  65.  * Return the current load factor threshold
  66.  * The Hash table occasionally checka against the load factor
  67.  * resizes itself if it has gone past it.
  68. **/
  69.  
  70.   public float thresholdLoadFactor();
  71.  
  72. /**
  73.  * Set the current desired load factor. Any value greater than 0 is OK.
  74.  * The current load is checked against it, possibly causing resize.
  75.  * @exception IllegalArgumentException if desired is 0 or less
  76. **/
  77.  
  78.   public void thresholdLoadFactor(float desired)
  79.     throws IllegalArgumentException;
  80.  
  81. }
  82.  
  83.