Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3128


Ignore:
Timestamp:
03/19/10 17:52:02 (15 years ago)
Author:
abeham
Message:

fixing bug in BestSelector as described in #930

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Selection/3.3/BestSelector.cs

    r3096 r3128  
    5252      var list = temp.ToList();
    5353
    54       int j = 0;
    55       for (int i = 0; i < count; i++) {
    56         if (copy) {
     54      if (copy) {
     55        for (int i = 0, j = 0; i < count; i++, j++) {
     56          if (j >= list.Count) j = 0;
    5757          selected[i] = (IScope)scopes[list[j].index].Clone();
    58           j++;
    59           if (j >= list.Count) j = 0;
    60         } else {
    61           selected[i] = scopes[list[j].index];
    62           scopes.RemoveAt(list[j].index);
    63           list.RemoveAt(j);
    6458        }
     59      } else {
     60        int i;
     61        for (i = 0; i < count; i++) {
     62          selected[i] = scopes[list[i].index];
     63        }
     64        // remove the selected scopes starting from the scope with the highest index
     65        if (i < list.Count) list.RemoveRange(i, list.Count - i);
     66        list = list.OrderBy(x => x.index).ToList();
     67        do {
     68          i--;
     69          scopes.RemoveAt(list[i].index);
     70        } while (i > 0);
    6571      }
    6672      return selected;
Note: See TracChangeset for help on using the changeset viewer.