Example #1
0
        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));
        }
Example #2
0
        public static void Test6()
        {
            System.Collections.Generic2.Dictionary <string, string> test = new System.Collections.Generic2.Dictionary <string, string>();
            //test.Add("A", "A");
            //test.Add("B", "B");
            //test.Add("C", "C");

            test.Add("D", "D");
            Debug.Assert(test.Remove("D", out string outValue1));
            Debug.Assert("D" == outValue1);
            Debug.Assert(!test.TryGetValue("D", out string outValue2));
            Debug.Assert(test.Count == 0);

            test.Add("D", "D");

            Debug.Assert(test.Count == 1);

            Debug.Assert(test.Remove("D", out string outValue3));

            Debug.Assert(test.Count == 0);
        }