- Timestamp:
- 07/04/11 23:58:24 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/GeneralizedRankSelector.cs
r6342 r6508 63 63 double pressure = PressureParameter.ActualValue.Value; 64 64 65 var ordered = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).ToList();65 var ordered = qualities.Select((x, index) => new IndexValuePair(index, x.Value)).OrderBy(x => x.Value).ToList(); 66 66 if (maximization) ordered.Reverse(); 67 67 … … 72 72 73 73 if (copy) { 74 selected[i] = (IScope)scopes[ordered[selIdx]. index].Clone();74 selected[i] = (IScope)scopes[ordered[selIdx].Index].Clone(); 75 75 } else { 76 selected[i] = scopes[ordered[selIdx].index]; 77 scopes.Remove(selected[i]); 76 int idx = ordered[selIdx].Index; 77 selected[i] = scopes[idx]; 78 scopes.RemoveAt(idx); 79 ordered.RemoveAt(selIdx); 80 for (int j = 0; j < ordered.Count; j++) { 81 var o = ordered[j]; 82 if (o.Index > idx) ordered[j] = o.DecrementIndex(); 83 } 78 84 m--; 79 85 } … … 81 87 return selected; 82 88 } 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 } 83 106 } 84 107 }
Note: See TracChangeset
for help on using the changeset viewer.