示例#1
0
    public void RobinHoodEditTestsSimplePasses()
    {
        Debug.Log("Robin Hood Tests");

        int size = 10;

        IDictionary <string, bool> RH = new RobinHoodDictionary <string, bool>(100000);


        string str = "a";

        for (int i = 0; i < size; i++)
        {
            RH.Add(str, false);
            str = str + "b";
        }
        Assert.True(RH.ContainsKey("a"));
        Debug.Log(RH.Count);
        Assert.True(size == RH.Count);

        DeciderNode node    = new DeciderNode(SmartSquare.StandardBoardSetUp());
        DeciderNode node2   = new DeciderNode(SmartSquare.StandardBoardSetUp());
        DeciderNode badNode = new DeciderNode(SmartSquare.NotStandardBoardSetUp());

        IDictionary <DeciderNode, Empty> game = new RobinHoodDictionary <DeciderNode, Empty>(1000);



        game.Add(node, new Empty());
        //test that the hash override works
        Assert.True(game.ContainsKey(node2));


        //that doesn't contain bad node
        Assert.False(game.ContainsKey(badNode));

        game.Add(badNode, new Empty());

        //that it does
        Assert.True(game.ContainsKey(badNode));
        //count is 2
        Assert.True(game.Count == 2);
    }
示例#2
0
        private static TimeSpan RunRH(int repetitions)
        {
            var dict = new RobinHoodDictionary<string, string>();
            string s = "", s2;

            var sw = Stopwatch.StartNew();
            for (var i = 0; i < repetitions; i++)
            {
                s2 = s;
                var c = (char)(i % char.MaxValue);
                s += c;

                dict.Add(s, s2);
                //Console.WriteLine($"Added {c}, Count = {dict.Count}");
            }
            sw.Stop();

            return sw.Elapsed;
        }