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>@Private public class LightWeightResizableGSet<K,E extends K> extends LightWeightGSet<K,E>
GSet implementation,
which uses an array for storing the elements
and linked lists for collision resolution.
If the size of elements exceeds the threshold,
the internal array will be resized to double length.
This class does not support null element.
This class is thread safe.LightWeightGSet.LinkedElement, LightWeightGSet.SetIteratorentries, hash_mask, modification, size| Constructor | Description |
|---|---|
LightWeightResizableGSet() |
|
LightWeightResizableGSet(int initCapacity) |
|
LightWeightResizableGSet(int initCapacity,
float loadFactor) |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
expandIfNecessary() |
Checks if we need to expand, and expands if necessary.
|
E |
get(K key) |
Return the stored element which is equal to the given key.
|
void |
getIterator(java.util.function.Consumer<java.util.Iterator<E>> consumer) |
|
E |
put(E element) |
Add/replace an element.
|
E |
remove(K key) |
Remove the element corresponding to the given key.
|
protected void |
resize(int cap) |
Resize the internal table to given capacity.
|
int |
size() |
actualArrayLength, clear, computeCapacity, contains, convert, getIndex, iterator, printDetails, remove, toString, valuespublic LightWeightResizableGSet(int initCapacity,
float loadFactor)
public LightWeightResizableGSet()
public LightWeightResizableGSet(int initCapacity)
public 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.public E get(K key)
GSetMap.get(Object).public E remove(K key)
GSetMap.remove(Object).public int size()
public void getIterator(java.util.function.Consumer<java.util.Iterator<E>> consumer)
protected void resize(int cap)
cap - capacity.protected void expandIfNecessary()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.