Changeset 15973 for branches/2522_RefactorPluginInfrastructure/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
- Timestamp:
- 06/28/18 11:13:37 (6 years ago)
- Location:
- branches/2522_RefactorPluginInfrastructure
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2522_RefactorPluginInfrastructure
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r12012 r15973 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. … … 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.