Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/10/19 17:39:38 (5 years ago)
Author:
gkronber
Message:

#2994: merged r17007:17118 from trunk to branch

Location:
branches/2994-AutoDiffForIntervals
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/HashExtensions.cs

    r17005 r17120  
    2525namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2626  public static class SymbolicExpressionHashExtensions {
     27    /// <summary>
     28    /// Holds data that is necessary to handle tree nodes in hashing / simplification.
     29    /// </summary>
     30    /// <typeparam name="T">The tree node type</typeparam>
    2731    public sealed class HashNode<T> : IComparable<HashNode<T>>, IEquatable<HashNode<T>> where T : class {
    2832      public T Data;
     
    3842      public SimplifyAction Simplify;
    3943
    40       //public IComparer<T> Comparer;
    41 
    4244      public bool IsLeaf => Arity == 0;
    43 
    44       //public HashNode(IComparer<T> comparer) {
    45       //  Comparer = comparer;
    46       //}
    47 
    48       //public HashNode() { }
    4945
    5046      public int CompareTo(HashNode<T> other) {
     
    170166
    171167    /// <summary>
    172     /// Get a function node's child indicest
     168    /// Get a function node's child indices
    173169    /// </summary>
    174170    /// <typeparam name="T">The data type encapsulated by a hash node</typeparam>
    175     /// <param name="nodes">An array of hash nodes with up-to-date node sizes</param>
     171    /// <param name="nodes">An array of hash nodes with up-to-date node sizes (see UpdateNodeSizes)</param>
    176172    /// <param name="i">The index in the array of hash nodes of the node whose children we want to iterate</param>
    177173    /// <returns>An array containing child indices</returns>
     
    188184    }
    189185
     186    /// <summary>
     187    /// Determines size of each branch and sets the results for each node.
     188    /// </summary>
     189    /// <typeparam name="T">The data type encapsulated by a hash node</typeparam>
     190    /// <param name="nodes">An array of hash nodes in postfix order.</param>
     191    /// <returns>The array with updated node sizes. The array is not copied.</returns>
    190192    public static HashNode<T>[] UpdateNodeSizes<T>(this HashNode<T>[] nodes) where T : class {
    191193      for (int i = 0; i < nodes.Length; ++i) {
     
    196198        }
    197199        node.Size = node.Arity;
    198 
     200        // visit all children and sum up their size (assumes postfix order).
    199201        for (int j = i - 1, k = 0; k < node.Arity; j -= 1 + nodes[j].Size, ++k) {
    200202          node.Size += nodes[j].Size;
     
    204206    }
    205207
     208    // disables duplicate branches and removes the disabled nodes
    206209    public static HashNode<T>[] Reduce<T>(this HashNode<T>[] nodes) where T : class {
    207210      int count = 0;
Note: See TracChangeset for help on using the changeset viewer.