Ignore:
Timestamp:
02/20/14 13:46:04 (7 years ago)
Author:
gkronber
Message:

#2127: removed Equals() and GetHashCode() overrides as well as related static methods.
Changed ctors of Task and Job to prevent calling virtual members.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs

    r9456 r10476  
    7373      sb.Append("Resource#" + Index + " [ ");
    7474      foreach (ScheduledTask t in Tasks) {
    75         sb.Append(t.ToString() + " ");
     75        sb.Append(t+ " ");
    7676      }
    7777      sb.Append("]");
    7878      return sb.ToString();
    7979    }
    80 
    81 
    82     public override bool Equals(object obj) {
    83       if (obj.GetType() == typeof(Resource))
    84         return AreEqual(this, obj as Resource);
    85       else
    86         return false;
    87     }
    88 
    89     public override int GetHashCode() {
    90       if (Tasks.Count == 1)
    91         return Tasks[0].GetHashCode();
    92       if (Tasks.Count == 2)
    93         return Tasks[0].GetHashCode() ^ Tasks[1].GetHashCode();
    94       return 0;
    95     }
    96 
    97     private static bool AreEqual(Resource res1, Resource res2) {
    98       if (res1.Tasks.Count != res2.Tasks.Count)
    99         return false;
    100       for (int i = 0; i < res1.Tasks.Count; i++) {
    101         if (!res1.Tasks[i].Equals(res2.Tasks[i]))
    102           return false;
    103       }
    104 
    105       return true;
    106     }
    10780  }
    10881}
Note: See TracChangeset for help on using the changeset viewer.