Fix C# Pair.cs, #1634.

This commit is contained in:
Ivan Kochurkin 2017-02-22 02:47:11 +03:00
parent 96e7904167
commit 160f893922
1 changed files with 33 additions and 33 deletions

View File

@ -2,48 +2,48 @@
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
using System;
namespace Antlr4.Runtime.Misc
{
public class Pair<A, B>
{
public readonly A a;
public readonly B b;
public readonly A a;
public readonly B b;
public Pair(A a, B b)
{
this.a = a;
this.b = b;
}
public override bool Equals(Object obj)
{
if (obj == this)
public Pair(A a, B b)
{
return true;
}
else if (!(obj is Pair<A, B>)) {
return false;
this.a = a;
this.b = b;
}
Pair <A, B> other = (Pair <A, B>)obj;
return a==null ? other.a==null : a.Equals(other.b);
}
public override bool Equals(Object obj)
{
if (obj == this)
{
return true;
}
else if (!(obj is Pair<A, B>))
{
return false;
}
public override int GetHashCode()
{
int hash = MurmurHash.Initialize();
hash = MurmurHash.Update(hash, a);
hash = MurmurHash.Update(hash, b);
return MurmurHash.Finish(hash, 2);
}
Pair<A, B> other = (Pair<A, B>)obj;
return (a == null ? other.a == null : a.Equals(other.a)) &&
(b == null ? other.b == null : b.Equals(other.b));
}
public override String ToString()
{
return String.Format("(%s, %s)", a, b);
}
}
public override int GetHashCode()
{
int hash = MurmurHash.Initialize();
hash = MurmurHash.Update(hash, a);
hash = MurmurHash.Update(hash, b);
return MurmurHash.Finish(hash, 2);
}
}
public override String ToString()
{
return String.Format("({0}, {1})", a, b);
}
}
}