Changeset 14860 for trunk/sources/HeuristicLab.Common
- Timestamp:
- 04/13/17 14:01:44 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Common/3.3/Point2D.cs
r14185 r14860 26 26 namespace HeuristicLab.Common { 27 27 [Serializable] 28 public struct Point2D<T> where T : struct {28 public struct Point2D<T> where T : struct, IEquatable<T> { 29 29 public static readonly Point2D<T> Empty = new Point2D<T>(); 30 30 … … 38 38 } 39 39 40 private object tag; 41 public object Tag { 42 get { return tag; } 43 } 44 40 45 [Browsable(false)] 41 46 public bool IsEmpty { … … 43 48 } 44 49 45 public Point2D(T x, T y ) {50 public Point2D(T x, T y, object tag = null) { 46 51 this.x = x; 47 52 this.y = y; 53 this.tag = tag; 48 54 } 49 55 50 56 public static bool operator ==(Point2D<T> left, Point2D<T> right) { 51 return left.x.Equals(right.x) && left.y.Equals(right.y) ;57 return left.x.Equals(right.x) && left.y.Equals(right.y) && left.tag == right.tag; 52 58 } 53 59 public static bool operator !=(Point2D<T> left, Point2D<T> right) { … … 59 65 return false; 60 66 Point2D<T> point = (Point2D<T>)obj; 61 return x.Equals(point.x) && y.Equals(point.y) && GetType().Equals(point.GetType()); 67 return GetType() == point.GetType() && x.Equals(point.x) && y.Equals(point.y) && 68 ((tag != null && tag.Equals(point.tag)) || tag == point.tag); 62 69 } 63 70 public override int GetHashCode() {
Note: See TracChangeset
for help on using the changeset viewer.