// ----------------------------------------------------------------------------- // file="TestSwiss" // Project: StgSharp // Copyright (c) Nitload. // SPDX-License-Identifier: MIT // ----------------------------------------------------------------------------- using StgSharp.Collections; using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; namespace StgSharp { internal static partial class Program { public static void TestSwiss() { SwissTable swiss = SwissTable.Create(); for (nuint i = 0; i < 5000; i++) { Console.Write($"Set {i}: "); _ = swiss.TryAddOrSet(i, i * 2, out _); Console.WriteLine($"Set a kvp of ({i},{i * 2})"); } Random rand = new Random(); for (int i = 0; i < 100; i++) { Console.Write($"Get {i}: "); nuint key = (nuint)rand.Next(4000, 5000); if (swiss.TryGet(key, out nuint value)) { Console.WriteLine($"Success in get a kvp of ({key},{value})"); } else { Console.WriteLine($"Failed to get a kvp of ({key},?)"); } } } } }