Changeset 16263 for trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs
- Timestamp:
- 10/30/18 13:08:01 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs
r16255 r16263 39 39 private static readonly ISymbolicExpressionTreeNodeComparer comparer = new SymbolicExpressionTreeNodeComparer(); 40 40 41 public static intComputeHash(this ISymbolicExpressionTree tree) {41 public static ulong ComputeHash(this ISymbolicExpressionTree tree) { 42 42 return ComputeHash(tree.Root.GetSubtree(0).GetSubtree(0)); 43 43 } 44 44 45 45 // compute node hashes without sorting the arguments 46 public static Dictionary<ISymbolicExpressionTreeNode, int> ComputeNodeHashes(this ISymbolicExpressionTree tree) {46 public static Dictionary<ISymbolicExpressionTreeNode, ulong> ComputeNodeHashes(this ISymbolicExpressionTree tree) { 47 47 var root = tree.Root.GetSubtree(0).GetSubtree(0); 48 48 var nodes = root.MakeNodes(); … … 57 57 } 58 58 59 public static intComputeHash(this ISymbolicExpressionTreeNode treeNode) {59 public static ulong ComputeHash(this ISymbolicExpressionTreeNode treeNode) { 60 60 var hashNodes = treeNode.MakeNodes(); 61 61 var simplified = hashNodes.Simplify(); 62 return ComputeHash(simplified); 63 } 64 65 public static int ComputeHash(this HashNode<ISymbolicExpressionTreeNode>[] nodes) { 66 int hash = 1315423911; 67 foreach (var node in nodes) 68 hash ^= (hash << 5) + node.CalculatedHashValue + (hash >> 2); 69 return hash; 70 } 62 //return ComputeHash(simplified); 63 return simplified.Last().CalculatedHashValue; 64 } 65 66 //public static int ComputeHash(this HashNode<ISymbolicExpressionTreeNode>[] nodes) { 67 // int hash = 1315423911; 68 // foreach (var node in nodes) 69 // hash ^= (hash << 5) + node.CalculatedHashValue + (hash >> 2); 70 // return hash; 71 //} 71 72 72 73 public static HashNode<ISymbolicExpressionTreeNode> ToHashNode(this ISymbolicExpressionTreeNode node) { … … 77 78 name = variableTreeNode.VariableName; 78 79 } 79 var hash = name.GetHashCode();80 var hash = (ulong)name.GetHashCode(); 80 81 var hashNode = new HashNode<ISymbolicExpressionTreeNode>(comparer) { 81 82 Data = node,
Note: See TracChangeset
for help on using the changeset viewer.