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> extends Object implements GSet<K,E>
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.Modifier and Type | Class and Description |
---|---|
static interface |
LightWeightGSet.LinkedElement
Elements of
LightWeightGSet . |
Constructor and Description |
---|
LightWeightGSet(int recommended_length) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
static int |
computeCapacity(double percentage,
String mapName)
Let t = percentage of max memory.
|
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() |
public LightWeightGSet(int recommended_length)
recommended_length
- Recommended size of the internal array.public int size()
public E get(K key)
GSet
Map.get(Object)
.public boolean contains(K key)
GSet
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.public E remove(K key)
GSet
Map.remove(Object)
.public void printDetails(PrintStream out)
public static int computeCapacity(double percentage, String mapName)
Copyright © 2013 Apache Software Foundation. All rights reserved.