Skip to content

Commit 3b334d3

Browse files
committed
feat: implement IEquatable for UVCoord
- Add IEquatable<UVCoord> implementation to UVCoord struct. - Override `Equals(object)` and add `Equals(UVCoord)` for equality checks. - Override `GetHashCode` using U and V coordinates. Signed-off-by: Illustar0 <me@illustar0.com>
1 parent fbd8884 commit 3b334d3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

components/RangeSelector/src/RangeSelector.Helpers.UVCoord.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace CommunityToolkit.WinUI.Controls;
88
/// A struct representing a coordinate in UV adjusted space.
99
/// </summary>
1010
[DebuggerDisplay("({U}u,{V}v)")]
11-
public struct UVCoord
11+
public struct UVCoord: IEquatable<UVCoord>
1212
{
1313
/// <summary>
1414
/// Initializes a new instance of the <see cref="UVCoord"/> struct.
@@ -127,4 +127,19 @@ public double V
127127
{
128128
return !(measure1 == measure2);
129129
}
130+
131+
public override bool Equals(object obj)
132+
{
133+
return obj is UVCoord other && Equals(other);
134+
}
135+
136+
public bool Equals(UVCoord other)
137+
{
138+
return this == other;
139+
}
140+
141+
public override int GetHashCode()
142+
{
143+
return HashCode.Combine(U, V);
144+
}
130145
}

0 commit comments

Comments
 (0)