Changeset 13579


Ignore:
Timestamp:
01/29/16 17:04:19 (4 years ago)
Author:
mkommend
Message:

#2570: Made SymbolicExpressionTreeNode.GetDepth/Length thread safe.

File:
1 edited

Legend:

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

    r12509 r13579  
    106106      if (length > 0) return length;
    107107      else {
    108         length = 1;
     108        ushort l = 1;
    109109        if (subtrees != null) {
    110110          for (int i = 0; i < subtrees.Count; i++) {
    111             checked { length += (ushort)subtrees[i].GetLength(); }
     111            checked { l += (ushort)subtrees[i].GetLength(); }
    112112          }
    113113        }
     114        length = l;
    114115        return length;
    115116      }
     
    119120      if (depth > 0) return depth;
    120121      else {
     122        ushort d = 0;
    121123        if (subtrees != null) {
    122           for (int i = 0; i < subtrees.Count; i++) depth = Math.Max(depth, (ushort)subtrees[i].GetDepth());
    123         }
    124         depth++;
     124          for (int i = 0; i < subtrees.Count; i++) d = Math.Max(d, (ushort)subtrees[i].GetDepth());
     125        }
     126        d++;
     127        depth = d;
    125128        return depth;
    126129      }
Note: See TracChangeset for help on using the changeset viewer.