public void TestStringTreeDictionaryAddSingle()
        {
            StringTreeDictionary <string> dictionary = new StringTreeDictionary <string>();

            dictionary.Add("test1", "test1");

            Assert.AreEqual("test1", dictionary.SearchExact("test1"));
        }
Пример #2
0
        public void TestStringTreeDictionaryAddSingle()
        {
            StringTreeDictionary<string> dictionary = new StringTreeDictionary<string>();

            dictionary.Add("test1", "test1");

            Assert.AreEqual("test1", dictionary.SearchExact("test1"));
        }
Пример #3
0
            internal void Add(short idx, string key, T value)
            {
                char ch = key[(int)idx];

                if ((int)ch < (int)this._split_char)
                {
                    if (this._lower_node == null)
                    {
                        this._lower_node = new StringTreeDictionary <T> .StringTreeNode(key[(int)idx]);

                        this._lower_node.Add(idx, key, value);
                    }
                    else
                    {
                        this._lower_node.Add(idx, key, value);
                    }
                }
                else if ((int)ch == (int)this._split_char)
                {
                    if ((int)idx < key.Length - 1)
                    {
                        if (this._equal_node == null)
                        {
                            this._equal_node = new StringTreeDictionary <T> .StringTreeNode(key[(int)idx + 1]);
                        }
                        this._equal_node.Add((short)((int)idx + 1), key, value);
                    }
                    else
                    {
                        this._value = value;
                    }
                }
                else if (this._higher_node == null)
                {
                    this._higher_node = new StringTreeDictionary <T> .StringTreeNode(key[(int)idx]);

                    this._higher_node.Add(idx, key, value);
                }
                else
                {
                    this._higher_node.Add(idx, key, value);
                }
            }
Пример #4
0
        public void TestStringTreeDictionaryRandom()
        {
            StringTreeDictionary<string> dictionary = new StringTreeDictionary<string>();

            HashSet<string> test_strings = new HashSet<string>();
            for (int i = 0; i < 1000; i++)
            {
                test_strings.Add(Utilities.RandomString(10));
            }

            foreach (string test_string in test_strings)
            {
                dictionary.Add(test_string, test_string);
            }

            foreach (string test_string in test_strings)
            {
                Assert.AreEqual(test_string, dictionary.SearchExact(test_string));
            }
        }
        public void TestStringTreeDictionaryRandomBig()
        {
            StringTreeDictionary <string> dictionary = new StringTreeDictionary <string>();

            HashSet <string> test_strings = new HashSet <string>();

            for (int i = 0; i < 100000; i++)
            {
                test_strings.Add(Utilities.RandomString(100));
            }

            foreach (string test_string in test_strings)
            {
                dictionary.Add(test_string, test_string);
            }

            foreach (string test_string in test_strings)
            {
                Assert.AreEqual(test_string, dictionary.SearchExact(test_string));
            }
        }
Пример #6
0
 public StringTreeDictionary()
 {
     this._root = new StringTreeDictionary <T> .StringTreeNode('㿿');
 }