Changeset 3430 for trunk/sources
- Timestamp:
- 04/20/10 02:02:39 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab 3.3/Files.txt
r3384 r3430 57 57 HeuristicLab.Random\3.3:HeuristicLab.Random-3.3.dll 58 58 HeuristicLab.Selection\3.3:HeuristicLab.Selection-3.3.dll 59 HeuristicLab.Selection.OffspringSelection\3.3:HeuristicLab.Selection.OffspringSelection-3.3.dll60 59 HeuristicLab.SequentialEngine\3.3:HeuristicLab.SequentialEngine-3.3.dll 61 60 HeuristicLab.TestFunctions\3.3:HeuristicLab.TestFunctions-3.3.dll -
trunk/sources/HeuristicLab.Data.Views/3.3/BoolValueView.cs
r3362 r3430 32 32 get { return (BoolValue)base.Content; } 33 33 set { base.Content = value; } 34 } 35 36 public override bool ReadOnly { 37 get { 38 if ((Content != null) && Content.ReadOnly) return true; 39 return base.ReadOnly; 40 } 41 set { base.ReadOnly = value; } 34 42 } 35 43 … … 82 90 83 91 private void valueCheckBox_CheckedChanged(object sender, EventArgs e) { 84 Content.Value = valueCheckBox.Checked;92 if (!Content.ReadOnly) Content.Value = valueCheckBox.Checked; 85 93 } 86 94 } -
trunk/sources/HeuristicLab.Data.Views/3.3/ComparisonView.cs
r3362 r3430 32 32 get { return (Comparison)base.Content; } 33 33 set { base.Content = value; } 34 } 35 36 public override bool ReadOnly { 37 get { 38 if ((Content != null) && Content.ReadOnly) return true; 39 return base.ReadOnly; 40 } 41 set { base.ReadOnly = value; } 34 42 } 35 43 … … 82 90 83 91 private void valueComboBox_SelectedIndexChanged(object sender, EventArgs e) { 84 if ( Content != null) Content.Value = (ComparisonType)valueComboBox.SelectedItem;92 if ((Content != null) && !Content.ReadOnly) Content.Value = (ComparisonType)valueComboBox.SelectedItem; 85 93 } 86 94 } -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r3362 r3430 35 35 get { return (IStringConvertibleArray)base.Content; } 36 36 set { base.Content = value; } 37 } 38 39 public override bool ReadOnly { 40 get { 41 if ((Content != null) && Content.ReadOnly) return true; 42 return base.ReadOnly; 43 } 44 set { base.ReadOnly = value; } 37 45 } 38 46 … … 133 141 } 134 142 private void lengthTextBox_Validated(object sender, EventArgs e) { 135 Content.Length = int.Parse(lengthTextBox.Text);143 if (!Content.ReadOnly) Content.Length = int.Parse(lengthTextBox.Text); 136 144 errorProvider.SetError(lengthTextBox, string.Empty); 137 145 } -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r3362 r3430 34 34 [Content(typeof(IStringConvertibleMatrix), true)] 35 35 public partial class StringConvertibleMatrixView : AsynchronousContentView { 36 private int[] virtualRowIndizes; 37 private List<KeyValuePair<int, SortOrder>> sortedColumnIndizes; 38 private RowComparer rowComparer; 39 36 40 public new IStringConvertibleMatrix Content { 37 41 get { return (IStringConvertibleMatrix)base.Content; } … … 39 43 } 40 44 41 private int[] virtualRowIndizes; 42 private List<KeyValuePair<int, SortOrder>> sortedColumnIndizes; 43 RowComparer rowComparer; 45 public override bool ReadOnly { 46 get { 47 if ((Content != null) && Content.ReadOnly) return true; 48 return base.ReadOnly; 49 } 50 set { base.ReadOnly = value; } 51 } 44 52 45 53 public StringConvertibleMatrixView() { … … 66 74 base.DeregisterContentEvents(); 67 75 } 68 69 76 protected override void RegisterContentEvents() { 70 77 base.RegisterContentEvents(); … … 75 82 Content.ReadOnlyViewChanged += new EventHandler(Content_ReadOnlyViewChanged); 76 83 } 77 78 84 79 85 protected override void OnContentChanged() { … … 204 210 } 205 211 private void rowsTextBox_Validated(object sender, EventArgs e) { 206 int textBoxValue = int.Parse(rowsTextBox.Text); 207 if (textBoxValue != Content.Rows) 208 Content.Rows = textBoxValue; 212 if (!Content.ReadOnly) Content.Rows = int.Parse(rowsTextBox.Text); 209 213 errorProvider.SetError(rowsTextBox, string.Empty); 210 214 } … … 226 230 } 227 231 private void columnsTextBox_Validated(object sender, EventArgs e) { 228 int textBoxValue = int.Parse(columnsTextBox.Text); 229 if (textBoxValue != Content.Columns) 230 Content.Columns = textBoxValue; 232 if (!Content.ReadOnly) Content.Columns = int.Parse(columnsTextBox.Text); 231 233 errorProvider.SetError(columnsTextBox, string.Empty); 232 234 } -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs
r3402 r3430 33 33 get { return (IStringConvertibleValue)base.Content; } 34 34 set { base.Content = value; } 35 } 36 37 public override bool ReadOnly { 38 get { 39 if ((Content != null) && Content.ReadOnly) return true; 40 return base.ReadOnly; 41 } 42 set { base.ReadOnly = value; } 35 43 } 36 44 … … 103 111 } 104 112 private void valueTextBox_Validated(object sender, EventArgs e) { 105 Content.SetValue(valueTextBox.Text);113 if (!Content.ReadOnly) Content.SetValue(valueTextBox.Text); 106 114 errorProvider.SetError(valueTextBox, string.Empty); 107 115 valueTextBox.Text = Content.GetValue(); -
trunk/sources/HeuristicLab.Data/3.3/BoolArray.cs
r3376 r3430 37 37 cloner.RegisterClonedObject(this, clone); 38 38 clone.ReadOnlyView = ReadOnlyView; 39 clone.readOnly = readOnly; 39 40 return clone; 40 41 } -
trunk/sources/HeuristicLab.Data/3.3/BoolMatrix.cs
r3376 r3430 30 30 [StorableClass] 31 31 public class BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix { 32 32 public BoolMatrix() : base() { } 33 33 public BoolMatrix(int rows, int columns) : base(rows, columns) { } 34 34 public BoolMatrix(int rows, int columns, IEnumerable<string> columnNames) : base(rows, columns, columnNames) { } … … 39 39 40 40 public override IDeepCloneable Clone(Cloner cloner) { 41 BoolMatrix clone = new BoolMatrix( matrix);41 BoolMatrix clone = new BoolMatrix(); 42 42 cloner.RegisterClonedObject(this, clone); 43 43 clone.ReadOnlyView = ReadOnlyView; 44 clone.ColumnNames = new List<string>(ColumnNames); 45 clone.RowNames = new List<string>(RowNames); 44 clone.matrix = (bool[,])matrix.Clone(); 45 clone.columnNames = new List<string>(columnNames); 46 clone.rowNames = new List<string>(rowNames); 47 clone.sortableView = sortableView; 48 clone.readOnly = readOnly; 46 49 return clone; 47 50 } … … 82 85 set { Columns = value; } 83 86 } 84 IEnumerable<string> IStringConvertibleMatrix.ColumnNames {85 get { return this.ColumnNames; }86 set { this.ColumnNames = value; }87 }88 IEnumerable<string> IStringConvertibleMatrix.RowNames {89 get { return this.RowNames; }90 set { this.RowNames = value; }91 }92 bool IStringConvertibleMatrix.SortableView {93 get { return this.SortableView; }94 set { this.SortableView = value; }95 }96 87 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 97 88 return Validate(value, out errorMessage); -
trunk/sources/HeuristicLab.Data/3.3/BoolValue.cs
r3376 r3430 42 42 cloner.RegisterClonedObject(this, clone); 43 43 clone.ReadOnlyView = ReadOnlyView; 44 clone.readOnly = readOnly; 44 45 return clone; 45 46 } -
trunk/sources/HeuristicLab.Data/3.3/Comparison.cs
r3376 r3430 41 41 cloner.RegisterClonedObject(this, clone); 42 42 clone.ReadOnlyView = ReadOnlyView; 43 clone.readOnly = readOnly; 43 44 return clone; 44 45 } -
trunk/sources/HeuristicLab.Data/3.3/DateTimeValue.cs
r3376 r3430 36 36 cloner.RegisterClonedObject(this, clone); 37 37 clone.ReadOnlyView = ReadOnlyView; 38 clone.readOnly = readOnly; 38 39 return clone; 39 40 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs
r3376 r3430 37 37 cloner.RegisterClonedObject(this, clone); 38 38 clone.ReadOnlyView = ReadOnlyView; 39 clone.readOnly = readOnly; 39 40 return clone; 40 41 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs
r3376 r3430 39 39 40 40 public override IDeepCloneable Clone(Cloner cloner) { 41 DoubleMatrix clone = new DoubleMatrix( matrix);41 DoubleMatrix clone = new DoubleMatrix(); 42 42 cloner.RegisterClonedObject(this, clone); 43 43 clone.ReadOnlyView = ReadOnlyView; 44 clone.ColumnNames = new List<string>(ColumnNames); 45 clone.RowNames = new List<string>(RowNames); 44 clone.matrix = (double[,])matrix.Clone(); 45 clone.columnNames = new List<string>(columnNames); 46 clone.rowNames = new List<string>(rowNames); 47 clone.sortableView = sortableView; 48 clone.readOnly = readOnly; 46 49 return clone; 47 50 } … … 82 85 set { Columns = value; } 83 86 } 84 IEnumerable<string> IStringConvertibleMatrix.ColumnNames {85 get { return this.ColumnNames; }86 set { this.ColumnNames = value; }87 }88 IEnumerable<string> IStringConvertibleMatrix.RowNames {89 get { return this.RowNames; }90 set { this.RowNames = value; }91 }92 bool IStringConvertibleMatrix.SortableView {93 get { return this.SortableView; }94 set { this.SortableView = value; }95 }96 87 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 97 88 return Validate(value, out errorMessage); -
trunk/sources/HeuristicLab.Data/3.3/DoubleValue.cs
r3376 r3430 42 42 cloner.RegisterClonedObject(this, clone); 43 43 clone.ReadOnlyView = ReadOnlyView; 44 clone.readOnly = readOnly; 44 45 return clone; 45 46 } -
trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleArray.cs
r3370 r3430 27 27 int Length { get; set; } 28 28 29 bool ReadOnly { get; } 30 29 31 bool Validate(string value, out string errorMessage); 30 32 string GetValue(int index); -
trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleMatrix.cs
r3370 r3430 32 32 33 33 bool SortableView { get; set; } 34 bool ReadOnly { get; } 34 35 35 36 bool Validate(string value, out string errorMessage); -
trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleValue.cs
r3370 r3430 25 25 namespace HeuristicLab.Data { 26 26 public interface IStringConvertibleValue : IContent { 27 bool ReadOnly { get; } 28 27 29 bool Validate(string value, out string errorMessage); 28 30 string GetValue(); -
trunk/sources/HeuristicLab.Data/3.3/IntArray.cs
r3376 r3430 37 37 cloner.RegisterClonedObject(this, clone); 38 38 clone.ReadOnlyView = ReadOnlyView; 39 clone.readOnly = readOnly; 39 40 return clone; 40 41 } -
trunk/sources/HeuristicLab.Data/3.3/IntMatrix.cs
r3376 r3430 39 39 40 40 public override IDeepCloneable Clone(Cloner cloner) { 41 IntMatrix clone = new IntMatrix( matrix);41 IntMatrix clone = new IntMatrix(); 42 42 cloner.RegisterClonedObject(this, clone); 43 43 clone.ReadOnlyView = ReadOnlyView; 44 clone.ColumnNames = new List<string>(ColumnNames); 45 clone.RowNames = new List<string>(RowNames); 44 clone.matrix = (int[,])matrix.Clone(); 45 clone.columnNames = new List<string>(columnNames); 46 clone.rowNames = new List<string>(rowNames); 47 clone.sortableView = sortableView; 48 clone.readOnly = readOnly; 46 49 return clone; 47 50 } … … 82 85 set { Columns = value; } 83 86 } 84 IEnumerable<string> IStringConvertibleMatrix.ColumnNames {85 get { return this.ColumnNames; }86 set { this.ColumnNames = value; }87 }88 IEnumerable<string> IStringConvertibleMatrix.RowNames {89 get { return this.RowNames; }90 set { this.RowNames = value; }91 }92 87 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 93 88 return Validate(value, out errorMessage); -
trunk/sources/HeuristicLab.Data/3.3/IntValue.cs
r3376 r3430 42 42 cloner.RegisterClonedObject(this, clone); 43 43 clone.ReadOnlyView = ReadOnlyView; 44 clone.readOnly = readOnly; 44 45 return clone; 45 46 } -
trunk/sources/HeuristicLab.Data/3.3/PercentValue.cs
r3402 r3430 36 36 cloner.RegisterClonedObject(this, clone); 37 37 clone.ReadOnlyView = ReadOnlyView; 38 clone.readOnly = readOnly; 38 39 return clone; 39 40 } -
trunk/sources/HeuristicLab.Data/3.3/StringArray.cs
r3317 r3430 44 44 get { return array.Length; } 45 45 protected set { 46 if (ReadOnly) throw new NotSupportedException("Length cannot be set. StringArray is read-only."); 46 47 if (value != Length) { 47 48 Array.Resize<string>(ref array, value); … … 53 54 get { return array[index]; } 54 55 set { 56 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringArray is read-only."); 55 57 if (value != array[index]) { 56 58 if ((value != null) || (array[index] != string.Empty)) { … … 62 64 } 63 65 66 [Storable] 67 protected bool readOnly; 68 public virtual bool ReadOnly { 69 get { return readOnly; } 70 } 71 64 72 public StringArray() { 65 73 array = new string[0]; 74 readOnly = false; 66 75 } 67 76 public StringArray(int length) { … … 69 78 for (int i = 0; i < array.Length; i++) 70 79 array[i] = string.Empty; 80 readOnly = false; 71 81 } 72 82 public StringArray(string[] elements) { … … 75 85 for (int i = 0; i < array.Length; i++) 76 86 array[i] = elements[i] == null ? string.Empty : elements[i]; 87 readOnly = false; 77 88 } 78 89 … … 82 93 clone.ReadOnlyView = ReadOnlyView; 83 94 clone.array = (string[])array.Clone(); 95 clone.readOnly = readOnly; 84 96 return clone; 97 } 98 99 public virtual StringArray AsReadOnly() { 100 StringArray readOnlyStringArray = (StringArray)this.Clone(); 101 readOnlyStringArray.readOnly = true; 102 return readOnlyStringArray; 85 103 } 86 104 … … 97 115 } 98 116 99 public IEnumerator<string> GetEnumerator() {117 public virtual IEnumerator<string> GetEnumerator() { 100 118 return array.Cast<string>().GetEnumerator(); 101 119 } 102 120 103 121 IEnumerator IEnumerable.GetEnumerator() { 104 return array.GetEnumerator();122 return GetEnumerator(); 105 123 } 106 124 -
trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs
r3320 r3430 33 33 [Item("StringMatrix", "Represents a matrix of strings.")] 34 34 [StorableClass] 35 public class StringMatrix : Item, IEnumerable , IStringConvertibleMatrix {35 public class StringMatrix : Item, IEnumerable<string>, IStringConvertibleMatrix { 36 36 public override Image ItemImage { 37 37 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; } … … 42 42 43 43 [Storable] 44 pr ivateList<string> columnNames;45 public IEnumerable<string> ColumnNames {44 protected List<string> columnNames; 45 public virtual IEnumerable<string> ColumnNames { 46 46 get { return this.columnNames; } 47 47 set { 48 if (ReadOnly) throw new NotSupportedException("ColumnNames cannot be set. StringMatrix is read-only."); 48 49 if (value == null || value.Count() == 0) 49 50 columnNames = new List<string>(); … … 55 56 } 56 57 [Storable] 57 pr ivateList<string> rowNames;58 public IEnumerable<string> RowNames {58 protected List<string> rowNames; 59 public virtual IEnumerable<string> RowNames { 59 60 get { return this.rowNames; } 60 61 set { 62 if (ReadOnly) throw new NotSupportedException("RowNames cannot be set. StringMatrix is read-only."); 61 63 if (value == null || value.Count() == 0) 62 64 rowNames = new List<string>(); … … 68 70 } 69 71 [Storable] 70 pr ivatebool sortableView;71 public bool SortableView {72 protected bool sortableView; 73 public virtual bool SortableView { 72 74 get { return sortableView; } 73 75 set { 76 if (ReadOnly) throw new NotSupportedException("SortableView cannot be set. StringMatrix is read-only."); 74 77 if (value != sortableView) { 75 78 sortableView = value; … … 82 85 get { return matrix.GetLength(0); } 83 86 protected set { 87 if (ReadOnly) throw new NotSupportedException("Rows cannot be set. StringMatrix is read-only."); 84 88 if (value != Rows) { 85 89 string[,] newMatrix = new string[value, Columns]; … … 97 101 get { return matrix.GetLength(1); } 98 102 protected set { 103 if (ReadOnly) throw new NotSupportedException("Columns cannot be set. StringMatrix is read-only."); 99 104 if (value != Columns) { 100 105 string[,] newMatrix = new string[Rows, value]; … … 113 118 get { return matrix[rowIndex, columnIndex]; } 114 119 set { 120 if (ReadOnly) throw new NotSupportedException("Item cannot be set. StringMatrix is read-only."); 115 121 if (value != matrix[rowIndex, columnIndex]) { 116 122 if ((value != null) || (matrix[rowIndex, columnIndex] != string.Empty)) { … … 122 128 } 123 129 130 [Storable] 131 protected bool readOnly; 132 public virtual bool ReadOnly { 133 get { return readOnly; } 134 } 135 124 136 public StringMatrix() { 125 137 matrix = new string[0, 0]; … … 127 139 rowNames = new List<string>(); 128 140 sortableView = false; 141 readOnly = false; 129 142 } 130 143 public StringMatrix(int rows, int columns) { … … 137 150 rowNames = new List<string>(); 138 151 sortableView = false; 152 readOnly = false; 139 153 } 140 154 protected StringMatrix(int rows, int columns, IEnumerable<string> columnNames) … … 156 170 rowNames = new List<string>(); 157 171 sortableView = false; 172 readOnly = false; 158 173 } 159 174 protected StringMatrix(string[,] elements, IEnumerable<string> columnNames) … … 170 185 cloner.RegisterClonedObject(this, clone); 171 186 clone.ReadOnlyView = ReadOnlyView; 172 clone.SortableView = SortableView;173 187 clone.matrix = (string[,])matrix.Clone(); 174 188 clone.columnNames = new List<string>(columnNames); 175 189 clone.rowNames = new List<string>(rowNames); 190 clone.sortableView = sortableView; 191 clone.readOnly = readOnly; 176 192 return clone; 193 } 194 195 public virtual StringMatrix AsReadOnly() { 196 StringMatrix readOnlyStringMatrix = (StringMatrix)this.Clone(); 197 readOnlyStringMatrix.readOnly = true; 198 return readOnlyStringMatrix; 177 199 } 178 200 … … 192 214 } 193 215 194 public virtual IEnumerator GetEnumerator() { 195 return matrix.GetEnumerator(); 216 public virtual IEnumerator<string> GetEnumerator() { 217 return matrix.Cast<string>().GetEnumerator(); 218 } 219 220 IEnumerator IEnumerable.GetEnumerator() { 221 return GetEnumerator(); 196 222 } 197 223 … … 257 283 set { Columns = value; } 258 284 } 259 IEnumerable<string> IStringConvertibleMatrix.ColumnNames {260 get { return this.ColumnNames; }261 set { this.ColumnNames = value; }262 }263 IEnumerable<string> IStringConvertibleMatrix.RowNames {264 get { return this.RowNames; }265 set { this.RowNames = value; }266 }267 bool IStringConvertibleMatrix.SortableView {268 get { return this.SortableView; }269 set { this.SortableView = value; }270 }271 285 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 272 286 return Validate(value, out errorMessage); -
trunk/sources/HeuristicLab.Data/3.3/StringValue.cs
r3376 r3430 39 39 get { return value; } 40 40 set { 41 if (ReadOnly) throw new NotSupportedException("Value cannot be set. StringValue is read-only."); 41 42 if (value != this.value) { 42 43 if ((value != null) || (this.value != string.Empty)) { … … 48 49 } 49 50 51 [Storable] 52 protected bool readOnly; 53 public virtual bool ReadOnly { 54 get { return readOnly; } 55 } 56 50 57 public StringValue() { 51 58 this.value = string.Empty; 59 this.readOnly = false; 52 60 } 53 61 public StringValue(string value) { 54 62 this.value = value != null ? value : string.Empty; 63 this.readOnly = false; 55 64 } 56 65 … … 59 68 cloner.RegisterClonedObject(this, clone); 60 69 clone.ReadOnlyView = ReadOnlyView; 70 clone.readOnly = readOnly; 61 71 return clone; 72 } 73 74 public virtual StringValue AsReadOnly() { 75 StringValue readOnlyStringValue = (StringValue)this.Clone(); 76 readOnlyStringValue.readOnly = true; 77 return readOnlyStringValue; 62 78 } 63 79 -
trunk/sources/HeuristicLab.Data/3.3/TimeSpanValue.cs
r3376 r3430 37 37 cloner.RegisterClonedObject(this, clone); 38 38 clone.ReadOnlyView = ReadOnlyView; 39 clone.readOnly = readOnly; 39 40 return clone; 40 41 } -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs
r3306 r3430 22 22 using System; 23 23 using System.Collections; 24 using System.Collections.Generic; 24 25 using System.Drawing; 26 using System.Linq; 25 27 using System.Text; 26 28 using HeuristicLab.Common; … … 31 33 [Item("ValueTypeArray<T>", "An abstract base class for representing arrays of value types.")] 32 34 [StorableClass] 33 public abstract class ValueTypeArray<T> : Item, IEnumerable where T : struct {35 public abstract class ValueTypeArray<T> : Item, IEnumerable<T> where T : struct { 34 36 public override Image ItemImage { 35 37 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; } … … 42 44 get { return array.Length; } 43 45 protected set { 46 if (ReadOnly) throw new NotSupportedException("Length cannot be set. ValueTypeArray is read-only."); 44 47 if (value != Length) { 45 48 Array.Resize<T>(ref array, value); … … 51 54 get { return array[index]; } 52 55 set { 56 if (ReadOnly) throw new NotSupportedException("Item cannot be set. ValueTypeArray is read-only."); 53 57 if (!value.Equals(array[index])) { 54 58 array[index] = value; … … 58 62 } 59 63 64 [Storable] 65 protected bool readOnly; 66 public virtual bool ReadOnly { 67 get { return readOnly; } 68 } 69 60 70 protected ValueTypeArray() { 61 71 array = new T[0]; 72 readOnly = false; 62 73 } 63 74 protected ValueTypeArray(int length) { 64 75 array = new T[length]; 76 readOnly = false; 65 77 } 66 78 protected ValueTypeArray(T[] elements) { 67 79 if (elements == null) throw new ArgumentNullException(); 68 80 array = (T[])elements.Clone(); 81 readOnly = false; 69 82 } 70 83 … … 72 85 ValueTypeArray<T> clone = (ValueTypeArray<T>)base.Clone(cloner); 73 86 clone.array = (T[])array.Clone(); 87 clone.readOnly = readOnly; 74 88 return clone; 89 } 90 91 public virtual ValueTypeArray<T> AsReadOnly() { 92 ValueTypeArray<T> readOnlyValueTypeArray = (ValueTypeArray<T>)this.Clone(); 93 readOnlyValueTypeArray.readOnly = true; 94 return readOnlyValueTypeArray; 75 95 } 76 96 … … 87 107 } 88 108 89 public virtual IEnumerator GetEnumerator() { 90 return array.GetEnumerator(); 109 public virtual IEnumerator<T> GetEnumerator() { 110 return array.Cast<T>().GetEnumerator(); 111 } 112 113 IEnumerator IEnumerable.GetEnumerator() { 114 return GetEnumerator(); 91 115 } 92 116 -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs
r3320 r3430 33 33 [Item("ValueTypeMatrix<T>", "An abstract base class for representing matrices of value types.")] 34 34 [StorableClass] 35 public abstract class ValueTypeMatrix<T> : Item, IEnumerable where T : struct {35 public abstract class ValueTypeMatrix<T> : Item, IEnumerable<T> where T : struct { 36 36 public override Image ItemImage { 37 37 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; } … … 42 42 43 43 [Storable] 44 pr ivateList<string> columnNames;45 public IEnumerable<string> ColumnNames {44 protected List<string> columnNames; 45 public virtual IEnumerable<string> ColumnNames { 46 46 get { return this.columnNames; } 47 47 set { 48 if (ReadOnly) throw new NotSupportedException("ColumnNames cannot be set. ValueTypeMatrix is read-only."); 48 49 if (value == null || value.Count() == 0) 49 50 columnNames = new List<string>(); … … 55 56 } 56 57 [Storable] 57 pr ivateList<string> rowNames;58 public IEnumerable<string> RowNames {58 protected List<string> rowNames; 59 public virtual IEnumerable<string> RowNames { 59 60 get { return this.rowNames; } 60 61 set { 62 if (ReadOnly) throw new NotSupportedException("RowNames cannot be set. ValueTypeMatrix is read-only."); 61 63 if (value == null || value.Count() == 0) 62 64 rowNames = new List<string>(); … … 68 70 } 69 71 [Storable] 70 pr ivatebool sortableView;71 public bool SortableView {72 protected bool sortableView; 73 public virtual bool SortableView { 72 74 get { return sortableView; } 73 75 set { 76 if (ReadOnly) throw new NotSupportedException("SortableView cannot be set. ValueTypeMatrix is read-only."); 74 77 if (value != sortableView) { 75 78 sortableView = value; … … 82 85 get { return matrix.GetLength(0); } 83 86 protected set { 87 if (ReadOnly) throw new NotSupportedException("Rows cannot be set. ValueTypeMatrix is read-only."); 84 88 if (value != Rows) { 85 89 T[,] newArray = new T[value, Columns]; … … 97 101 get { return matrix.GetLength(1); } 98 102 protected set { 103 if (ReadOnly) throw new NotSupportedException("Columns cannot be set. ValueTypeMatrix is read-only."); 99 104 if (value != Columns) { 100 105 T[,] newArray = new T[Rows, value]; … … 113 118 get { return matrix[rowIndex, columnIndex]; } 114 119 set { 120 if (ReadOnly) throw new NotSupportedException("Item cannot be set. ValueTypeMatrix is read-only."); 115 121 if (!value.Equals(matrix[rowIndex, columnIndex])) { 116 122 matrix[rowIndex, columnIndex] = value; … … 118 124 } 119 125 } 126 } 127 128 [Storable] 129 protected bool readOnly; 130 public virtual bool ReadOnly { 131 get { return readOnly; } 120 132 } 121 133 … … 125 137 rowNames = new List<string>(); 126 138 sortableView = false; 139 readOnly = false; 127 140 } 128 141 protected ValueTypeMatrix(int rows, int columns) { … … 131 144 rowNames = new List<string>(); 132 145 sortableView = false; 146 readOnly = false; 133 147 } 134 148 protected ValueTypeMatrix(int rows, int columns, IEnumerable<string> columnNames) … … 136 150 ColumnNames = columnNames; 137 151 } 138 protected ValueTypeMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames)152 protected ValueTypeMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames) 139 153 : this(rows, columns, columnNames) { 140 154 RowNames = rowNames; … … 146 160 rowNames = new List<string>(); 147 161 sortableView = false; 162 readOnly = false; 148 163 } 149 164 protected ValueTypeMatrix(T[,] elements, IEnumerable<string> columnNames) … … 158 173 public override IDeepCloneable Clone(Cloner cloner) { 159 174 ValueTypeMatrix<T> clone = (ValueTypeMatrix<T>)base.Clone(cloner); 160 clone.SortableView = SortableView;161 175 clone.matrix = (T[,])matrix.Clone(); 162 176 clone.columnNames = new List<string>(columnNames); 163 177 clone.rowNames = new List<string>(rowNames); 178 clone.sortableView = sortableView; 179 clone.readOnly = readOnly; 164 180 return clone; 181 } 182 183 public virtual ValueTypeMatrix<T> AsReadOnly() { 184 ValueTypeMatrix<T> readOnlyValueTypeMatrix = (ValueTypeMatrix<T>)this.Clone(); 185 readOnlyValueTypeMatrix.readOnly = true; 186 return readOnlyValueTypeMatrix; 165 187 } 166 188 … … 180 202 } 181 203 182 public virtual IEnumerator GetEnumerator() { 183 return matrix.GetEnumerator(); 204 public virtual IEnumerator<T> GetEnumerator() { 205 return matrix.Cast<T>().GetEnumerator(); 206 } 207 208 IEnumerator IEnumerable.GetEnumerator() { 209 return GetEnumerator(); 184 210 } 185 211 -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeValue.cs
r3376 r3430 39 39 get { return value; } 40 40 set { 41 if (ReadOnly) throw new NotSupportedException("Value cannot be set. ValueTypeValue is read-only."); 41 42 if (!value.Equals(this.value)) { 42 43 this.value = value; … … 46 47 } 47 48 49 [Storable] 50 protected bool readOnly; 51 public virtual bool ReadOnly { 52 get { return readOnly; } 53 } 54 48 55 protected ValueTypeValue() { 49 56 this.value = default(T); 57 this.readOnly = false; 50 58 } 51 59 protected ValueTypeValue(T value) { 52 60 this.value = value; 61 this.readOnly = false; 53 62 } 54 63 … … 56 65 ValueTypeValue<T> clone = (ValueTypeValue<T>)base.Clone(cloner); 57 66 clone.value = value; 67 clone.readOnly = readOnly; 58 68 return clone; 69 } 70 71 public virtual ValueTypeValue<T> AsReadOnly() { 72 ValueTypeValue<T> readOnlyValueTypeValue = (ValueTypeValue<T>)this.Clone(); 73 readOnlyValueTypeValue.readOnly = true; 74 return readOnlyValueTypeValue; 59 75 } 60 76 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVector.cs
r3376 r3430 46 46 cloner.RegisterClonedObject(this, clone); 47 47 clone.ReadOnlyView = ReadOnlyView; 48 clone.readOnly = readOnly; 48 49 return clone; 49 50 } -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs
r3376 r3430 46 46 cloner.RegisterClonedObject(this, clone); 47 47 clone.ReadOnlyView = ReadOnlyView; 48 clone.readOnly = readOnly; 48 49 return clone; 49 50 } -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r3376 r3430 67 67 cloner.RegisterClonedObject(this, clone); 68 68 clone.ReadOnlyView = ReadOnlyView; 69 clone.readOnly = readOnly; 69 70 return clone; 70 71 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVector.cs
r3376 r3430 46 46 cloner.RegisterClonedObject(this, clone); 47 47 clone.ReadOnlyView = ReadOnlyView; 48 clone.readOnly = readOnly; 48 49 return clone; 49 50 } -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r3377 r3430 151 151 get { return true; } 152 152 set { throw new NotSupportedException(); } 153 } 154 public bool ReadOnly { 155 get { return false; } 153 156 } 154 157 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Dataset.cs
r3377 r3430 291 291 } 292 292 293 public bool ReadOnly { 294 get { return false; } 295 } 296 293 297 IEnumerable<string> IStringConvertibleMatrix.ColumnNames { 294 298 get { return this.VariableNames; } -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPCoordinatesPathEvaluator.cs
r3376 r3430 68 68 dm[i, j] = CalculateDistance(c[i, 0], c[i, 1], c[j, 0], c[j, 1]); 69 69 } 70 DistanceMatrixParameter.ActualValue = dm;70 DistanceMatrixParameter.ActualValue = (DoubleMatrix)dm.AsReadOnly(); 71 71 } 72 72 -
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r3340 r3430 168 168 public override IDeepCloneable Clone(Cloner cloner) { 169 169 TravelingSalesmanProblem clone = (TravelingSalesmanProblem)base.Clone(cloner); 170 clone.DistanceMatrixParameter.Value = DistanceMatrixParameter.Value; 170 171 clone.Initialize(); 171 172 return clone;
Note: See TracChangeset
for help on using the changeset viewer.