From 0b4babe8c1e4f52eadbc131075021cdf25a0a448 Mon Sep 17 00:00:00 2001 From: Krishna Vedala <7001608+kvedala@users.noreply.github.com> Date: Thu, 27 Aug 2020 09:19:10 -0400 Subject: [PATCH] clang-tidy fixes --- data_structures/trie_tree.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/data_structures/trie_tree.cpp b/data_structures/trie_tree.cpp index 66105d752..9a4931c20 100644 --- a/data_structures/trie_tree.cpp +++ b/data_structures/trie_tree.cpp @@ -31,15 +31,18 @@ class trie { * @returns `tre` if found * @returns `false` if not found */ - bool search(std::shared_ptr root, const std::string& str, int index) { + bool search(const std::shared_ptr& root, const std::string& str, + int index) { if (index == str.length()) { - if (!root->isEndofWord) + if (!root->isEndofWord) { return false; + } return true; } int j = str[index] - 'a'; - if (!root->arr[j]) + if (!root->arr[j]) { return false; + } return search(root->arr[j], str, index + 1); } @@ -81,13 +84,15 @@ class trie { */ bool search(const std::string& str, int index) { if (index == str.length()) { - if (!isEndofWord) + if (!isEndofWord) { return false; + } return true; } int j = str[index] - 'a'; - if (!arr[j]) + if (!arr[j]) { return false; + } return search(arr[j], str, index + 1); } @@ -104,8 +109,9 @@ class trie { // std::shared_ptr root (nullptr); if (index == str.length()) { - if (!isEndofWord) + if (!isEndofWord) { return false; + } isEndofWord = false; // for (int i = 0; i < NUM_CHARS; i++) // if (root->arr[i]) @@ -113,18 +119,21 @@ class trie { return true; } int j = str[index] - 'a'; - if (!arr[j]) + if (!arr[j]) { return false; + } bool var = deleteString(str, index + 1); if (var) { arr[j].reset(); if (isEndofWord) { return false; } else { - int i; - for (i = 0; i < NUM_CHARS; i++) - if (arr[i]) + int i = 0; + for (i = 0; i < NUM_CHARS; i++) { + if (arr[i]) { return false; + } + } return true; } }