Updated mapping for EqualityComparator and AbstractEqualityComparator

This commit is contained in:
Sam Harwell 2013-02-16 17:14:24 -06:00
parent 8ddfed3dd5
commit 87d27b7c02
5 changed files with 24 additions and 20 deletions

View File

@ -528,7 +528,7 @@ outer_break: ;
}
}
public sealed class IdentityEqualityComparator : AbstractEqualityComparator<PredictionContext
public sealed class IdentityEqualityComparator : EqualityComparer<PredictionContext
>
{
public static readonly PredictionContext.IdentityEqualityComparator Instance = new
@ -538,7 +538,7 @@ outer_break: ;
{
}
public override int HashCode(PredictionContext obj)
public override int GetHashCode(PredictionContext obj)
{
return obj.GetHashCode();
}

View File

@ -85,8 +85,8 @@ namespace Antlr4.Runtime.Atn
}
}
private sealed class AltAndContextConfigEqualityComparator : AbstractEqualityComparator
<ATNConfig>
private sealed class AltAndContextConfigEqualityComparator : EqualityComparer<ATNConfig
>
{
public static readonly PredictionMode.AltAndContextConfigEqualityComparator Instance
= new PredictionMode.AltAndContextConfigEqualityComparator();
@ -96,7 +96,7 @@ namespace Antlr4.Runtime.Atn
}
/// <summary>Code is function of (s, _, ctx, _)</summary>
public override int HashCode(ATNConfig o)
public override int GetHashCode(ATNConfig o)
{
int hashCode = 7;
hashCode = 31 * hashCode + o.GetState().stateNumber;
@ -114,7 +114,7 @@ namespace Antlr4.Runtime.Atn
{
return false;
}
if (HashCode(a) != HashCode(b))
if (GetHashCode(a) != GetHashCode(b))
{
return false;
}

View File

@ -48,7 +48,7 @@ namespace Antlr4.Runtime.Misc
public const double LoadFactor = 0.75;
[NotNull]
protected internal readonly AbstractEqualityComparator<T> comparator;
protected internal readonly EqualityComparer<T> comparator;
protected internal T[][] buckets;
@ -65,13 +65,13 @@ namespace Antlr4.Runtime.Misc
{
}
public Array2DHashSet(AbstractEqualityComparator<T> comparator) : this(comparator
, InitalCapacity, InitalBucketCapacity)
public Array2DHashSet(EqualityComparer<T> comparator) : this(comparator, InitalCapacity
, InitalBucketCapacity)
{
}
public Array2DHashSet(AbstractEqualityComparator<T> comparator, int initialCapacity
, int initialBucketCapacity)
public Array2DHashSet(EqualityComparer<T> comparator, int initialCapacity, int initialBucketCapacity
)
{
// must be power of 2
// when to expand
@ -174,7 +174,7 @@ namespace Antlr4.Runtime.Misc
protected internal int GetBucket(T o)
{
int hash = comparator.HashCode(o);
int hash = comparator.GetHashCode(o);
int b = hash & (buckets.Length - 1);
// assumes len is power of 2
return b;
@ -195,7 +195,7 @@ namespace Antlr4.Runtime.Misc
{
break;
}
h += comparator.HashCode(o);
h += comparator.GetHashCode(o);
}
}
return h;

View File

@ -71,7 +71,7 @@ namespace Antlr4.Runtime.Misc
}
[NotNull]
protected internal readonly AbstractEqualityComparator<K> comparator;
protected internal readonly EqualityComparer<K> comparator;
protected internal List<FlexibleHashMap.Entry<K, V>>[] buckets;
@ -88,13 +88,13 @@ namespace Antlr4.Runtime.Misc
{
}
public FlexibleHashMap(AbstractEqualityComparator<K> comparator) : this(comparator
, InitalCapacity, InitalBucketCapacity)
public FlexibleHashMap(EqualityComparer<K> comparator) : this(comparator, InitalCapacity
, InitalBucketCapacity)
{
}
public FlexibleHashMap(AbstractEqualityComparator<K> comparator, int initialCapacity
, int initialBucketCapacity)
public FlexibleHashMap(EqualityComparer<K> comparator, int initialCapacity, int initialBucketCapacity
)
{
// when to expand
// jump by 4 primes each expand or whatever
@ -117,7 +117,7 @@ namespace Antlr4.Runtime.Misc
protected internal virtual int GetBucket(K key)
{
int hash = comparator.HashCode(key);
int hash = comparator.GetHashCode(key);
int b = hash & (buckets.Length - 1);
// assumes len is power of 2
return b;
@ -247,7 +247,7 @@ namespace Antlr4.Runtime.Misc
{
break;
}
h += comparator.HashCode(e.key);
h += comparator.GetHashCode(e.key);
}
}
return h;

View File

@ -188,6 +188,10 @@
-typeMapping java.lang.IndexOutOfBoundsException ArgumentOutOfRangeException
-typeMapping java.util.EmptyStackException InvalidOperationException
-typeMapping org.antlr.v4.runtime.misc.EqualityComparator<> System.Collections.Generic.IEqualityComparer
-methodMapping org.antlr.v4.runtime.misc.EqualityComparator.hashCode GetHashCode
-typeMapping org.antlr.v4.runtime.misc.AbstractEqualityComparator<> System.Collections.Generic.EqualityComparer
-typeMapping org.antlr.v4.runtime.misc.Tuple System.Tuple
-typeMapping org.antlr.v4.runtime.misc.Tuple2<,> System.Tuple
-propertyMapping org.antlr.v4.runtime.misc.Tuple2.getItem1 Item1