Created
March 29, 2019 06:23
-
-
Save dadhi/ec1b49287d6185c265b9a18f860dd26b to your computer and use it in GitHub Desktop.
DictionarySlimWtf
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
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