Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/11/17 00:27:04 (7 years ago)
Author:
abeham
Message:

#2731: Added better performing manipulation methods to Permutation and adapted the manipulators to use them

  • Added unit tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/Swap3Manipulator.cs

    r14185 r14662  
    5757    public static void Apply(IRandom random, Permutation permutation) {
    5858      if (permutation.Length < 3) throw new ArgumentException("Swap3Manipulator: The permutation must be at least of size 3.", "permutation");
    59       int index1, index2, index3, temp;
     59      int index1, index2, index3;
    6060
    6161      do {
     
    6565      } while (index1 == index2 || index2 == index3 || index1 == index3);
    6666
    67       // swap positions 1 and 2
    68       temp = permutation[index1];
    69       permutation[index1] = permutation[index2];
    70       permutation[index2] = temp;
    71       // swap positions 2 and 3
    72       temp = permutation[index2];
    73       permutation[index2] = permutation[index3];
    74       permutation[index3] = temp;
     67      permutation.Swap(index1, index2);
     68      permutation.Swap(index2, index3);
    7569    }
    7670
Note: See TracChangeset for help on using the changeset viewer.