diff --git a/src/routing/static-route-manager.cc b/src/routing/static-route-manager.cc index aab5bd88f..4a4739c4d 100644 --- a/src/routing/static-route-manager.cc +++ b/src/routing/static-route-manager.cc @@ -49,7 +49,6 @@ SPFVertex::Initialize () // XXX previous = 0 } - StaticRouteManagerLSDB::~StaticRouteManagerLSDB() { NS_DEBUG("StaticRouteManagerLSDB::~StaticRouteManagerLSDB ()"); @@ -401,6 +400,28 @@ StaticRouteManagerTest::RunTests (void) { bool ok = true; + SPFVertexPriorityQueue candidate; // <---------------- + + for (int i = 0; i < 100; ++i) + { + SPFVertex *v = new SPFVertex; + v->m_distanceFromRoot = rand () % 100; + candidate.push (v); // <---------------- + } + + uint32_t lastDistance = 0; + + for (int i = 0; i < 100; ++i) + { + SPFVertex *v = candidate.top (); // <---------------- + candidate.pop (); // <---------------- + if (v->m_distanceFromRoot < lastDistance) + { + ok = false; + } + lastDistance = v->m_distanceFromRoot; + } + // Build fake link state database; four routers (0-3), 3 point-to-point // links // diff --git a/src/routing/static-route-manager.h b/src/routing/static-route-manager.h index 0ab536350..81669804f 100644 --- a/src/routing/static-route-manager.h +++ b/src/routing/static-route-manager.h @@ -18,6 +18,7 @@ #include #include +#include #include #include "ns3/object.h" #include "ns3/ptr.h" @@ -58,8 +59,20 @@ public: uint32_t m_distanceFromRoot; bool m_stat; // true if LSA is in SPF tree already + + struct Greater : public std::binary_function< SPFVertex*, SPFVertex*, bool> + { + bool operator()(const SPFVertex *v1, const SPFVertex *v2) const + { + return v1->m_distanceFromRoot > v2->m_distanceFromRoot; + } + }; }; +typedef std::vector SPFVector_t; +typedef std::priority_queue + SPFVertexPriorityQueue; + /** * \brief The Link State DataBase (LSDB) of a static router */