/** * The hash table data. */ privatetransient Entry<K,V>[] table;
/** * The total number of entries in the hash table. */ privatetransientint count;
/** * The table is rehashed when its size exceeds this threshold. (The * value of this field is (int)(capacity * loadFactor).) * * @serial */ privateint threshold;
/** * The load factor for the hashtable. * * @serial */ privatefloat loadFactor;
/** * The number of times this Hashtable has been structurally modified * Structural modifications are those that change the number of entries in * the Hashtable or otherwise modify its internal structure (e.g., * rehash). This field is used to make iterators on Collection-views of * the Hashtable fail-fast. (See ConcurrentModificationException). */ privatetransientint modCount = 0;
/** * Constructs a new, empty hashtable with the specified initial * capacity and the specified load factor. * * @param initialCapacity the initial capacity of the hashtable. * @param loadFactor the load factor of the hashtable. * @exception IllegalArgumentException if the initial capacity is less * than zero, or if the load factor is nonpositive. */ publicHashtable(int initialCapacity, float loadFactor){ if (initialCapacity < 0) thrownew IllegalArgumentException("Illegal Capacity: "+ initialCapacity); if (loadFactor <= 0 || Float.isNaN(loadFactor)) thrownew IllegalArgumentException("Illegal Load: "+loadFactor);
/** * Constructs a new, empty hashtable with the specified initial capacity * and default load factor (0.75). * * @param initialCapacity the initial capacity of the hashtable. * @exception IllegalArgumentException if the initial capacity is less * than zero. */ publicHashtable(int initialCapacity){ this(initialCapacity, 0.75f); }
/** * Constructs a new, empty hashtable with a default initial capacity (11) * and load factor (0.75). */ publicHashtable(){ this(11, 0.75f); }
/** * Constructs a new hashtable with the same mappings as the given * Map. The hashtable is created with an initial capacity sufficient to * hold the mappings in the given Map and a default load factor (0.75). * * @param t the map whose mappings are to be placed in this map. * @throws NullPointerException if the specified map is null. * @since 1.2 */ publicHashtable(Map<? extends K, ? extends V> t){ this(Math.max(2*t.size(), 11), 0.75f); putAll(t); }