Package org.antlr.v4.runtime.misc
Class FlexibleHashMap<K,V>
- java.lang.Object
-
- org.antlr.v4.runtime.misc.FlexibleHashMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
- Direct Known Subclasses:
PredictionMode.AltAndContextMap
public class FlexibleHashMap<K,V> extends java.lang.Object implements java.util.Map<K,V>A limited map (many unsupported operations) that lets me use varying hashCode/equals.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFlexibleHashMap.Entry<K,V>
-
Field Summary
Fields Modifier and Type Field Description protected java.util.LinkedList<FlexibleHashMap.Entry<K,V>>[]bucketsprotected AbstractEqualityComparator<? super K>comparatorprotected intcurrentPrimestatic intINITAL_BUCKET_CAPACITYstatic intINITAL_CAPACITYprotected intinitialBucketCapacityprotected intinitialCapacitystatic doubleLOAD_FACTORprotected intnHow many elements in setprotected intthresholdwhen to expand
-
Constructor Summary
Constructors Constructor Description FlexibleHashMap()FlexibleHashMap(AbstractEqualityComparator<? super K> comparator)FlexibleHashMap(AbstractEqualityComparator<? super K> comparator, int initialCapacity, int initialBucketCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)private static <K,V>
java.util.LinkedList<FlexibleHashMap.Entry<K,V>>[]createEntryListArray(int length)java.util.Set<java.util.Map.Entry<K,V>>entrySet()booleanequals(java.lang.Object o)protected voidexpand()Vget(java.lang.Object key)protected intgetBucket(K key)inthashCode()booleanisEmpty()java.util.Set<K>keySet()static voidmain(java.lang.String[] args)Vput(K key, V value)voidputAll(java.util.Map<? extends K,? extends V> m)Vremove(java.lang.Object key)intsize()java.lang.StringtoString()java.lang.StringtoTableString()java.util.Collection<V>values()
-
-
-
Field Detail
-
INITAL_CAPACITY
public static final int INITAL_CAPACITY
- See Also:
- Constant Field Values
-
INITAL_BUCKET_CAPACITY
public static final int INITAL_BUCKET_CAPACITY
- See Also:
- Constant Field Values
-
LOAD_FACTOR
public static final double LOAD_FACTOR
- See Also:
- Constant Field Values
-
comparator
protected final AbstractEqualityComparator<? super K> comparator
-
buckets
protected java.util.LinkedList<FlexibleHashMap.Entry<K,V>>[] buckets
-
n
protected int n
How many elements in set
-
currentPrime
protected int currentPrime
-
threshold
protected int threshold
when to expand
-
initialCapacity
protected final int initialCapacity
-
initialBucketCapacity
protected final int initialBucketCapacity
-
-
Constructor Detail
-
FlexibleHashMap
public FlexibleHashMap()
-
FlexibleHashMap
public FlexibleHashMap(AbstractEqualityComparator<? super K> comparator)
-
FlexibleHashMap
public FlexibleHashMap(AbstractEqualityComparator<? super K> comparator, int initialCapacity, int initialBucketCapacity)
-
-
Method Detail
-
createEntryListArray
private static <K,V> java.util.LinkedList<FlexibleHashMap.Entry<K,V>>[] createEntryListArray(int length)
-
getBucket
protected int getBucket(K key)
-
values
public java.util.Collection<V> values()
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
hashCode
public int hashCode()
-
equals
public boolean equals(java.lang.Object o)
-
expand
protected void expand()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toTableString
public java.lang.String toTableString()
-
main
public static void main(java.lang.String[] args)
-
-