|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hdfs.util.LightWeightHashSet<T>
public class LightWeightHashSet<T>
A low memory linked hash set implementation, which uses an array for storing the elements and linked lists for collision resolution. This class does not support null element. This class is not thread safe.
Field Summary | |
---|---|
protected static float |
DEFAULT_MAX_LOAD_FACTOR
|
protected static float |
DEFAUT_MIN_LOAD_FACTOR
|
protected org.apache.hadoop.hdfs.util.LightWeightHashSet.LinkedElement<T>[] |
entries
An internal array of entries, which are the rows of the hash table. |
protected static int |
MINIMUM_CAPACITY
|
protected int |
modification
Modification version for fail-fast. |
protected int |
size
The size of the set (not the entry array). |
Constructor Summary | |
---|---|
LightWeightHashSet()
|
|
LightWeightHashSet(int minCapacity)
|
|
LightWeightHashSet(int initCapacity,
float maxLoadFactor,
float minLoadFactor)
|
Method Summary | ||
---|---|---|
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()
|
|
|
toArray(U[] a)
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
protected 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 volatile int modification
ConcurrentModificationException
Constructor Detail |
---|
public 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)
Method Detail |
---|
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 Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
public String toString()
toString
in class Object
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>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |