Instantly share code, notes, and snippets.

View BigHashSet.cs
[DebuggerTypeProxy(typeof(HashSetDebugViewInt<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public class BigHashSet<T> : IEnumerable<T>
{
private readonly BigSet<T> _set;
public BigHashSet() : this(new BigComparer<T>())
{
}
public BigHashSet(IBigEqualityComparer<T> comparer)
View BigComparer.cs
public class BigComparer<T> : IBigEqualityComparer<T>
{
private static FNV1a64 hash;
private static Type _type;
public bool Equals(T x, T y)
{
if (x == null || y == null)
return false;
return object.Equals((T)x, (T)y);
}
View GetObjectSize.cs
public class GetObjectSize
{
public enum SetValueEnum
{
NotSet = -1,
Yes = 1,
No = 0
}
private SetValueEnum _isPrimitive;
private int _primitiveSize;
View BigSet.cs
[Serializable]
public class BigSet<T>
{
private const int ShiftCount = 19;
private const ulong MinimumSize = 1 << ShiftCount;
internal IBigEqualityComparer<T> _comparer;
internal BigArray<ulong> _hashBuckets;
internal BigArray<Slot> _slots;
internal ulong Count;
internal ulong Position;
View BigIntegerPrimality.cs
public class BigIntegerPrimality
{
private readonly Stopwatch MrSw = new Stopwatch();
private readonly BigInteger Three = new BigInteger(3);
public int BitLength;
public int Candidates;
private CryptoGetBytes crng;
public int FermatCandidates;
public int FermatComposites;
public int MillerRabinCandidates;
View CryptoGetBytes.cs
public class CryptoGetBytes : RandomNumberGenerator
{
private readonly int _hashSizeInBytes;
private int _availableCacheBytes;
private volatile byte[] _buffer;
private volatile byte[] _cache;
private volatile int _ptr;
public HashAlgorithm Algorithm;
#if DEBUG
public TinyDictionary<int, long> BytesRequestList = new TinyDictionary<int, long>();
View CryptoEntropy.cs
public class CryptoEntropy
{
public readonly TinyHashSet<byte[]> _entropyTest;
public CryptoEntropy()
{
EntropyRequested = 0;
_entropyTest = new TinyHashSet<byte[]>(new ArrayComparer());
}
public byte[] Entropy => GetEntropy();
public int EntropyRequested{get; private set;}
View CryptoJitterSeedBytes.cs
public class CryptoJitterSeedBytes
{
private readonly object _lock = new object();
public byte[] SeedBuffer => !BypassEntropy ? GetSeed() : MeasureCPUJitter(SeedBufferSize);
public bool BypassEntropy {get; set;}
public bool LoopTesting {get; set;}
public double BufferEntropy {get; private set;}
public bool BypassCPULoadTest {get; set;}
public int SeedBufferSize {get; set;} = 64;
public int PCLimit {get; set;} = 80000;
View CRng.cs
[Serializable]
public class CRng : RandomNumberGenerator
{
private const double DBi = 5.42101086242752E-20D;
private readonly CryptoGetBytes crng = new CryptoGetBytes();
public char NextChar()
{
return(char) (Sample() * char.MaxValue);
}
public char NextChar(char maxValue)
View TinySet.cs
public class TinySet<T>
{
internal IEqualityComparer<T> _comparer;
internal int[] _hashBuckets;
internal Slot[] _slots;
internal int Count;
internal int Position;
internal int Version;
public TinySet() : this(EqualityComparer<T>.Default)
{