public class LightWeightHashSet<T> extends Object implements Collection<T>
| Modifier and Type | Field and Description | 
|---|---|
| protected static float | DEFAULT_MAX_LOAD_FACTOR | 
| protected static float | DEFAUT_MIN_LOAD_FACTOR | 
| protected org.apache.hadoop.hdfs.util.LightWeightHashSet.LinkedElement<T>[] | entriesAn internal array of entries, which are the rows of the hash table. | 
| protected static int | MINIMUM_CAPACITY | 
| protected int | modificationModification version for fail-fast. | 
| protected int | sizeThe size of the set (not the entry array). | 
| Constructor and Description | 
|---|
| LightWeightHashSet() | 
| LightWeightHashSet(int minCapacity) | 
| LightWeightHashSet(int initCapacity,
                  float maxLoadFactor,
                  float minLoadFactor) | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | add(T element)Add given element to the hash table. | 
| boolean | addAll(Collection<? extends T> toAdd)All all elements in the collection. | 
| protected boolean | addElem(T element)Add given element to the hash table | 
| void | clear()Clear the set. | 
| boolean | contains(Object key)Check if the set contains given element | 
| boolean | containsAll(Collection<?> c) | 
| protected void | expandIfNecessary()Checks if we need to expand, and expands if necessary. | 
| int | getCapacity()Return the current capacity (for testing). | 
| protected T | getContainedElem(int index,
                T key,
                int hashCode)Check if the set contains given element at given index. | 
| T | getElement(T key)Return the element in this set which is equal to
 the given key, if such an element exists. | 
| protected int | getIndex(int hashCode)Get index in the internal table for a given hash. | 
| boolean | isEmpty()Check if the set is empty. | 
| Iterator<T> | iterator() | 
| List<T> | pollAll()Remove all elements from the set and return them. | 
| List<T> | pollN(int n)Remove and return n elements from the hashtable. | 
| T[] | pollToArray(T[] array)Get array.length elements from the set, and put them into the array. | 
| void | printDetails(PrintStream out)Print detailed information of this object. | 
| boolean | remove(Object key)Remove the element corresponding to the key. | 
| boolean | removeAll(Collection<?> c) | 
| protected org.apache.hadoop.hdfs.util.LightWeightHashSet.LinkedElement<T> | removeElem(T key)Remove the element corresponding to the key, given key.hashCode() == index. | 
| boolean | retainAll(Collection<?> c) | 
| protected void | shrinkIfNecessary()Checks if we need to shrink, and shrinks if necessary. | 
| int | size()Return the number of stored elements. | 
| Object[] | toArray() | 
| <U> U[] | toArray(U[] a) | 
| String | toString() | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCodeprotected static final float DEFAULT_MAX_LOAD_FACTOR
protected static final float DEFAUT_MIN_LOAD_FACTOR
protected static final int MINIMUM_CAPACITY
protected org.apache.hadoop.hdfs.util.LightWeightHashSet.LinkedElement<T>[] entries
protected int size
protected int modification
ConcurrentModificationExceptionpublic LightWeightHashSet(int initCapacity,
                  float maxLoadFactor,
                  float minLoadFactor)
initCapacity - Recommended size of the internal array.maxLoadFactor - used to determine when to expand the internal arrayminLoadFactor - used to determine when to shrink the internal arraypublic LightWeightHashSet()
public LightWeightHashSet(int minCapacity)
public boolean isEmpty()
isEmpty in interface Collection<T>public int getCapacity()
public int size()
size in interface Collection<T>protected int getIndex(int hashCode)
public boolean contains(Object key)
contains in interface Collection<T>public T getElement(T key)
protected T getContainedElem(int index, T key, int hashCode)
public boolean addAll(Collection<? extends T> toAdd)
addAll in interface Collection<T>toAdd - - elements to add.public boolean add(T element)
add in interface Collection<T>protected boolean addElem(T element)
public boolean remove(Object key)
remove in interface Collection<T>protected org.apache.hadoop.hdfs.util.LightWeightHashSet.LinkedElement<T> removeElem(T key)
public List<T> pollN(int n)
public List<T> pollAll()
public T[] pollToArray(T[] array)
protected void shrinkIfNecessary()
protected void expandIfNecessary()
public void printDetails(PrintStream out)
public void clear()
clear in interface Collection<T>public Object[] toArray()
toArray in interface Collection<T>public <U> U[] toArray(U[] a)
toArray in interface Collection<T>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>public boolean removeAll(Collection<?> c)
removeAll in interface Collection<T>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<T>Copyright © 2017 Apache Software Foundation. All Rights Reserved.