K - Key type for looking up the elementsE - Element type, which must be
(1) a subclass of K, and
(2) implementing LightWeightGSet.LinkedElement interface.java.lang.Iterable<E>, GSet<K,E>LightWeightCache, LightWeightResizableGSet@Private public class LightWeightGSet<K,E extends K> extends java.lang.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 | Description |
|---|---|---|
static interface |
LightWeightGSet.LinkedElement |
Elements of
LightWeightGSet. |
class |
LightWeightGSet.SetIterator |
| Modifier and Type | Field | Description |
|---|---|---|
protected LightWeightGSet.LinkedElement[] |
entries |
An internal array of entries, which are the rows of the hash table.
|
protected int |
hash_mask |
A mask for computing the array index from the hash value of an element.
|
protected int |
modification |
Modification version for fail-fast.
|
protected int |
size |
The size of the set (not the entry array).
|
| Modifier | Constructor | Description |
|---|---|---|
protected |
LightWeightGSet() |
|
|
LightWeightGSet(int recommended_length) |
| Modifier and Type | Method | Description |
|---|---|---|
protected static int |
actualArrayLength(int recommended) |
|
void |
clear() |
Clear the set.
|
static int |
computeCapacity(double percentage,
java.lang.String mapName) |
Let t = percentage of max memory.
|
boolean |
contains(K key) |
Does this set contain an element corresponding to the given key?
|
protected E |
convert(LightWeightGSet.LinkedElement e) |
|
E |
get(K key) |
Return the stored element which is equal to the given key.
|
protected int |
getIndex(K key) |
|
java.util.Iterator<E> |
iterator() |
|
void |
printDetails(java.io.PrintStream out) |
Print detailed information of this object.
|
E |
put(E element) |
Add/replace an element.
|
protected E |
remove(int index,
K key) |
Remove the element corresponding to the key,
given key.hashCode() == index.
|
E |
remove(K key) |
Remove the element corresponding to the given key.
|
int |
size() |
|
java.lang.String |
toString() |
|
java.util.Collection<E> |
values() |
Returns a
Collection view of the values contained in this set. |
protected LightWeightGSet.LinkedElement[] entries
protected int hash_mask
protected int size
protected int modification
ConcurrentModificationExceptionprotected LightWeightGSet()
public LightWeightGSet(int recommended_length)
recommended_length - Recommended size of the internal array.protected static int actualArrayLength(int recommended)
public int size()
protected int getIndex(K key)
protected E convert(LightWeightGSet.LinkedElement e)
public E get(K key)
GSetMap.get(Object).public boolean contains(K key)
GSetpublic E put(E element)
GSetMap.put(Object, Object)
but is different from Set.add(Object)
which does not replace the existing element if there is any.protected E remove(int index, K key)
key - key.index - index.public E remove(K key)
GSetMap.remove(Object).public java.util.Collection<E> values()
GSetCollection view of the values contained in this set.
The collection is backed by the set, so changes to the set are
reflected in the collection, and vice-versa.public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<K>public java.lang.String toString()
toString in class java.lang.Objectpublic void printDetails(java.io.PrintStream out)
out - out.public static int computeCapacity(double percentage,
java.lang.String mapName)
mapName - mapName.percentage - percentage.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.