Changeset 17887 for branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs
- Timestamp:
- 03/12/21 14:00:36 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting_reintegration/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs
r17631 r17887 34 34 get => HeuristicLab.Common.Resources.VSImageLibrary.Object; 35 35 } 36 private IDictionary<string, Interval> intervals { get; } = new Dictionary<string, Interval>();37 36 38 [Storable(Name = "StorableIntervalInformation")] 37 //[Storable] 38 private IDictionary<string, Interval> intervals { get; set; } = new Dictionary<string, Interval>(); 39 40 [Storable(OldName = "StorableIntervalInformation")] 39 41 private KeyValuePair<string, double[]>[] StorableIntervalInformation { 42 set { 43 foreach (var varInt in value) 44 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 45 } 46 } 47 48 [Storable] 49 private object[] StorableIntervals { 40 50 get { 41 var l = new List<KeyValuePair<string, double[]>>(); 42 foreach (var varInt in intervals) 51 var names = intervals.Keys.ToArray(); 52 var lowerBounds = intervals.Values.Select(i => i.LowerBound).ToArray(); 53 var upperBounds = intervals.Values.Select(i => i.UpperBound).ToArray(); 43 54 44 l.Add(new KeyValuePair<string, double[]>(varInt.Key, 45 new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound })); 46 return l.ToArray(); 55 return new object[] { names, lowerBounds, upperBounds }; 47 56 } 48 57 49 58 set { 50 foreach (var varInt in value) 51 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 59 var names = (string[])value[0]; 60 var lowerBounds = (double[])value[1]; 61 var upperBounds = (double[])value[2]; 62 63 for (int i = 0; i < names.Length; i++) { 64 intervals.Add(names[i], new Interval(lowerBounds[i], upperBounds[i])); 65 } 52 66 } 53 67 } … … 80 94 public void SetInterval(string identifier, Interval interval) { 81 95 intervals[identifier] = interval; 96 RaiseChanged(); 82 97 } 83 98 84 99 public void AddInterval(string identifier, Interval interval) { 85 100 intervals.Add(identifier, interval); 101 RaiseChanged(); 86 102 } 87 103 88 104 public void DeleteInterval(string identifier) { 89 105 intervals.Remove(identifier); 106 RaiseChanged(); 90 107 } 91 108 … … 102 119 yield return Tuple.Create(variableInterval.Key, variableInterval.Value); 103 120 } 121 122 public event EventHandler Changed; 123 private void RaiseChanged() { 124 OnChanged(); 125 var handler = Changed; 126 if (handler != null) 127 handler(this, EventArgs.Empty); 128 } 129 130 protected virtual void OnChanged() { } 104 131 } 105 132 }
Note: See TracChangeset
for help on using the changeset viewer.