Package org.apache.hadoop.util
Class LightWeightResizableGSet<K,E extends K>
java.lang.Object
org.apache.hadoop.util.LightWeightGSet<K,E>
org.apache.hadoop.util.LightWeightResizableGSet<K,E>
- Type Parameters:
K- Key type for looking up the elementsE- Element type, which must be (1) a subclass of K, and (2) implementingLightWeightGSet.LinkedElementinterface.
A low memory footprint
GSet implementation,
which uses an array for storing the elements
and linked lists for collision resolution.
If the size of elements exceeds the threshold,
the internal array will be resized to double length.
This class does not support null element.
This class is thread safe.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.util.LightWeightGSet
LightWeightGSet.LinkedElement, LightWeightGSet.SetIterator -
Field Summary
Fields inherited from class org.apache.hadoop.util.LightWeightGSet
entries, hash_mask, modification, size -
Constructor Summary
ConstructorsConstructorDescriptionLightWeightResizableGSet(int initCapacity) LightWeightResizableGSet(int initCapacity, float loadFactor) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if we need to expand, and expands if necessary.Return the stored element which is equal to the given key.voidgetIterator(Consumer<Iterator<E>> consumer) Add/replace an element.Remove the element corresponding to the given key.protected voidresize(int cap) Resize the internal table to given capacity.intsize()Methods inherited from class org.apache.hadoop.util.LightWeightGSet
actualArrayLength, clear, computeCapacity, contains, convert, getIndex, iterator, printDetails, remove, toString, valuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LightWeightResizableGSet
public LightWeightResizableGSet(int initCapacity, float loadFactor) -
LightWeightResizableGSet
public LightWeightResizableGSet() -
LightWeightResizableGSet
public LightWeightResizableGSet(int initCapacity)
-
-
Method Details
-
put
Description copied from interface:GSetAdd/replace an element. If the element does not exist, add it to the set. Otherwise, replace the existing element. Note that this operation is similar toMap.put(Object, Object)but is different fromSet.add(Object)which does not replace the existing element if there is any. -
get
Description copied from interface:GSetReturn the stored element which is equal to the given key. This operation is similar toMap.get(Object). -
remove
Description copied from interface:GSetRemove the element corresponding to the given key. This operation is similar toMap.remove(Object). -
size
public int size() -
getIterator
-
resize
protected void resize(int cap) Resize the internal table to given capacity.- Parameters:
cap- capacity.
-
expandIfNecessary
protected void expandIfNecessary()Checks if we need to expand, and expands if necessary.
-