Skip to content

Instantly share code, notes, and snippets.

@dadhi
Created March 29, 2019 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadhi/ec1b49287d6185c265b9a18f860dd26b to your computer and use it in GitHub Desktop.
Save dadhi/ec1b49287d6185c265b9a18f860dd26b to your computer and use it in GitHub Desktop.
DictionarySlimWtf
private DictionarySlim<TypeVal, string> _dict;
public DictionarySlim<TypeVal, string> DictSlim()
{
var dict = new DictionarySlim<TypeVal, string>();
foreach (var key in _keys.Take(Count))
dict.GetOrAddValueRef(key) = "a";
dict.GetOrAddValueRef(typeof(ImHashMapBenchmarks)) = "!";
return dict;
}
public struct TypeVal : IEquatable<TypeVal>
{
public static implicit operator TypeVal(Type t) => new TypeVal(t);
public readonly Type Type;
public TypeVal(Type type) => Type = type;
public bool Equals(TypeVal other) => Type == other.Type;
public override bool Equals(object obj) => !ReferenceEquals(null, obj) && obj is TypeVal other && Equals(other);
public override int GetHashCode() => Type.GetHashCode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment