Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/22 11:02:45 (3 years ago)
Author:
gkronber
Message:

#3145: refactored infix formatter to improve output (less parenthesis) and added unit tests to test that the infix formatter works correclty.

Location:
trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs

    r17180 r18211  
    5050    void InsertSubtree(int index, ISymbolicExpressionTreeNode tree);
    5151    void RemoveSubtree(int index);
     52    void ReplaceSubtree(int index, ISymbolicExpressionTreeNode tree);
     53    void ReplaceSubtree(ISymbolicExpressionTreeNode orig, ISymbolicExpressionTreeNode repl);
    5254
    5355    void ResetLocalParameters(IRandom random);
  • trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r17180 r18211  
    177177      ResetCachedValues();
    178178    }
     179    public virtual void ReplaceSubtree(int index, ISymbolicExpressionTreeNode repl) {
     180      subtrees[index].Parent = null;
     181      subtrees[index] = repl;
     182      repl.Parent = this;
     183      ResetCachedValues();
     184    }
     185    public virtual void ReplaceSubtree(ISymbolicExpressionTreeNode old, ISymbolicExpressionTreeNode repl) {
     186      var index = IndexOfSubtree(old);
     187      subtrees[index].Parent = null;
     188      subtrees[index] = repl;
     189      repl.Parent = this;
     190      ResetCachedValues();
     191    }
    179192
    180193    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() {
Note: See TracChangeset for help on using the changeset viewer.