Back to his old tricks then
Buying up other peoples ideas & exploiting the idea.
So much for quitting Microsoft to spend more time with his medicines. Billionaire Bill Gates has reportedly started a new venture, bgC3 LLC. TechFlash has described Gates' new baby as a think-tank that was founded after he quit his full-time duties with Microsoft this summer after 33 years. Gates is on his own at bgC3 LLC, …
.. to in memory Linq first.
private string test(int c)
{
List<int> list1 = new List<int>() { 3, 1, 2, 6, 7, 8, 30 };
List<int> list2 = new List<int>() { 4, 5, 2, 2, 7, 9, 30 };
(from l1 in list1 from l2 in list2 select (l1 * l2 + 111) % 77).ToList<int>().ForEach(n => { if (list1.Count < c) list1.Add(n); });
(from l1 in list1 from l2 in list2 select (l1 * l2 + 111) % 77).ToList<int>().ForEach(n => { if (list2.Count < c) list2.Add(n); });
(from l1 in list1 from l2 in list2 select (l1 * l2 + 111) % 77).ToList<int>().ForEach(n => { if (list1.Count < c) list1.Add(n); });
(from l1 in list1 from l2 in list2 select (l1 * l2 + 111) % 77).ToList<int>().ForEach(n => { if (list2.Count < c) list2.Add(n); });
Stopwatch s = new Stopwatch();
s.Start();
int lLoop = InnerLoopJoin(list1, list2);
s.Stop();
long tLoop = s.ElapsedMilliseconds;
s.Reset();
s.Start();
int lHash = InnerHashJoin(list1, list2);
s.Stop();
long tHash = s.ElapsedMilliseconds;
s.Reset();
return "Hash = " + tHash.ToString() + " Loop = " + tLoop.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
for (int i = 100; i < 4000; i += 100)
listBox1.Items.Add(i.ToString() + test(i));
}
private int InnerLoopJoin(List<int> list1, List<int> list2)
{
var x =
from l1 in list1
from l2 in list2
where l1 == l2
select new { l1, l2 };
return x.Count();
}
private int InnerHashJoin(List<int> list1, List<int> list2)
{
Dictionary<int, int> d = (from l1 in list1 group l1 by l1 into g select g).ToDictionary(n => n.Key, n => n.Count());
var x =
from l2 in list2
where d.ContainsKey (l2)
from i in Enumerable.Range (1, d[l2])
select new { l1 = l2, l2 };
return x.Count();
}
private int MergeJoin(List<int> list1, List<int> list2)
{
// var x =
// from
return 0;
}