132
|
1 /*
|
|
2 File: HashParams.d
|
|
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.d working file
|
|
11
|
|
12 */
|
|
13
|
|
14
|
|
15 module tango.util.collection.model.HashParams;
|
|
16
|
|
17
|
|
18 /**
|
|
19 *
|
|
20 * Base interface for hash table based collections.
|
|
21 * Provides common ways of dealing with buckets and threshholds.
|
|
22 * (It would be nice to share some of the code too, but this
|
|
23 * would require multiple inheritance here.)
|
|
24 *
|
|
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 HashParams
|
|
34 {
|
|
35
|
|
36 /**
|
|
37 * The default initial number of buckets of a non-empty HT
|
|
38 **/
|
|
39
|
|
40 public static int defaultInitialBuckets = 31;
|
|
41
|
|
42 /**
|
|
43 * The default load factor for a non-empty HT. When the proportion
|
|
44 * of elements per buckets exceeds this, the table is resized.
|
|
45 **/
|
|
46
|
|
47 public static float defaultLoadFactor = 0.75f;
|
|
48
|
|
49 /**
|
|
50 * return the current number of hash table buckets
|
|
51 **/
|
|
52
|
|
53 public int buckets();
|
|
54
|
|
55 /**
|
|
56 * Set the desired number of buckets in the hash table.
|
|
57 * Any value greater than or equal to one is OK.
|
|
58 * if different than current buckets, causes a version change
|
|
59 * Throws: IllegalArgumentException if newCap less than 1
|
|
60 **/
|
|
61
|
|
62 public void buckets(int newCap);
|
|
63
|
|
64
|
|
65 /**
|
|
66 * Return the current load factor threshold
|
|
67 * The Hash table occasionally checka against the load factor
|
|
68 * resizes itself if it has gone past it.
|
|
69 **/
|
|
70
|
|
71 public float thresholdLoadFactor();
|
|
72
|
|
73 /**
|
|
74 * Set the current desired load factor. Any value greater than 0 is OK.
|
|
75 * The current load is checked against it, possibly causing resize.
|
|
76 * Throws: IllegalArgumentException if desired is 0 or less
|
|
77 **/
|
|
78
|
|
79 public void thresholdLoadFactor(float desired);
|
|
80 }
|