diff --git a/sequential/linkedlist.hpp b/src/sequential/linkedlist.hpp similarity index 100% rename from sequential/linkedlist.hpp rename to src/sequential/linkedlist.hpp diff --git a/sequential/ringbuffer.hpp b/src/sequential/ringbuffer.hpp similarity index 100% rename from sequential/ringbuffer.hpp rename to src/sequential/ringbuffer.hpp diff --git a/sequential/stack.hpp b/src/sequential/stack.hpp similarity index 100% rename from sequential/stack.hpp rename to src/sequential/stack.hpp diff --git a/sequential/vector.hpp b/src/sequential/vector.hpp similarity index 100% rename from sequential/vector.hpp rename to src/sequential/vector.hpp diff --git a/tree/binarytree.hpp b/src/tree/binarytree.hpp similarity index 87% rename from tree/binarytree.hpp rename to src/tree/binarytree.hpp index 42833cc..f6dbbca 100644 --- a/tree/binarytree.hpp +++ b/src/tree/binarytree.hpp @@ -43,17 +43,17 @@ private: void DeleteNode(std::unique_ptr> & node) { - if(node == nullptr || node->IsLeaf()) + if(node || node->IsLeaf()) { node.release(); } - if(node->left == nullptr) + if(node->left) { node = std::move(node->right); } - if(node->right == nullptr) + if(node->right) { node = std::move(node->left); } @@ -69,7 +69,7 @@ private: std::unique_ptr> & FindNode(T const & value) { std::unique_ptr> *currentPtr = &root; - while (*currentPtr != nullptr && (*currentPtr)->value != value) + while (*currentPtr && (*currentPtr)->value != value) { if ((*currentPtr)->value > value) { @@ -88,7 +88,7 @@ public: void Insert(T const & value) { std::unique_ptr> *currentPtr = &root; - while ((*currentPtr) != nullptr) + while (*currentPtr) { if ((*currentPtr)->value > value) { @@ -105,7 +105,7 @@ public: void InsertNoDuplicates(T const & value) { auto & toInsertIn = FindNode(value); - if(toInsertIn != nullptr) + if(toInsertIn) { return; } @@ -115,13 +115,13 @@ public: bool Contains(T const & value) { - return FindNode(value) != nullptr; + return static_cast(FindNode(value)); } void Delete(T const & value) { auto & node = FindNode(value); - if (node == nullptr) + if (node) { return; }