-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathBucket.cs
More file actions
77 lines (63 loc) · 1.53 KB
/
Bucket.cs
File metadata and controls
77 lines (63 loc) · 1.53 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
namespace Waher.Utility.ExStat
{
public class Bucket
{
public long Count = 0;
public bool Touched = false;
public Histogram<string>[] SubHistograms = null;
public void Inc(params string[] SubKeys)
{
int i, c;
this.Count++;
this.Touched = true;
if ((c = SubKeys.Length) > 0)
{
if (this.SubHistograms is null)
{
this.SubHistograms = new Histogram<string>[c];
i = 0;
}
else if ((i = this.SubHistograms.Length) < c)
Array.Resize<Histogram<string>>(ref this.SubHistograms, c);
while (i < c)
this.SubHistograms[i++] = new Histogram<string>();
for (i = 0; i < c; i++)
this.SubHistograms[i].Inc(SubKeys[i]);
}
}
public void Join(int Count, bool First, params string[] SubKeys)
{
int i, c;
this.Count += Count;
this.Touched = true;
if ((c = SubKeys.Length) > 0)
{
if (this.SubHistograms is null)
{
this.SubHistograms = new Histogram<string>[c];
i = 0;
}
else if ((i = this.SubHistograms.Length) < c)
Array.Resize<Histogram<string>>(ref this.SubHistograms, c);
while (i < c)
this.SubHistograms[i++] = new Histogram<string>();
for (i = 0; i < c; i++)
{
string SubKey = SubKeys[i];
if (!(SubKey is null))
this.SubHistograms[i].Join(SubKey, Count, First);
}
}
}
public void RemoveUntouched()
{
if (!(this.SubHistograms is null))
{
foreach (Histogram<string> H in this.SubHistograms)
H.RemoveUntouched();
}
}
}
}