All pastes #216675 Raw Edit

Untitled

public text v1 · immutable
#216675 ·published 2006-10-23 07:28 UTC
rendered paste body
const Trie *
Trie::FindWord(const string newword) {
  map<char, Trie *>::iterator childit;
  Trie * child;

  if (newword.size() < 1) {
    if (fullword)
      return this;
    else
      return NULL;
  }

  char first = newword.substr(0,1).c_str()[0];
  childit = children.find(first);

  if ( childit == children.end())
    return NULL;

  string rest = newword.substr(1);
  child = (*childit).second;
  return child->FindWord(rest);
}