Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6684


Ignore:
Timestamp:
08/30/11 17:48:18 (13 years ago)
Author:
mkommend
Message:

#1579: Changed cloning of SymbolicExpressionTreeNodes.

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r6375 r6684  
    5555      : base() {
    5656      symbol = original.symbol; // symbols are reused
    57       subtrees = new List<ISymbolicExpressionTreeNode>(original.subtrees.Count);
    58       foreach (var subtree in original.subtrees) {
    59         var clonedSubtree = cloner.Clone(subtree);
    60         subtrees.Add(clonedSubtree);
    61         clonedSubtree.Parent = this;
     57      if (original.subtrees != null) {
     58        subtrees = new List<ISymbolicExpressionTreeNode>(original.subtrees.Count);
     59        foreach (var subtree in original.subtrees) {
     60          var clonedSubtree = cloner.Clone(subtree);
     61          subtrees.Add(clonedSubtree);
     62          clonedSubtree.Parent = this;
     63        }
    6264      }
    6365    }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTerminalNode.cs

    r6233 r6684  
    3737    [StorableConstructor]
    3838    protected SymbolicExpressionTreeTerminalNode(bool deserializing) : base(deserializing) { }
    39     // don't call cloning constructor of base to prevent allocation of sub-trees list in base!
    40     protected SymbolicExpressionTreeTerminalNode(SymbolicExpressionTreeTerminalNode original, Cloner cloner)
    41       : base() {
    42       // symbols are reused
    43       this.Symbol = original.Symbol;
    44     }
     39    protected SymbolicExpressionTreeTerminalNode(SymbolicExpressionTreeTerminalNode original, Cloner cloner) : base(original, cloner) { }
    4540    protected SymbolicExpressionTreeTerminalNode() : base() { }
    4641
Note: See TracChangeset for help on using the changeset viewer.