Definition at line 35 of file main.cpp.
◆ Trie()
Definition at line 42 of file main.cpp.
43 {
45 for (char c = 'a'; c <= 'z'; ++c)
46 tree.push_back(make_unique<trie_node>(c));
47 }
vector< unique_ptr< trie_node > > tree
vector< bool > tree_beginnings
References tree.
◆ insert()
| void Trie::insert |
( |
string |
word | ) |
|
|
inline |
◆ search()
| bool Trie::search |
( |
string |
word | ) |
|
|
inline |
◆ startsWith()
| bool Trie::startsWith |
( |
string |
prefix | ) |
|
|
inline |
Definition at line 82 of file main.cpp.
83 {
84 if (prefix.empty())
85 return true;
87 if ((int)prefix.length() == 1)
89 for (int i = 1; i < (int)prefix.length(); ++i)
90 {
92 if (child == nullptr)
93 return false;
94 node = child;
95 }
96 return true;
97 }
References trie_node::find(), tree, and tree_beginnings.
◆ tree
◆ tree_beginnings
| vector<bool> Trie::tree_beginnings |
|
private |
The documentation for this class was generated from the following file: