Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/17/13 12:07:20 (11 years ago)
Author:
ascheibe
Message:

#2069 simplified Interpret methods of symbols

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/Logical Comparators/LessThanOrEqual.cs

    r10011 r10046  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    4951    public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) {
    5052      ISymbolicExpressionTreeNode lhs = null, rhs = null;
    51       var enumerator = children.GetEnumerator();
    52       int childCount = 0;
    53       while (enumerator.MoveNext()) {
    54         childCount++;
    55         switch (childCount) {
    56           case 1: lhs = enumerator.Current; break;
    57           case 2: rhs = enumerator.Current; break;
    58           default: throw new System.Exception("Unexpected number of children. Expected 2 children.");
    59         }
    60       }
    61       if (childCount < 2) throw new System.Exception("Unexpected number of children. Expected 2 children.");
     53      if (children.Count() != 2)
     54        throw new Exception("Unexpected number of children. Expected 2 children.");
     55
     56      lhs = children.First();
     57      rhs = children.Last();
    6258
    6359      var result = new[] {
Note: See TracChangeset for help on using the changeset viewer.