Changeset 12392 for trunk/sources
- Timestamp:
- 05/19/15 12:54:14 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EnumerableBoolEqualityComparer.cs
r12012 r12392 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.