Пример #1
0
void Trie::Insert(char x[]) {
  TrieNode *current = root;
  int i = 0;
  while ( x[i] != '\0' )
   { int j = x[i] - 'a';
     if ( current->GetPtr(j) == 0 )
              current->SetPtr(j, new TrieNode());
     current = current->GetPtr(j);
     i = i + 1;
   }
  current->SetStrEnds();
}
Пример #2
0
int Trie::Count(){
	int counter = 0;
	for(int i=0;i<TrieMaxElem;i++)
		counter = counter + Count(root->GetPtr(i), i, false, 1);
	return counter;
}