mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 15:09:29 +00:00
25 lines
464 B
C#
25 lines
464 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MonoGame.Extended.Tests;
|
|
|
|
public class WithinDeltaEqualityComparer : IEqualityComparer<float>
|
|
{
|
|
private readonly float _delta;
|
|
|
|
public WithinDeltaEqualityComparer(float delta)
|
|
{
|
|
_delta = delta;
|
|
}
|
|
|
|
public bool Equals(float x, float y)
|
|
{
|
|
return Math.Abs(x - y) < _delta;
|
|
}
|
|
|
|
public int GetHashCode(float obj)
|
|
{
|
|
return obj.GetHashCode();
|
|
}
|
|
}
|