1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
class Distribuzione
{
private Dictionary<String, SortedDictionary<Tuple<double, double>, int>> distr;
double intervall = 10;
public Distribuzione()
{
distr = new Dictionary<String, SortedDictionary<Tuple<double, double>, int>>();
}
//intervall standard 10
public void addAttributDef(String s, double i)
{
addAttribute(s, i, intervall);
}
public void addAttribute(String s, double value, double inte)
{
SortedDictionary<Tuple<double, double>, int> actualdistr;
double min, max;
int i = 1;
min = value - (value % inte);
max = value + (inte - (value % inte));
Tuple<double, double> tmp = new Tuple<double, double>(min, max);
if (!distr.TryGetValue(s, out actualdistr))
{
actualdistr = new SortedDictionary<Tuple<double, double>, int>();
actualdistr.Add(tmp, 1);
distr.Add(s, actualdistr);
}
else
{
if (!actualdistr.TryGetValue(tmp, out i)) actualdistr.Add(tmp, 1);
else { i++; actualdistr.Remove(tmp); actualdistr.Add(tmp, i); }
distr.Remove(s);
distr.Add(s, actualdistr);
}
}
public void addElemento(ElementoDisribuzione e, double inter)
{
foreach (var item in e.getVariabili()) {
this.addAttribute(item.Key, item.Value, inter);
}
}
public void addElementoDef(ElementoDisribuzione e)
{
addElemento(e, intervall);
}
public bool getdistribuzione(string s, out SortedDictionary<Tuple<double, double>, int> req)
{
if (distr.TryGetValue(s, out req)) return true;
else return false;
}
}
|