Hashcodes

This commit is contained in:
glax 2024-01-29 17:23:03 +01:00
parent 961dcd29d1
commit 9596811ae7
4 changed files with 23 additions and 5 deletions

View File

@ -7,7 +7,7 @@
<Authors>Glax</Authors>
<RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
</PropertyGroup>
<ItemGroup>

View File

@ -11,4 +11,9 @@ public class DurationRange : RandomIntegerRange
{
return obj is IntensityRange && base.Equals(obj);
}
public override int GetHashCode()
{
return HashCode.Combine("DR", base.GetHashCode());
}
}

View File

@ -11,4 +11,9 @@ public class IntensityRange : RandomIntegerRange
{
return obj is IntensityRange && base.Equals(obj);
}
public override int GetHashCode()
{
return HashCode.Combine("IR", base.GetHashCode());
}
}

View File

@ -2,7 +2,7 @@
public abstract class RandomIntegerRange
{
public short Min, Max;
public readonly short Min, Max;
internal RandomIntegerRange(short min, short max, short minLimit, short maxLimit)
{
if (max - min < 0)
@ -27,8 +27,16 @@ public abstract class RandomIntegerRange
public override bool Equals(object? obj)
{
return obj is RandomIntegerRange rir &&
this.Min == rir.Min &&
this.Max == rir.Max;
return obj is RandomIntegerRange rir && Equals(rir);
}
private bool Equals(RandomIntegerRange other)
{
return Min == other.Min && Max == other.Max;
}
public override int GetHashCode()
{
return HashCode.Combine(Min, Max);
}
}