Changeset 14650 for branches/PersistentDataStructures/HeuristicLab.Data/3.3
- Timestamp:
- 02/07/17 14:05:09 (8 years ago)
- Location:
- branches/PersistentDataStructures/HeuristicLab.Data/3.3
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistentDataStructures/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r13979 r14650 146 146 <Compile Include="Interfaces\IStringConvertibleMatrix.cs" /> 147 147 <Compile Include="Interfaces\IStringConvertibleValue.cs" /> 148 <Compile Include="PersistentDataStructures\Adaptations\HistoryArray.cs" /> 149 <Compile Include="PersistentDataStructures\Adaptations\HistoryList.cs" /> 150 <Compile Include="PersistentDataStructures\Implementations\ArrayMappedTrie.cs" /> 148 151 <Compile Include="Plugin.cs" /> 149 152 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/PersistentDataStructures/HeuristicLab.Data/3.3/PercentArray.cs
r14186 r14650 45 45 StringBuilder sb = new StringBuilder(); 46 46 sb.Append("["); 47 if ( array.Length > 0) {48 sb.Append( array[0].ToString("#0.#################### %")); // percent format49 for (int i = 1; i < array.Length; i++)50 sb.Append(";").Append( array[i].ToString("#0.#################### %")); // percent format47 if (historyArray.Length > 0) { 48 sb.Append(historyArray[0].ToString("#0.#################### %")); // percent format 49 for (int i = 1; i < historyArray.Length; i++) 50 sb.Append(";").Append(historyArray[i].ToString("#0.#################### %")); // percent format 51 51 } 52 52 sb.Append("]"); -
branches/PersistentDataStructures/HeuristicLab.Data/3.3/ValueTypeArray.cs
r14186 r14650 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data.PersistentDataStructures.Adaptations; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 32 … … 40 41 } 41 42 42 [Storable] 43 protected T[] array; 43 [Storable(AllowOneWay = true, Name = "array")] 44 protected T[] oldArrayValuePersistence { set { historyArray = new HistoryArray<T>(value); } } 45 46 [Storable] 47 protected HistoryArray<T> historyArray; 44 48 45 49 [Storable] … … 60 64 61 65 public virtual int Length { 62 get { return array.Length; }66 get { return historyArray.Length; } 63 67 #region Mono Compatibility 64 68 // this setter should be protected, but the Mono compiler couldn't handle it … … 66 70 if (ReadOnly) throw new NotSupportedException("Length cannot be set. ValueTypeArray is read-only."); 67 71 if (value != Length) { 68 Array.Resize<T>(ref array,value);72 historyArray.Resize(value); 69 73 while (elementNames.Count > value) 70 74 elementNames.RemoveAt(elementNames.Count - 1); … … 90 94 91 95 public virtual T this[int index] { 92 get { return array[index]; }96 get { return historyArray[index]; } 93 97 set { 94 98 if (ReadOnly) throw new NotSupportedException("Item cannot be set. ValueTypeArray is read-only."); 95 if (!value.Equals( array[index])) {96 array[index] = value;99 if (!value.Equals(historyArray[index])) { 100 historyArray[index] = value; 97 101 OnItemChanged(index); 98 102 } … … 115 119 protected ValueTypeArray(ValueTypeArray<T> original, Cloner cloner) 116 120 : base(original, cloner) { 117 this. array = (T[])original.array.Clone();121 this.historyArray = (HistoryArray<T>)original.historyArray.Clone(); 118 122 this.readOnly = original.readOnly; 119 123 this.resizable = original.resizable; … … 121 125 } 122 126 protected ValueTypeArray() { 123 array = new T[0];127 historyArray = new HistoryArray<T>(0); 124 128 readOnly = false; 125 129 resizable = true; … … 127 131 } 128 132 protected ValueTypeArray(int length) { 129 array = new T[length];133 historyArray = new HistoryArray<T>(length); 130 134 readOnly = false; 131 135 resizable = true; … … 134 138 protected ValueTypeArray(T[] elements) { 135 139 if (elements == null) throw new ArgumentNullException(); 136 array = (T[])elements.Clone();140 historyArray = new HistoryArray<T>(elements); 137 141 readOnly = false; 138 142 resizable = true; … … 147 151 148 152 public T[] CloneAsArray() { 149 //mkommend: this works because T must be a value type (struct constraint); 150 return (T[])array.Clone(); 153 return historyArray.ToArray(); 151 154 } 152 155 153 156 public override string ToString() { 154 if ( array.Length == 0) return "[]";157 if (historyArray.Length == 0) return "[]"; 155 158 156 159 StringBuilder sb = new StringBuilder(); 157 160 sb.Append("["); 158 sb.Append( array[0].ToString());159 for (int i = 1; i < array.Length; i++) {160 sb.Append(";").Append( array[i].ToString());161 sb.Append(historyArray[0].ToString()); 162 for (int i = 1; i < historyArray.Length; i++) { 163 sb.Append(";").Append(historyArray[i].ToString()); 161 164 if (sb.Length > maximumToStringLength) { 162 165 sb.Append("..."); … … 169 172 170 173 public virtual IEnumerator<T> GetEnumerator() { 171 return array.Cast<T>().GetEnumerator();174 return historyArray.Cast<T>().GetEnumerator(); 172 175 } 173 176
Note: See TracChangeset
for help on using the changeset viewer.