Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12704 for stable


Ignore:
Timestamp:
07/10/15 11:54:54 (9 years ago)
Author:
mkommend
Message:

#2386: Merged r12392 into stable.

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EnumerableBoolEqualityComparer.cs

    r12009 r12704  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
     
    3029    }
    3130    public int GetHashCode(IEnumerable<bool> obj) {
    32       int hash = 0;
    33       int word = 1;
    34       foreach (bool bit in obj) {
    35         // load bits into an integer
    36         word <<= 1;
    37         word |= Convert.ToInt32(bit);
    38         // only happens when the leading 1 reaches the sign bit
    39         if (word < 0) {
    40           // combine word into the hash
    41           hash ^= word;
    42           word = 1;
     31      unchecked {
     32        int hash = 17;
     33        foreach (var bit in obj) {
     34          hash = hash * 29 + (bit ? 1231 : 1237);
    4335        }
     36        return hash;
    4437      }
    45       // combine in any remaining content
    46       if (word > 1) {
    47         hash ^= word;
    48       }
    49       return hash;
    5038    }
    5139  }
Note: See TracChangeset for help on using the changeset viewer.