Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
- Timestamp:
- 03/18/19 17:24:30 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r13366 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 122 122 } 123 123 124 public virtual void Swap(int i, int j) { 125 var h = array[i]; 126 array[i] = array[j]; 127 array[j] = h; 128 OnReset(); 129 } 130 131 public virtual void Reverse(int startIndex, int length) { 132 Array.Reverse(array, startIndex, length); 133 if (length > 1) OnReset(); 134 } 135 136 public virtual void Move(int startIndex, int endIndex, int insertIndex) { 137 if (insertIndex == startIndex) return; 138 if (insertIndex > startIndex && insertIndex <= endIndex) { 139 var start = endIndex + 1; 140 var end = endIndex + insertIndex - startIndex; 141 insertIndex = startIndex; 142 startIndex = start; 143 endIndex = end; 144 } 145 var original = (int[])array.Clone(); 146 Array.Copy(original, startIndex, array, insertIndex, endIndex - startIndex + 1); 147 if (insertIndex > endIndex) 148 Array.Copy(original, endIndex + 1, array, startIndex, insertIndex - startIndex); 149 else Array.Copy(original, insertIndex, array, insertIndex + endIndex - startIndex + 1, startIndex - insertIndex); 150 OnReset(); 151 } 152 153 public virtual void Replace(int startIndex, int[] replacement) { 154 Array.Copy(replacement, 0, array, startIndex, replacement.Length); 155 OnReset(); 156 } 157 124 158 public event EventHandler PermutationTypeChanged; 125 159
Note: See TracChangeset
for help on using the changeset viewer.