|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hdfs.util.LightWeightGSet<K,E>
K
- Key type for looking up the elementsE
- Element type, which must be
(1) a subclass of K, and
(2) implementing LightWeightGSet.LinkedElement
interface.@InterfaceAudience.Private public class LightWeightGSet<K,E extends K>
A low memory footprint GSet
implementation,
which uses an array for storing the elements
and linked lists for collision resolution.
No rehash will be performed.
Therefore, the internal array will never be resized.
This class does not support null element.
This class is not thread safe.
Nested Class Summary | |
---|---|
static interface |
LightWeightGSet.LinkedElement
Elements of LightWeightGSet . |
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
LOG
|
Constructor Summary | |
---|---|
LightWeightGSet(int recommended_length)
|
Method Summary | |
---|---|
boolean |
contains(K key)
Does this set contain an element corresponding to the given key? |
E |
get(K key)
Return the stored element which is equal to the given key. |
Iterator<E> |
iterator()
|
void |
printDetails(PrintStream out)
Print detailed information of this object. |
E |
put(E element)
Add/replace an element. |
E |
remove(K key)
Remove the element corresponding to the given key. |
int |
size()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
public LightWeightGSet(int recommended_length)
recommended_length
- Recommended size of the internal array.Method Detail |
---|
public int size()
size
in interface GSet<K,E extends K>
public E get(K key)
GSet
Map.get(Object)
.
get
in interface GSet<K,E extends K>
key
- The given key.
public boolean contains(K key)
GSet
contains
in interface GSet<K,E extends K>
key
- The given key.
public E put(E element)
GSet
Map.put(Object, Object)
but is different from Set.add(Object)
which does not replace the existing element if there is any.
put
in interface GSet<K,E extends K>
element
- The element being put.
public E remove(K key)
GSet
Map.remove(Object)
.
remove
in interface GSet<K,E extends K>
key
- The key of the element being removed.
public Iterator<E> iterator()
iterator
in interface Iterable<E extends K>
public String toString()
toString
in class Object
public void printDetails(PrintStream out)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |