- Timestamp:
- 02/11/17 00:27:04 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r14185 r14662 121 121 } 122 122 123 public virtual void Swap(int i, int j) { 124 var h = array[i]; 125 array[i] = array[j]; 126 array[j] = h; 127 OnReset(); 128 } 129 130 public virtual void Reverse(int startIndex, int length) { 131 Array.Reverse(array, startIndex, length); 132 if (length > 1) OnReset(); 133 } 134 135 public virtual void Move(int startIndex, int endIndex, int insertIndex) { 136 if (insertIndex == startIndex) return; 137 if (insertIndex > startIndex && insertIndex <= endIndex) { 138 var start = endIndex + 1; 139 var end = endIndex + insertIndex - startIndex; 140 insertIndex = startIndex; 141 startIndex = start; 142 endIndex = end; 143 } 144 var original = (int[])array.Clone(); 145 Array.Copy(original, startIndex, array, insertIndex, endIndex - startIndex + 1); 146 if (insertIndex > endIndex) 147 Array.Copy(original, endIndex + 1, array, startIndex, insertIndex - startIndex); 148 else Array.Copy(original, insertIndex, array, insertIndex + endIndex - startIndex + 1, startIndex - insertIndex); 149 OnReset(); 150 } 151 152 public virtual void Replace(int startIndex, int[] replacement) { 153 Array.Copy(replacement, 0, array, startIndex, replacement.Length); 154 OnReset(); 155 } 156 123 157 public event EventHandler PermutationTypeChanged; 124 158
Note: See TracChangeset
for help on using the changeset viewer.