java.lang.Iterable<T>, java.util.Collection<T>LightWeightLinkedSetpublic class LightWeightHashSet<T>
extends java.lang.Object
implements java.util.Collection<T>
| Modifier and Type | Field | Description |
|---|---|---|
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 | Description |
|---|---|
LightWeightHashSet() |
|
LightWeightHashSet(int minCapacity) |
|
LightWeightHashSet(int initCapacity,
float maxLoadFactor,
float minLoadFactor) |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
add(T element) |
Add given element to the hash table.
|
boolean |
addAll(java.util.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(java.lang.Object key) |
Check if the set contains given element
|
boolean |
containsAll(java.util.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.
|
java.util.Iterator<T> |
iterator() |
|
java.util.List<T> |
pollAll() |
Remove all elements from the set and return them.
|
java.util.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(java.io.PrintStream out) |
Print detailed information of this object.
|
boolean |
remove(java.lang.Object key) |
Remove the element corresponding to the key.
|
boolean |
removeAll(java.util.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(java.util.Collection<?> c) |
|
protected void |
shrinkIfNecessary() |
Checks if we need to shrink, and shrinks if necessary.
|
int |
size() |
Return the number of stored elements.
|
java.lang.Object[] |
toArray() |
|
<U> U[] |
toArray(U[] a) |
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprotected 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 java.util.Collection<T>public int getCapacity()
public int size()
size in interface java.util.Collection<T>protected int getIndex(int hashCode)
public boolean contains(java.lang.Object key)
contains in interface java.util.Collection<T>public T getElement(T key)
protected T getContainedElem(int index, T key, int hashCode)
public boolean addAll(java.util.Collection<? extends T> toAdd)
addAll in interface java.util.Collection<T>toAdd - - elements to add.public boolean add(T element)
add in interface java.util.Collection<T>protected boolean addElem(T element)
public boolean remove(java.lang.Object key)
remove in interface java.util.Collection<T>protected org.apache.hadoop.hdfs.util.LightWeightHashSet.LinkedElement<T> removeElem(T key)
public java.util.List<T> pollN(int n)
public java.util.List<T> pollAll()
public T[] pollToArray(T[] array)
protected void shrinkIfNecessary()
protected void expandIfNecessary()
public java.util.Iterator<T> iterator()
public java.lang.String toString()
toString in class java.lang.Objectpublic void printDetails(java.io.PrintStream out)
public void clear()
clear in interface java.util.Collection<T>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<T>public <U> U[] toArray(U[] a)
toArray in interface java.util.Collection<T>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<T>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<T>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<T>Copyright © 2008–2025 Apache Software Foundation. All rights reserved.