- Timestamp:
- 10/28/18 21:26:06 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/HashExtensions.cs
r16260 r16261 82 82 var node = nodes[i]; 83 83 var hashes = new int[node.Arity + 1]; 84 int idx = 0; 85 foreach (int c in nodes.IterateChildren(i)) { 86 hashes[idx++] = nodes[c].CalculatedHashValue; 87 } 88 hashes[idx] = node.HashValue; 84 for (int j = i - 1, k = 0; k < node.Arity; j -= 1 + nodes[j].Size, k++) { 85 hashes[k] = nodes[j].CalculatedHashValue; 86 } 87 hashes[node.Arity] = node.HashValue; 89 88 return HashUtil.JSHash(hashes); 90 89 } … … 137 136 } else { // i have some non-terminal children 138 137 var sorted = new HashNode<T>[size]; 139 var indices = nodes.IterateChildren(i); 138 var indices = new int[node.Arity]; 139 for (int j = i - 1, k = 0; k < node.Arity; j -= 1 + nodes[j].Size, ++k) { 140 indices[k] = j; 141 } 140 142 Array.Sort(indices, sort); 141 143 … … 158 160 159 161 /// <summary> 160 /// Get a function node's child indices from left to right162 /// Get a function node's child indicest 161 163 /// </summary> 162 164 /// <typeparam name="T">The data type encapsulated by a hash node</typeparam> … … 184 186 } 185 187 node.Size = node.Arity; 186 foreach (int j in nodes.IterateChildren(i)) { 188 189 for (int j = i - 1, k = 0; k < node.Arity; j -= 1 + nodes[j].Size, ++k) { 187 190 node.Size += nodes[j].Size; 188 191 } … … 199 202 } 200 203 201 foreach (var j in nodes.IterateChildren(i)) { 204 var arity = node.Arity; 205 for (int j = i - 1, k = 0; k < arity; j -= 1 + nodes[j].Size, ++k) { 202 206 if (node.HashValue == nodes[j].HashValue) { 203 207 nodes[j].Enabled = false;
Note: See TracChangeset
for help on using the changeset viewer.