Exemplo n.º 1
0
 public void OptimizeSparseNodes()
 {
     if (_root.ShouldOptimize)
     {
         _root = new SparseTrieNode(_root.CharNodePairs());
         c_sparse_nodes++;
     }
     _root.OptimizeChildNodes();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Note: doesn't de-optimize optimized nodes if re-run later
 /// </summary>
 public void OptimizeChildNodes()
 {
     if (Nodes != null)
     {
         foreach (var q in CharNodePairs())
         {
             TrieNodeBase n_old = q.Value;
             if (n_old.ShouldOptimize)
             {
                 TrieNodeBase n_new = new SparseTrieNode(n_old.CharNodePairs());
                 n_new.m_value = n_old.m_value;
                 Trie <TValue> .c_sparse_nodes++;
                 ReplaceChild(q.Key, n_new);
             }
             n_old.OptimizeChildNodes();
         }
     }
 }