Class Array2DHashSet<T>
java.lang.Object
org.graalvm.shadowed.org.antlr.v4.runtime.misc.Array2DHashSet<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
- Direct Known Subclasses:
ATNConfigSet.AbstractConfigHashSet
Set implementation with closed hashing (open addressing).-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected T[][]protected final AbstractEqualityComparator<? super T> protected intstatic final intstatic final intprotected final intprotected final intstatic final doubleprotected intHow many elements in setprotected intwhen to expand -
Constructor Summary
ConstructorsConstructorDescriptionArray2DHashSet(AbstractEqualityComparator<? super T> comparator) Array2DHashSet(AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity) -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanbooleanaddAll(Collection<? extends T> c) protected TReturnoas an instance of the element typeT.voidclear()final booleanbooleancontainsAll(Collection<?> collection) booleancontainsFast(T obj) protected T[]createBucket(int capacity) Return an array ofTwith lengthcapacity.protected T[][]createBuckets(int capacity) Return an array ofT[]with lengthcapacity.booleanprotected voidexpand()protected final intfinal TAddoto set if not there; return existing value if already there.protected TgetOrAddImpl(T o) inthashCode()final booleanisEmpty()iterator()final booleanbooleanremoveAll(Collection<?> c) booleanremoveFast(T obj) booleanretainAll(Collection<?> c) final intsize()T[]toArray()<U> U[]toArray(U[] a) toString()Methods 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
spliterator
-
Field Details
-
INITAL_CAPACITY
public static final int INITAL_CAPACITY- See Also:
-
INITAL_BUCKET_CAPACITY
public static final int INITAL_BUCKET_CAPACITY- See Also:
-
LOAD_FACTOR
public static final double LOAD_FACTOR- See Also:
-
comparator
-
buckets
-
n
protected int nHow many elements in set -
currentPrime
protected int currentPrime -
threshold
protected int thresholdwhen to expand -
initialCapacity
protected final int initialCapacity -
initialBucketCapacity
protected final int initialBucketCapacity
-
-
Constructor Details
-
Array2DHashSet
public Array2DHashSet() -
Array2DHashSet
-
Array2DHashSet
public Array2DHashSet(AbstractEqualityComparator<? super T> comparator, int initialCapacity, int initialBucketCapacity)
-
-
Method Details
-
getOrAdd
-
getOrAddImpl
-
get
-
getBucket
-
hashCode
-
equals
-
expand
protected void expand() -
add
-
size
-
isEmpty
-
contains
-
containsFast
-
iterator
-
toArray
-
toArray
-
remove
-
removeFast
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>
-
addAll
-
retainAll
-
removeAll
-
clear
-
toString
-
toTableString
-
asElementType
Returnoas an instance of the element typeT. Ifois non-null but known to not be an instance ofT, this method returnsnull. The base implementation does not perform any type checks; override this method to provide strong type checks for thecontains(java.lang.Object)andremove(java.lang.Object)methods to ensure the arguments to theEqualityComparatorfor the set always have the expected types.- Parameters:
o- the object to try and cast to the element type of the set- Returns:
oif it could be an instance ofT, otherwisenull.
-
createBuckets
Return an array ofT[]with lengthcapacity.- Parameters:
capacity- the length of the array to return- Returns:
- the newly constructed array
-
createBucket
Return an array ofTwith lengthcapacity.- Parameters:
capacity- the length of the array to return- Returns:
- the newly constructed array
-