Changeset 12438 for branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EnumerableBoolEqualityComparer.cs
- Timestamp:
- 06/12/15 15:35:16 (9 years ago)
- Location:
- branches/HeuristicLab.DatasetRefactor/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatasetRefactor/sources
- Property svn:mergeinfo changed
/trunk/sources merged: 12262,12264,12273,12292-12293,12305,12315,12333,12358-12361,12365,12392-12393,12397-12401,12422,12424,12428-12435
- Property svn:mergeinfo changed
-
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EnumerableBoolEqualityComparer.cs
r12012 r12438 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.