Class BucketizedHashtable
java.lang.Object
com.sun.jdo.spi.persistence.utility.BucketizedHashtable
- All Implemented Interfaces:
Serializable,Cloneable,Map
This class implements bucketize hashtable, which subdivide the key
collection stored into several hashtables (buckets) of smaller size.
This will reduce the contention of hashtable.
- Author:
- Shing Wai Chan
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty BucketizedHashtable with the default bucket size 11, default initial capacity (11 * bucketSize) and default load factor 0.75.BucketizedHashtable(int bucketSize) Constructs a new, empty BucketizedHashtable with the specified bucket size, default initial capacity (11 * bucketSize) and default load factor 0.75.BucketizedHashtable(int bucketSize, int initialCapacity) Constructs a new, empty BucketizedHashtable with the specified bucket size, initial capacity and default load factor 0.75.BucketizedHashtable(int bucketSize, int initialCapacity, float loadFactor) Constructs a new, empty BucketizedHashtable with the specified bucket size, initial capacity and load factor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears this BucketizedHashtable so that it contains no key.clone()Creates and returns a shallow copy of this object.booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()The return set is backed by the map, so changes to the map are reflected in the set, and vice-versa.booleanCompares the specified object with this map for equality.inthashCode()booleanisEmpty()keySet()The return set is backed by the map, so changes to the map are reflected in the set, and vice-versa.Maps the specifiedkeyto the specifiedvaluein this hashtable.voidRemove the key and its corresponding value.intsize()toString()values()The return collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
BucketizedHashtable
public BucketizedHashtable(int bucketSize, int initialCapacity, float loadFactor) Constructs a new, empty BucketizedHashtable with the specified bucket size, initial capacity and load factor.- Parameters:
bucketSize- the number of buckets used for hashinginitialCapacity- the initial capacity of BucketizedHashtableloadFactor- the load factor of hashtable
-
BucketizedHashtable
public BucketizedHashtable(int bucketSize, int initialCapacity) Constructs a new, empty BucketizedHashtable with the specified bucket size, initial capacity and default load factor 0.75.- Parameters:
bucketSize- the number of buckets used for hashinginitialCapacity- the initial capacity of hashtable
-
BucketizedHashtable
public BucketizedHashtable(int bucketSize) Constructs a new, empty BucketizedHashtable with the specified bucket size, default initial capacity (11 * bucketSize) and default load factor 0.75.- Parameters:
bucketSize- the number of buckets used for hashing
-
BucketizedHashtable
public BucketizedHashtable()Constructs a new, empty BucketizedHashtable with the default bucket size 11, default initial capacity (11 * bucketSize) and default load factor 0.75.
-
-
Method Details
-
get
-
remove
Remove the key and its corresponding value. -
put
Maps the specifiedkeyto the specifiedvaluein this hashtable. Neither the key nor the value can benull. -
putAll
-
containsKey
- Specified by:
containsKeyin interfaceMap- Parameters:
key- possible key- Returns:
- true if and only if the specified object is a key in one of of the hashtables
-
containsValue
- Specified by:
containsValuein interfaceMap- Parameters:
value- possible value- Returns:
- true if and only if the specified object is a value in one of of the hashtables
-
size
public int size() -
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty() -
clear
public void clear()Clears this BucketizedHashtable so that it contains no key. -
entrySet
The return set is backed by the map, so changes to the map are reflected in the set, and vice-versa.- Specified by:
entrySetin interfaceMap- Returns:
- a set of Map.Entry when bucketSet equal 1
- Throws:
UnsupportedOperationException- when bucketSize is greater one
-
keySet
The return set is backed by the map, so changes to the map are reflected in the set, and vice-versa.- Specified by:
keySetin interfaceMap- Returns:
- a set of keys when bucketSet equal 1
- Throws:
UnsupportedOperationException- when bucketSize is greater one
-
values
The return collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.- Specified by:
valuesin interfaceMap- Returns:
- a collection of values when bucketSet equal 1
- Throws:
UnsupportedOperationException- when bucketSize is greater one
-
equals
Compares the specified object with this map for equality. -
clone
Creates and returns a shallow copy of this object. The keys and values are not cloned. -
toString
-