void HyphenationNode::insert (const char *pattern, const vector<char>& hp) {
   /* Is this the terminal node for that pattern? */
   if (! *pattern) {
      /* If we descended the tree all the way to the last letter, we can now
       * write the pattern into this node. */
      hyphenation_pattern.reset(new vector<char>(hp));
   } else {
      /* Check for an already present branch for that letter. */
      HyphenationNode *p = find(*pattern);
      if (!p) {
	 /* If there is none, create one. */
	 p = new HyphenationNode();
	 jump_table.insert(pair<char, HyphenationNode*>(*pattern, p));
      }
      /* Go to the next letter and descend. */
      p->insert(pattern+1, hp);
   }
}
示例#2
0
void HyphenationNode::insert (const char* key_string, 
                              auto_ptr<HyphenationRule> pattern) 
{
   /* Is this the terminal node for that pattern? */
   if (key_string[0] == 0) {
      /* If we descended the tree all the way to the last letter, we can now
       * write the pattern into this node. */

      hyphenation_pattern.reset(pattern.release());
   } else  {
      /* If not, however, we make sure that the branch for our letter exists
       * and descend. */
      char key = key_string[0];
      /* Ensure presence of a branch for that letter. */
      HyphenationNode *p = find(key);
      if (!p) {
	 p = new HyphenationNode();
	 jump_table.insert(pair<char, HyphenationNode*>(key, p));
      }
      /* Go to the next letter and descend. */
      p->insert(key_string+1, pattern);
   }
}