Merge pull request #5400 from RoosterDragon/equatable

Implemented IEquatable<T>
This commit is contained in:
Paul Chote
2014-06-09 17:32:17 +12:00
9 changed files with 50 additions and 57 deletions

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Primitives
}
}
public struct Bits<T> where T : struct
public struct Bits<T> : IEquatable<Bits<T>> where T : struct
{
public int Value;
@@ -58,6 +58,11 @@ namespace OpenRA.Primitives
return BitAllocator<T>.GetStrings(Value).JoinWith(",");
}
public static bool operator ==(Bits<T> me, Bits<T> other) { return (me.Value == other.Value); }
public static bool operator !=(Bits<T> me, Bits<T> other) { return !(me == other); }
public bool Equals(Bits<T> other) { return other == this; }
public override bool Equals(object obj) { return obj is Bits<T> && Equals((Bits<T>)obj); }
public override int GetHashCode() { return Value.GetHashCode(); }
}
}