clang-tidy fixes

This commit is contained in:
Krishna Vedala 2020-08-27 09:19:10 -04:00
parent e19260c869
commit 0b4babe8c1
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -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;
} }
} }