Name prefix table entries keep pointers instead of keeping a copy of the object for routing table entries.
refs: #2863
Change-Id: I3271c9f96dfc8721a0ca7c900542c6ddb0b321ac
diff --git a/src/route/nexthop-list.cpp b/src/route/nexthop-list.cpp
index 22046fd..c5010ec 100644
--- a/src/route/nexthop-list.cpp
+++ b/src/route/nexthop-list.cpp
@@ -43,6 +43,39 @@
nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) ;
}
+bool
+operator==(const NexthopList& lhs, const NexthopList& rhs)
+{
+ if (lhs.getSize() != rhs.getSize()) {
+ return false;
+ }
+
+ NexthopList slhs = lhs;
+ NexthopList srhs = rhs;
+
+ for (struct {std::set<NextHop>::iterator lItr;
+ std::set<NextHop>::iterator rItr;} pair = {slhs.begin(), srhs.begin()};
+ (pair.lItr != slhs.end() || pair.rItr != srhs.end());
+ pair.rItr++, pair.lItr++) {
+ if (!((*pair.lItr) == (*pair.rItr))) {
+ return false;
+ }
+ }
+ return true;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const NexthopList& nhl)
+{
+ NexthopList& ucnhl = const_cast<NexthopList&>(nhl);
+ os << "NexthopList(\nNext hops: ";
+ for (auto&& nh : ucnhl.getNextHops()) {
+ os << nh;
+ }
+ os << ")";
+ return os;
+}
+
void
NexthopList::addNextHop(const NextHop& nh)
{