Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/05/11 00:04:04 (13 years ago)
Author:
abeham
Message:

#1496

  • a little undecided today, I removed the private struct for using KeyValuePair<U, V>
File:
1 edited

Legend:

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

    r6510 r6511  
    6363      double pressure = PressureParameter.ActualValue.Value;
    6464
    65       var ordered = qualities.Select((x, index) => new IndexValuePair(index, x.Value)).OrderBy(x => x.Value).ToList();
     65      var ordered = qualities.Select((x, index) => new KeyValuePair<int, double>(index, x.Value)).OrderBy(x => x.Value).ToList();
    6666      if (maximization) ordered.Reverse();
    6767
     
    7272
    7373        if (copy) {
    74           selected[i] = (IScope)scopes[ordered[selIdx].Index].Clone();
     74          selected[i] = (IScope)scopes[ordered[selIdx].Key].Clone();
    7575        } else {
    76           int idx = ordered[selIdx].Index;
     76          int idx = ordered[selIdx].Key;
    7777          selected[i] = scopes[idx];
    7878          scopes.RemoveAt(idx);
     
    8080          for (int j = 0; j < ordered.Count; j++) {
    8181            var o = ordered[j];
    82             if (o.Index > idx) ordered[j] = o.DecrementIndex();
     82            if (o.Key > idx) ordered[j] = new KeyValuePair<int, double>(o.Key - 1, o.Value);
    8383          }
    8484          m--;
     
    8787      return selected;
    8888    }
    89 
    90     private struct IndexValuePair {
    91       private int index;
    92       internal int Index { get { return index; } }
    93       private double value;
    94       internal double Value { get { return value; } }
    95 
    96       internal IndexValuePair(int index, double value) {
    97         this.index = index;
    98         this.value = value;
    99       }
    100 
    101       internal IndexValuePair DecrementIndex() {
    102         this.index--;
    103         return this;
    104       }
    105     }
    10689  }
    10790}
Note: See TracChangeset for help on using the changeset viewer.