rm.Trie.TrieNode.SetChild C# (CSharp) Method

SetChild() private method

private SetChild ( TrieNode child ) : void
child TrieNode
return void
        internal void SetChild(TrieNode child)
        {
            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }
            Children[child.Character] = child;
        }

Usage Example

Example #1
0
 /// <summary>
 /// Adds words recursively.
 /// <para>
 /// Gets the first char of the word, creates the child TrieNode if null,
 /// and recurses with the first char removed from the word. If the word
 /// length is 0, return.
 /// </para>
 /// </summary>
 private void AddWord(TrieNode trieNode, char[] word)
 {
     foreach (var c in word)
     {
         var child = trieNode.GetChild(c);
         if (child == null)
         {
             child = new TrieNode(c);
             trieNode.SetChild(child);
         }
         trieNode = child;
     }
     trieNode.WordCount++;
 }
All Usage Examples Of rm.Trie.TrieNode::SetChild