示例#1
0
        public static void FractalDictionaryTest_0()
        {
            FractalDictionary fd = new FractalDictionary();

            List <object> coordinates = new List <object>();

            coordinates = new List <object> {
                1, 2, 3
            };
            fd.Add(coordinates, "Value_123");
            coordinates = new List <object> {
                1, 2, 4
            };
            fd.Add(coordinates, "Value_124");

            Console.WriteLine("TryGet: " + fd.TryGet(new List <object> {
                1, 2, 4
            }));
            Console.WriteLine("TryGet: " + fd.TryGet(new List <object> {
                2, 2, 4
            }));
            Console.WriteLine("TryGet: " + fd.TryGet(new List <object> {
                1, 2, 6
            }));

            Console.WriteLine($"Total Dict: {FractalDictionary.totalInnerDictionaries}");
        }
示例#2
0
        public static void FractalDictionaryTest_1()
        {
            FractalDictionary fd = new FractalDictionary();
            Stopwatch         sw = new Stopwatch();

            List <object> coordinates;

            sw.Start();
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        for (int m = 0; m < 10; m++)
                        {
                            coordinates = new List <object> {
                                i, j, k, m
                            };
                            fd.Add(coordinates, $"Value{i}{j}{k}{m}");
                        }
                    }
                }
            }
            sw.Stop();
            Console.WriteLine("Add ms: " + sw.ElapsedTicks);

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        for (int m = 0; m < 10; m++)
                        {
                            coordinates = new List <object> {
                                i, j, k, m
                            };
                            sw.Start();
                            object o = fd.TryGet(new List <object> {
                                i, j, k, m
                            });
                            sw.Stop();
                            Console.WriteLine($"TryGet: {i}{j}{k}{m} | " + o);
                            Console.WriteLine("ms: " + sw.ElapsedTicks);
                            sw.Reset();
                        }
                    }
                }
            }

            Console.WriteLine($"Total Dict: {FractalDictionary.totalInnerDictionaries}");
        }