Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/21/17 11:33:53 (7 years ago)
Author:
pkimmesw
Message:

#2665 Testet Problems, Testet error functions, Small fixes, Created HL files

Location:
branches/PushGP/HeuristicLab.PushGP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP

    • Property svn:ignore
      •  

        old new  
        11*.user
         2packages
         3TestResults
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushProgram.cs

    r15189 r15334  
    55namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
    66  using System.Diagnostics;
     7  using System.Diagnostics.CodeAnalysis;
     8
    79  using Constants;
    810  using Data.Pool;
     
    3840
    3941    [StorableConstructor]
    40     public PushProgram(bool deserializing) : this(EmptyExpressions) { }
     42    private PushProgram(bool deserializing) : this(EmptyExpressions) { }
    4143
    4244    public PushProgram(IReadOnlyList<Expression> expressions) {
     
    6769    }
    6870
    69     void IPooledObject.Init() { }
    70 
    7171    void IPooledObject.Reset() {
    7272      expressions = null;
     
    159159    [NonSerialized]
    160160    private int? hashCode;
     161    [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
    161162    public override int GetHashCode() {
    162163      if (hashCode == null) hashCode = expressions.HashCode();
     
    256257      get
    257258      {
    258         if (branches == null) {
    259           branches = 1;
    260 
    261           for (var i = 0; i < Count; i++) {
    262             var expression = expressions[i];
    263 
    264             if (!expression.IsProgram)
    265               continue;
    266 
    267             var program = (PushProgram)expression;
    268             branches += program.Branches;
    269           }
    270         }
    271 
     259        if (branches == null) CountBranches();
    272260        return branches.Value;
     261      }
     262    }
     263
     264    private void CountBranches() {
     265      branches = 1;
     266
     267      for (var i = 0; i < Count; i++) {
     268        var expression = expressions[i];
     269
     270        if (!expression.IsProgram)
     271          continue;
     272
     273        var program = (PushProgram)expression;
     274        branches += program.Branches;
    273275      }
    274276    }
Note: See TracChangeset for help on using the changeset viewer.