1 | using HeuristicLab.Collections;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
5 | using System;
|
---|
6 | using System.Collections.Generic;
|
---|
7 | using System.Drawing;
|
---|
8 | using System.Linq;
|
---|
9 | using System.Text;
|
---|
10 | using System.Threading.Tasks;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Problems.DataAnalysis.Implementation {
|
---|
13 | [Item("NamedIntervals", "Represents variables with their interval ranges.")]
|
---|
14 | [StorableClass]
|
---|
15 | public class NamedIntervals : Item {
|
---|
16 | ObservableDictionary<string, Interval> variableIntervals = new ObservableDictionary<string, Interval>();
|
---|
17 |
|
---|
18 | public NamedIntervals() : base(){}
|
---|
19 | protected NamedIntervals(bool deserializing) : base(deserializing) { }
|
---|
20 | protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) { }
|
---|
21 |
|
---|
22 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
23 | return new NamedIntervals(this, cloner);
|
---|
24 | }
|
---|
25 |
|
---|
26 | public bool InsertMany(IEnumerable<KeyValuePair<string, Interval>> entries) {
|
---|
27 | if (entries == null) throw new ArgumentNullException("The given dataset is null.");
|
---|
28 | if (entries.Count() != 0) {
|
---|
29 | foreach (var entry in entries) {
|
---|
30 | if (variableIntervals.ContainsKey(entry.Key))
|
---|
31 | variableIntervals[entry.Key] = entry.Value;
|
---|
32 | else
|
---|
33 | variableIntervals.Add(entry.Key, entry.Value);
|
---|
34 | }
|
---|
35 | }
|
---|
36 | return true;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public bool Add(string key, Interval value) {
|
---|
40 | variableIntervals[key] = value;
|
---|
41 | return true;
|
---|
42 | }
|
---|
43 |
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|