Skip to content

Commit

Permalink
Add nullptr guard-check in comparision of shared ptr node and edge (#436
Browse files Browse the repository at this point in the history
)

* Add nullptr guard-check in comparision of shared ptr node and edge

* Ran through git clang-format HEAD
  • Loading branch information
badumbatish authored Jun 20, 2024
1 parent d0ed187 commit 24f5c79
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/CXXGraph/Utility/PointerHash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,23 @@ struct edgeHash {

template <typename T>
bool operator==(shared<const Node<T>> p1, shared<const Node<T>> p2) {
if (p1 == nullptr && p2 == nullptr) return true;
if (p1 == nullptr || p2 == nullptr) return false;
return p1->getUserId() == p2->getUserId();
}

template <typename T>
bool operator==(shared<Node<T>> p1, shared<Node<T>> p2) {
if (p1 == nullptr && p2 == nullptr) return true;
if (p1 == nullptr || p2 == nullptr) return false;
return p1->getUserId() == p2->getUserId();
}

template <typename T>
bool operator==(shared<const Edge<T>> p1, shared<const Edge<T>> p2) {
if (p1 == nullptr && p2 == nullptr) return true;
if (p1 == nullptr || p2 == nullptr) return false;

return p1->getNodePair().first->getUserId() ==
p2->getNodePair().first->getUserId() &&
p1->getNodePair().second->getUserId() ==
Expand Down

0 comments on commit 24f5c79

Please sign in to comment.