problemscpp
A collection of my answers to algorithm problems in c++.
Public 成员函数 | Public 属性 | 所有成员列表
TrieNode结构体 参考

字典树节点 更多...

#include <templates.h>

Public 成员函数

 TrieNode (char ch)
 
 ~TrieNode ()
 
void insert (const string &str)
 

Public 属性

char ch
 
unsigned count = 0
 
bool end_of_word = false
 
array< TrieNode *, 26 > nexts = {}
 

详细描述

字典树节点

在文件 templates.h9 行定义.

构造及析构函数说明

◆ TrieNode()

TrieNode::TrieNode ( char  ch)
inlineexplicit

在文件 templates.h15 行定义.

16 : ch(ch) {}
char ch
Definition: templates.h:10

被这些函数引用 insert().

◆ ~TrieNode()

TrieNode::~TrieNode ( )

在文件 templates.cpp21 行定义.

21 {
22 for(const auto *next: this->nexts) {
23 delete next;
24 }
25}
array< TrieNode *, 26 > nexts
Definition: templates.h:11

引用了 nexts.

成员函数说明

◆ insert()

void TrieNode::insert ( const string &  str)

在文件 templates.cpp9 行定义.

9 {
10 if(this->nexts[str[0] - 'a'] == nullptr) {
11 this->nexts[str[0] - 'a'] = new TrieNode(str[0]);
12 }
13 if(str.length() == 1) {
14 this->nexts[str[0] - 'a']->end_of_word = true;
15 this->nexts[str[0] - 'a']->count++;
16 } else {
17 this->nexts[str[0] - 'a']->insert(str.substr(1));
18 }
19}
TrieNode(char ch)
Definition: templates.h:15

引用了 TrieNode() , 以及 nexts.

被这些函数引用 leetcode::word_break::Solution::wordBreak().

类成员变量说明

◆ ch

char TrieNode::ch

在文件 templates.h10 行定义.

◆ count

unsigned TrieNode::count = 0

在文件 templates.h13 行定义.

◆ end_of_word

bool TrieNode::end_of_word = false

在文件 templates.h12 行定义.

被这些函数引用 leetcode::word_break::Solution::search().

◆ nexts

array<TrieNode *, 26> TrieNode::nexts = {}

该结构体的文档由以下文件生成: