File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed
RhythmGameUtilities/Structs Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 1+ using System ;
12using System . Runtime . InteropServices ;
23
34namespace RhythmGameUtilities
45{
56
67 [ StructLayout ( LayoutKind . Sequential ) ]
7- public struct Note
8+ public struct Note : IEquatable < Note >
89 {
910
1011 public int Position ;
@@ -13,6 +14,28 @@ public struct Note
1314
1415 public int Length ;
1516
17+ public override int GetHashCode ( ) => ( Position , HandPosition , Length ) . GetHashCode ( ) ;
18+
19+ public bool Equals ( Note other )
20+ {
21+ return Position == other . Position && HandPosition == other . HandPosition && Length == other . Length ;
22+ }
23+
24+ public override bool Equals ( object obj )
25+ {
26+ return obj is Note other && Equals ( other ) ;
27+ }
28+
29+ public static bool operator == ( Note left , Note right )
30+ {
31+ return left . Equals ( right ) ;
32+ }
33+
34+ public static bool operator != ( Note left , Note right )
35+ {
36+ return ! ( left == right ) ;
37+ }
38+
1639 }
1740
1841}
Original file line number Diff line number Diff line change 1+ using System ;
12using System . Runtime . InteropServices ;
23
34namespace RhythmGameUtilities
45{
56
67 [ StructLayout ( LayoutKind . Sequential ) ]
7- public struct Note
8+ public struct Note : IEquatable < Note >
89 {
910
1011 public int Position ;
@@ -13,6 +14,28 @@ public struct Note
1314
1415 public int Length ;
1516
17+ public override int GetHashCode ( ) => ( Position , HandPosition , Length ) . GetHashCode ( ) ;
18+
19+ public bool Equals ( Note other )
20+ {
21+ return Position == other . Position && HandPosition == other . HandPosition && Length == other . Length ;
22+ }
23+
24+ public override bool Equals ( object obj )
25+ {
26+ return obj is Note other && Equals ( other ) ;
27+ }
28+
29+ public static bool operator == ( Note left , Note right )
30+ {
31+ return left . Equals ( right ) ;
32+ }
33+
34+ public static bool operator != ( Note left , Note right )
35+ {
36+ return ! ( left == right ) ;
37+ }
38+
1639 }
1740
1841}
You can’t perform that action at this time.
0 commit comments