Class OpenAddressedHashSet<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.antlr.v4.runtime.atn.OpenAddressedHashSet<E>
Type Parameters:
E - element type (value equality via Object.equals(java.lang.Object) / Object.hashCode(), matching HPPC's default strategy)
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

final class OpenAddressedHashSet<E> extends AbstractSet<E>
Package-private JDK 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.

  • Field Details

    • storage

      private final com.carrotsearch.hppc.ObjectHashSet<E> storage
      Open-addressed storage. Empty-fast clear() is implemented on this adapter (not a HPPC subclass) so stock ObjectHashSet remains monomorphic and retained busy sets skip bulk Arrays.fill when 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 as ObjectHashSet(int))
  • Method Details