Skip to content

Commit 917715f

Browse files
author
Dan Hog
committed
Add content
1 parent 31cddea commit 917715f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5707
-30
lines changed

DLib.sln

+6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
1112
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
1214
EndGlobalSection
1315
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1416
{FA780655-380A-4C71-9501-43381B534700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1517
{FA780655-380A-4C71-9501-43381B534700}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{FA780655-380A-4C71-9501-43381B534700}.Debug|x64.ActiveCfg = Debug|x64
19+
{FA780655-380A-4C71-9501-43381B534700}.Debug|x64.Build.0 = Debug|x64
1620
{FA780655-380A-4C71-9501-43381B534700}.Release|Any CPU.ActiveCfg = Release|Any CPU
1721
{FA780655-380A-4C71-9501-43381B534700}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{FA780655-380A-4C71-9501-43381B534700}.Release|x64.ActiveCfg = Release|x64
23+
{FA780655-380A-4C71-9501-43381B534700}.Release|x64.Build.0 = Release|x64
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

DLib/Benchmark.cs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Diagnostics;
3+
4+
namespace DLib
5+
{
6+
public static class Benchmark
7+
{
8+
public static long TimeIt<TResult>(Func<TResult> func, ulong accuracy)
9+
{
10+
func();
11+
Stopwatch sw = new Stopwatch();
12+
sw.Start();
13+
for (ulong i = 0; i < accuracy; i++)
14+
func();
15+
return sw.ElapsedMilliseconds / (long)accuracy;
16+
}
17+
18+
public static long TimeIt<T, TResult>(Func<T, TResult> func, T p, ulong accuracy)
19+
{
20+
func(p);
21+
Stopwatch sw = new Stopwatch();
22+
sw.Start();
23+
for (ulong i = 0; i < accuracy; i++)
24+
func(p);
25+
return sw.ElapsedMilliseconds / (long)accuracy;
26+
}
27+
28+
public static long TimeIt<T1, T2, TResult>(Func<T1, T2, TResult> func, T1 p1, T2 p2, ulong accuracy)
29+
{
30+
func(p1, p2);
31+
Stopwatch sw = new Stopwatch();
32+
sw.Start();
33+
for (ulong i = 0; i < accuracy; i++)
34+
func(p1, p2);
35+
return sw.ElapsedMilliseconds / (long)accuracy;
36+
}
37+
38+
public static long TimeIt<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> func, T1 p1, T2 p2, T3 p3, ulong accuracy)
39+
{
40+
func(p1, p2, p3);
41+
Stopwatch sw = new Stopwatch();
42+
sw.Start();
43+
for (ulong i = 0; i < accuracy; i++)
44+
func(p1, p2, p3);
45+
return sw.ElapsedMilliseconds / (long)accuracy;
46+
}
47+
48+
public static long TimeIt<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> func, T1 p1, T2 p2, T3 p3, T4 p4, ulong accuracy)
49+
{
50+
func(p1, p2, p3, p4);
51+
Stopwatch sw = new Stopwatch();
52+
sw.Start();
53+
for (ulong i = 0; i < accuracy; i++)
54+
func(p1, p2, p3, p4);
55+
return sw.ElapsedMilliseconds / (long)accuracy;
56+
}
57+
}
58+
}

DLib/Class1.cs

-12
This file was deleted.

DLib/Collection/Array.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
6+
namespace DLib.Collection
7+
{
8+
public class Array<T>
9+
{
10+
T[][] arrays;
11+
12+
public ulong Length { get; private set; }
13+
14+
public Array(ulong length)
15+
{
16+
arrays = new T[(int)System.Math.Ceiling(length / (double)int.MaxValue)][];
17+
for (int i = 0; i < arrays.Length - 1; i++)
18+
arrays[i] = new T[int.MaxValue];
19+
arrays[arrays.Length - 1] = new T[(int)(length % (int.MaxValue - 1))];
20+
Length = length;
21+
}
22+
23+
public Array(List<T> list)
24+
{
25+
arrays = new T[list.Lists.Count][];
26+
for (int i = 0; i < arrays.Length; i++)
27+
arrays[i] = list.Lists[i].ToArray();
28+
Length = list.Count;
29+
}
30+
31+
public T this[ulong i]
32+
{
33+
get => arrays[(int)(i / (double)int.MaxValue)][(int)(i % (int.MaxValue - 1))];
34+
set => arrays[(int)(i / (double)int.MaxValue)][(int)(i % (int.MaxValue - 1))] = value;
35+
}
36+
37+
public void Foreach(Action<T> action)
38+
{
39+
foreach (T[] array in arrays)
40+
foreach (T item in array)
41+
action(item);
42+
}
43+
}
44+
}

DLib/Collection/BitArray.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
6+
namespace DLib.Collection
7+
{
8+
public class BitArray
9+
{
10+
System.Collections.BitArray[] arrays;
11+
12+
public ulong Length { get; private set; }
13+
14+
public BitArray(ulong length)
15+
{
16+
arrays = new System.Collections.BitArray[(int)System.Math.Ceiling(length / (double)int.MaxValue)];
17+
for (int i = 0; i < arrays.Length - 1; i++)
18+
arrays[i] = new System.Collections.BitArray(int.MaxValue);
19+
arrays[arrays.Length - 1] = new System.Collections.BitArray((int)(length % (int.MaxValue - 1)));
20+
Length = length;
21+
}
22+
23+
public bool this[ulong i]
24+
{
25+
get => arrays[(int)(i / (double)int.MaxValue)][(int)(i % (int.MaxValue - 1))];
26+
set => arrays[(int)(i / (double)int.MaxValue)][(int)(i % (int.MaxValue - 1))] = value;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)