using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace ItemStatistics; public static class UnsafeUtils { public unsafe static ref TValue GetValueRefOrNullRef(this Dictionary dictionary, TKey key) { int num = dictionary.FindEntry(key); if (num >= 0) { return ref dictionary._entries[num].value; } return ref Unsafe.AsRef((void*)null); } public static DictionaryRefEntries GetRefEntries(this Dictionary dictionary) { return new DictionaryRefEntries(dictionary); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static bool IsNullRef(in T value) { return Unsafe.AsPointer(ref Unsafe.AsRef(ref value)) == null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref U As(in T value) { return ref Unsafe.As(ref Unsafe.AsRef(ref value)); } } public ref struct DictionaryRefEntries { private readonly Dictionary dictionary; private int current; public readonly ref TKey current_key => ref dictionary._entries[current - 1].key; public readonly ref TValue current_value => ref dictionary._entries[current - 1].value; public DictionaryRefEntries(Dictionary dictionary) { this.dictionary = dictionary; current = 0; } public bool MoveNext() { while ((uint)current < (uint)dictionary._count) { if (dictionary._entries[current++].hashCode >= 0) { return true; } } current = dictionary._count - 1; return false; } }