Skip to content

Commit

Permalink
Adding equality comparer
Browse files Browse the repository at this point in the history
  • Loading branch information
grofit committed Mar 11, 2020
1 parent 1559d35 commit b6c8b05
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/EcsRx/Scheduling/ElapsedTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EcsRx.Scheduling
{
public struct ElapsedTime
public struct ElapsedTime : IEquatable<ElapsedTime>
{
public TimeSpan DeltaTime;
public TimeSpan TotalTime;
Expand All @@ -12,5 +12,24 @@ public ElapsedTime(TimeSpan deltaTime, TimeSpan totalTime)
DeltaTime = deltaTime;
TotalTime = totalTime;
}

public bool Equals(ElapsedTime other)
{
return DeltaTime.Equals(other.DeltaTime) && TotalTime.Equals(other.TotalTime);
}

public override bool Equals(object obj)
{
return obj is ElapsedTime other && Equals(other);
}

public override int GetHashCode()
{
unchecked
{
return (DeltaTime.GetHashCode() * 397) ^ TotalTime.GetHashCode();
}
}

}
}

0 comments on commit b6c8b05

Please sign in to comment.