Class OpenAddressedHashSet<E>
- Type Parameters:
E- element type (value equality viaObject.equals(java.lang.Object)/Object.hashCode(), matching HPPC's default strategy)
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
Set over an open-addressed HPPC table with
O(1) empty clear().
Used on the epsilon-closure busy-set hot path so production code keeps the
open-addressed storage (no per-element entry objects) while every
public/protected API surface speaks only JDK collection
interfaces. Subclasses of ParserATNSimulator therefore override
ParserATNSimulator.closure(ATNConfig, ATNConfigSet, ATNConfigSet, Set, boolean, boolean, PredictionContextCache, int, boolean)
with a standard Set parameter and never depend on HPPC types.
PERF: add(E), contains(java.lang.Object), remove(java.lang.Object), clear(),
size(), and isEmpty() are thin delegates. clear() is
O(1) when the set is already empty (stock HPPC always
fills the table); only a non-empty table pays
bulk zero. The set object is allocated once per EpsilonClosure and
retained across predictions; only the underlying open-addressed table
grows.
Not part of the published API. Same-package tests exercise this type via
EpsilonClosure.retainedBusy() and direct construction.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classSnapshot iterator over elements present wheniterator()was called. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, containsAll, retainAll, spliterator, toArray
-
Field Details
-
storage
Open-addressed storage. Empty-fastclear()is implemented on this adapter (not a HPPC subclass) so stockObjectHashSetremains monomorphic and retained busy sets skip bulkArrays.fillwhen already empty.
-
-
Constructor Details
-
OpenAddressedHashSet
OpenAddressedHashSet(int expectedElements) - Parameters:
expectedElements- expected element count used as a capacity hint for the underlying open-addressed table (same contract asObjectHashSet(int))
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>
-
clear
public void clear()Clears all elements. Already-empty sets return immediately without touching HPPC's open-addressed table (stockObjectHashSet.clear()always bulk-fills).- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
toArray
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classAbstractCollection<E>
-
iterator
Iterator over a snapshot of current members.Iterator.remove()is supported by delegating toremove(Object). A snapshot avoids concurrent-modification hazards against HPPC's open-addressed table (whose native cursor iterator does not support removal).Iteration order is unspecified and may change after structural modification, matching typical hash-set contracts. Snapshot iterators do not reflect elements added after the iterator was created.
-