本文整理汇总了C++中TNode::end_of_word方法的典型用法代码示例。如果您正苦于以下问题:C++ TNode::end_of_word方法的具体用法?C++ TNode::end_of_word怎么用?C++ TNode::end_of_word使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNode
的用法示例。
在下文中一共展示了TNode::end_of_word方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: search
int Trie::search(char word[]) {
int len = strlen(word);
TNode* current = root;
int i = 0;
while (current != NULL && i < len)
current = current->exist_child(tolower(word[i++]));
return (current != NULL && current->end_of_word());
}
示例2: print_words_recursive
void Trie::print_words_recursive(TNode* root, char word[], int len) {
TNode* child = root->get_first_child();
while (child != NULL) {
word[len] = child->get_node_value();
// if this is a valid word, print it out
if (child->end_of_word())
print_array(word,len+1);
print_words_recursive(child,word,len+1);
child = child->get_next();
}
}
示例3: insert
int Trie::insert(char word[]) {
int len = strlen(word);
TNode* current = root;
int i = 0; char c;
// processing each character
while (i < len) {
c = word[i++];
if (current->exist_child(c) == NULL)
num_nodes++;
current = current->get_child_node(tolower(c));
}
if (!current->end_of_word()) {
num_words++;
current->set_end_of_word(true);
}
}