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> <Authors>Glax</Authors>
<RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl> <RepositoryUrl>https://github.com/C9Glax/CShocker</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<Version>2.0.1</Version> <Version>2.0.2</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -11,4 +11,9 @@ public class DurationRange : RandomIntegerRange
{ {
return obj is IntensityRange && base.Equals(obj); 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); 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 abstract class RandomIntegerRange
{ {
public short Min, Max; public readonly short Min, Max;
internal RandomIntegerRange(short min, short max, short minLimit, short maxLimit) internal RandomIntegerRange(short min, short max, short minLimit, short maxLimit)
{ {
if (max - min < 0) if (max - min < 0)
@ -27,8 +27,16 @@ public abstract class RandomIntegerRange
public override bool Equals(object? obj) public override bool Equals(object? obj)
{ {
return obj is RandomIntegerRange rir && return obj is RandomIntegerRange rir && Equals(rir);
this.Min == rir.Min && }
this.Max == rir.Max;
private bool Equals(RandomIntegerRange other)
{
return Min == other.Min && Max == other.Max;
}
public override int GetHashCode()
{
return HashCode.Combine(Min, Max);
} }
} }