Esempio n. 1
0
        public void Add(string word)
        {
            var charArray = word.ToLower().ToCharArray();

            //simple initialisation to ensure that the root is initialised
            if (_roots[charArray[0]] == null)
            {
                _roots[charArray[0]] = new TrieNodes(_radix);
            }

            var currentNode = _roots[charArray[0]];

            for (var i = 0; i < charArray.Length; i++)
            {
                if (currentNode.Nodes[charArray[i]] == null)
                {
                    currentNode.Nodes[charArray[i]] = new TrieNodes(_radix);
                }

                currentNode = currentNode.Nodes[charArray[i]];
            }

            currentNode.Value = word;
        }
Esempio n. 2
0
 public TrieNodes(int radix)
 {
     Nodes = new TrieNodes[radix];
 }