Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/30/17 16:41:06 (7 years ago)
Author:
pfleck
Message:

#2713 #2715 #2765
Merged to stable

  • 14435-14439,14493,14516,14519,14982,14987,14992,15042 (from #2713)
  • 14457-14458,14508,14582,14740,14984,15068,15095 (from #2715)
  • 14860-14861 (from #2765)
Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Common/3.3/Point2D.cs

    r14186 r15097  
    2626namespace HeuristicLab.Common {
    2727  [Serializable]
    28   public struct Point2D<T> where T : struct {
     28  public struct Point2D<T> where T : struct, IEquatable<T> {
    2929    public static readonly Point2D<T> Empty = new Point2D<T>();
    3030
     
    3838    }
    3939
     40    private object tag;
     41    public object Tag {
     42      get { return tag; }
     43    }
     44
    4045    [Browsable(false)]
    4146    public bool IsEmpty {
     
    4348    }
    4449
    45     public Point2D(T x, T y) {
     50    public Point2D(T x, T y, object tag = null) {
    4651      this.x = x;
    4752      this.y = y;
     53      this.tag = tag;
    4854    }
    4955
    5056    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;
    5258    }
    5359    public static bool operator !=(Point2D<T> left, Point2D<T> right) {
     
    5965        return false;
    6066      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);
    6269    }
    6370    public override int GetHashCode() {
Note: See TracChangeset for help on using the changeset viewer.