summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/WithinDeltaEqualityComparer.cs
blob: 6ab17de74ba0389ca8be57370cbfb24f4ba2ebcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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();
    }
}