public static void Test4() { var dictionary = new System.Collections.Generic2.Dictionary <string, string>(); Debug.Assert(0 == dictionary.EnsureCapacity(0), "0 == dictionary.EnsureCapacity(0)"); dictionary.TrimExcess(); Debug.Assert(0 == dictionary.EnsureCapacity(0), "0 == dictionary.EnsureCapacity(0)"); }
public static void Test9() { foreach (var count in new int[] { 85, 89 }) { var dictionary = new System.Collections.Generic2.Dictionary <int, int>(20); for (int i = 0; i < count; i++) { dictionary.Add(i, 0); } dictionary.TrimExcess(); var res = dictionary.EnsureCapacity(0); Debug.Assert(res >= count && res <= int.MaxValue); } }
public static void Test8() { System.Collections.Generic2.Dictionary <string, int> dictionary = new System.Collections.Generic2.Dictionary <string, int>(7); for (int i = 0; i < 4; i++) { dictionary.Add(i.ToString(), 0); } var s_64bit = new string[] { "95e85f8e-67a3-4367-974f-dd24d8bb2ca2", "eb3d6fe9-de64-43a9-8f58-bddea727b1ca" }; var s_32bit = new string[] { "25b1f130-7517-48e3-96b0-9da44e8bfe0e", "ba5a3625-bc38-4bf1-a707-a3cfe2158bae" }; string[] chained = (Environment.Is64BitProcess ? s_64bit : s_32bit).ToArray(); dictionary.Add(chained[0], 0); dictionary.Add(chained[1], 0); for (int i = 0; i < 4; i++) { dictionary.Remove(i.ToString()); } dictionary.TrimExcess(3); Debug.Assert(2 == dictionary.Count); int val; Debug.Assert(dictionary.TryGetValue(chained[0], out val)); Debug.Assert(dictionary.TryGetValue(chained[1], out val)); }
public static void Test5() { System.Collections.Generic2.Dictionary <string, string> test = new System.Collections.Generic2.Dictionary <string, string>(); test.TrimExcess(); }