Ejemplo n.º 1
0
        public void SimpleRemoveTest()
        {
            using (var test = new PrefixTree <int>(m_Pile))
            {
                const int REMOVE_VALUE   = 15;
                const int REMOVE_VALUE_1 = 1;
                const int REMOVE_VALUE_2 = 17;
                for (int i = 0; i < 20; i++)
                {
                    test["a--{0}".Args(i)] = i;
                }
                test.Remove("a--{0}".Args(REMOVE_VALUE));
                Console.WriteLine(test["a--{0}".Args(REMOVE_VALUE)]);

                test.Remove("a--{0}".Args(REMOVE_VALUE_1));
                Console.WriteLine(test["a--{0}".Args(REMOVE_VALUE_1)]);

                test.Remove("a--{0}".Args(REMOVE_VALUE_2));
                Console.WriteLine(test["a--{0}".Args(REMOVE_VALUE_2)]);


                Aver.AreEqual(test["a--{0}".Args(REMOVE_VALUE)], default(int));
                Aver.AreEqual(test["a--{0}".Args(REMOVE_VALUE_1)], default(int));
                Aver.AreEqual(test["a--{0}".Args(REMOVE_VALUE_2)], default(int));
                Aver.AreEqual(test["a--{0}".Args(19)], 19);
                Aver.AreEqual(test["a--{0}".Args(12)], 12);
            }
        }
Ejemplo n.º 2
0
        public void SimpleCountTest()
        {
            using (var test = new PrefixTree <int>(m_Pile))
            {
                const int COUNT = 1000;
                for (int i = 0; i < COUNT; i++)
                {
                    test["{0}".Args(i)] = i;
                }
                Aver.AreEqual(test.Count, COUNT);
                var   rnd    = new Random();
                int[] delete = { rnd.Next(COUNT), rnd.Next(COUNT) };
                Array.Sort(delete);
                for (int i = delete[0]; i < delete[1]; i++)
                {
                    test.Remove("{0}".Args(i));
                }
                int deleted = delete[1] - delete[0];
                Aver.AreEqual(test.Count, COUNT - deleted);

                test.Remove("{0}".Args(COUNT - 1));
                Aver.AreEqual(test.Count, COUNT - deleted - 1);
            }
        }