Changeset 12704
- Timestamp:
- 07/10/15 11:54:54 (9 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12392
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EnumerableBoolEqualityComparer.cs
r12009 r12704 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 30 29 } 31 30 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); 43 35 } 36 return hash; 44 37 } 45 // combine in any remaining content46 if (word > 1) {47 hash ^= word;48 }49 return hash;50 38 } 51 39 }
Note: See TracChangeset
for help on using the changeset viewer.