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

#include <leetcode.h>

Public 成员函数

 TrieNode ()
 
 TrieNode (char ch)
 
string get_prefix (string root, const string &str) const
 
void insert (const string &str)
 

Public 属性

char ch
 
bool endroot
 
TrieNodenext [26] = {}
 

详细描述

在文件 leetcode.h565 行定义.

构造及析构函数说明

◆ TrieNode() [1/2]

leetcode::UhWRSj::TrieNode::TrieNode ( )
inline

在文件 leetcode.h570 行定义.

571 : ch(0), endroot(false){};

被这些函数引用 insert().

◆ TrieNode() [2/2]

leetcode::UhWRSj::TrieNode::TrieNode ( char  ch)
inlineexplicit

在文件 leetcode.h573 行定义.

574 : ch(ch), endroot(false){};

成员函数说明

◆ get_prefix()

string TrieNode::get_prefix ( string  root,
const string &  str 
) const

在文件 leetcode.cpp1293 行定义.

1293 {
1294 if(this->endroot || str.empty()) {
1295 return root;
1296 }
1297 if(this->next[str[0] - 'a'] == nullptr) {
1298 return root + str;
1299 }
1300 return this->next[str[0] - 'a']->get_prefix(root + str[0], str.substr(1));
1301 }
vector< int > root
Definition: acwing408.cpp:349
TrieNode * next[26]
Definition: leetcode.h:567
string get_prefix(string root, const string &str) const
Definition: leetcode.cpp:1293

引用了 endroot, get_prefix(), next , 以及 acwing::acwing836_408::root.

被这些函数引用 get_prefix().

◆ insert()

void TrieNode::insert ( const string &  str)

在文件 leetcode.cpp1282 行定义.

1282 {
1283 if(str.empty()) {
1284 this->endroot = true;
1285 return;
1286 }
1287 if(this->next[str[0] - 'a'] == nullptr) {
1288 this->next[str[0] - 'a'] = new TrieNode(str[0]);
1289 }
1290 this->next[str[0] - 'a']->insert(str.substr(1));
1291 }
void insert(const string &str)
Definition: leetcode.cpp:1282

引用了 TrieNode(), endroot, insert() , 以及 next.

被这些函数引用 insert().

类成员变量说明

◆ ch

char leetcode::UhWRSj::TrieNode::ch

在文件 leetcode.h566 行定义.

◆ endroot

bool leetcode::UhWRSj::TrieNode::endroot

在文件 leetcode.h568 行定义.

被这些函数引用 get_prefix() , 以及 insert().

◆ next

TrieNode* leetcode::UhWRSj::TrieNode::next[26] = {}

在文件 leetcode.h567 行定义.

被这些函数引用 get_prefix() , 以及 insert().


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