This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Security.Cryptography; | |
/// <summary> | |
/// Pros: ~Very few to no Collisions within int bit space ~(2,147,483,647) | |
/// Cons: Maintains a TinyDictionary(byte[],byte[]), Decreased performance, non-deterministic across application or | |
/// method domains | |
/// Cannot Transform or reuse. | |
/// </summary> | |
public class Mapping64BitToHash32Bit : HashAlgorithm | |
{ | |
private readonly FNV1a64 hasher = new FNV1a64(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
private class ArrayComparer<T> : IEqualityComparer<T> | |
{ | |
private static Type _type; | |
private static int _size; | |
public bool Equals(T x, T y) | |
{ | |
if(x == null || y == null) | |
return false; | |
if(_type == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Converters | |
{ | |
public static bool IsValidPrimitive(Type type) | |
{ | |
switch(Type.GetTypeCode(type)) | |
{ | |
case TypeCode.Boolean: | |
case TypeCode.Char: | |
case TypeCode.SByte: | |
case TypeCode.Byte: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// XOR folding version reduces collisions by greater than ~2/3's | |
/// </summary> | |
public class FNV1a32 : HashAlgorithm | |
{ | |
private const uint K = 0x1000193; | |
private uint _hash; | |
public uint Hash; | |
public uint Seed = 0x811c9dc5; | |
public FNV1a32() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// IEnumerable File Helper Class. | |
/// </summary> | |
public static class IEnumerableFileHelper | |
{ | |
/// <summary> | |
/// Save a IEnumerable to a file. | |
/// </summary> | |
public static void SaveToFileIEnum<T>(this IEnumerable<T> obj, string path, bool append = false) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Pathhelper | |
{ | |
[Flags] | |
[Serializable] | |
public enum DeviceTypes | |
{ | |
None = 0, | |
CDRom = 1, | |
InvalidCDRom = 2, | |
PhysicalDrive = 4, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileHash128 : Murmur3 | |
{ | |
private const int BufferSize = 1024 * 80; | |
private readonly byte[] buffer = new byte[1073741823]; | |
public byte[] GetFileHashSync(string path) | |
{ | |
var fLen = 0; | |
using(var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize, false)) | |
{ | |
var offset = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LabelMJS : Label | |
{ | |
public enum Angles | |
{ | |
/// <summary> | |
/// Normal drawing direction. | |
/// </summary> | |
LeftToRight = 0, | |
/// <summary> | |
/// Draw text top to bottom as viewed from the left. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ByteArray : IFormattable, IComparable, IComparable<ByteArray>, IEquatable<ByteArray> | |
{ | |
public byte[] bytes; | |
public ByteArray() : this(0) | |
{ | |
} | |
public ByteArray(int size) | |
{ | |
bytes = new byte[size]; | |
Active = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IEnumerableStep | |
{ | |
/// <summary> | |
/// Generates a sequence of 8-bit signed numbers within a specified range starting at | |
/// 'form' through 'to' with a given step value. | |
/// </summary> | |
public static IEnumerable<sbyte> Step(this sbyte from, sbyte to, int step) | |
{ | |
return Step(from, to, step).Select(i => i); | |
} |