mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
clang-tidy fixes
This commit is contained in:
parent
e19260c869
commit
0b4babe8c1
@ -31,15 +31,18 @@ class trie {
|
|||||||
* @returns `tre` if found
|
* @returns `tre` if found
|
||||||
* @returns `false` if not found
|
* @returns `false` if not found
|
||||||
*/
|
*/
|
||||||
bool search(std::shared_ptr<trie> root, const std::string& str, int index) {
|
bool search(const std::shared_ptr<trie>& root, const std::string& str,
|
||||||
|
int index) {
|
||||||
if (index == str.length()) {
|
if (index == str.length()) {
|
||||||
if (!root->isEndofWord)
|
if (!root->isEndofWord) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int j = str[index] - 'a';
|
int j = str[index] - 'a';
|
||||||
if (!root->arr[j])
|
if (!root->arr[j]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return search(root->arr[j], str, index + 1);
|
return search(root->arr[j], str, index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,13 +84,15 @@ class trie {
|
|||||||
*/
|
*/
|
||||||
bool search(const std::string& str, int index) {
|
bool search(const std::string& str, int index) {
|
||||||
if (index == str.length()) {
|
if (index == str.length()) {
|
||||||
if (!isEndofWord)
|
if (!isEndofWord) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int j = str[index] - 'a';
|
int j = str[index] - 'a';
|
||||||
if (!arr[j])
|
if (!arr[j]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return search(arr[j], str, index + 1);
|
return search(arr[j], str, index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +109,9 @@ class trie {
|
|||||||
// std::shared_ptr<trie> root (nullptr);
|
// std::shared_ptr<trie> root (nullptr);
|
||||||
|
|
||||||
if (index == str.length()) {
|
if (index == str.length()) {
|
||||||
if (!isEndofWord)
|
if (!isEndofWord) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
isEndofWord = false;
|
isEndofWord = false;
|
||||||
// for (int i = 0; i < NUM_CHARS; i++)
|
// for (int i = 0; i < NUM_CHARS; i++)
|
||||||
// if (root->arr[i])
|
// if (root->arr[i])
|
||||||
@ -113,18 +119,21 @@ class trie {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int j = str[index] - 'a';
|
int j = str[index] - 'a';
|
||||||
if (!arr[j])
|
if (!arr[j]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
bool var = deleteString(str, index + 1);
|
bool var = deleteString(str, index + 1);
|
||||||
if (var) {
|
if (var) {
|
||||||
arr[j].reset();
|
arr[j].reset();
|
||||||
if (isEndofWord) {
|
if (isEndofWord) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i = 0;
|
||||||
for (i = 0; i < NUM_CHARS; i++)
|
for (i = 0; i < NUM_CHARS; i++) {
|
||||||
if (arr[i])
|
if (arr[i]) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user