using System;
namespace LC.Google.Protobuf
{
///
/// Struct used to hold the keys for the fieldByNumber table in DescriptorPool and the keys for the
/// extensionByNumber table in ExtensionRegistry.
///
internal struct ObjectIntPair : IEquatable> where T : class
{
private readonly int number;
private readonly T obj;
internal ObjectIntPair(T obj, int number)
{
this.number = number;
this.obj = obj;
}
public bool Equals(ObjectIntPair other)
{
return obj == other.obj
&& number == other.number;
}
public override bool Equals(object obj)
{
if (obj is ObjectIntPair)
{
return Equals((ObjectIntPair)obj);
}
return false;
}
public override int GetHashCode()
{
return obj.GetHashCode() * ((1 << 16) - 1) + number;
}
}
}