Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/17 14:42:50 (7 years ago)
Author:
jkarder
Message:

#2730: improved equality comparers

  • got rid of one extra comparison
  • fixed RealVectorEqualityComparer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEqualityComparer.cs

    r15067 r15162  
    2828  public class BinaryVectorEqualityComparer : EqualityComparer<BinaryVector> {
    2929    public override bool Equals(BinaryVector x, BinaryVector y) {
    30       if (x == null && y == null) return true;
     30      if (ReferenceEquals(x, y)) return true;
    3131      if (x == null || y == null) return false;
    32       if (ReferenceEquals(x, y)) return true;
    3332      if (x.Length != y.Length) return false;
    3433      for (var i = 0; i < x.Length; i++)
     
    3635      return true;
    3736    }
     37
    3838    public override int GetHashCode(BinaryVector obj) {
    3939      if (obj == null) throw new ArgumentNullException("obj", "BinaryVectorEqualityComparer: Cannot compute hash value of null.");
    4040      unchecked {
    4141        int hash = 17;
    42         foreach (var bit in obj) {
     42        foreach (var bit in obj)
    4343          hash = hash * 29 + (bit ? 1231 : 1237);
    44         }
    4544        return hash;
    4645      }
Note: See TracChangeset for help on using the changeset viewer.