⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 additional.c

📁 一个linux下的各种组播路由算法编程
💻 C
字号:
NodeListEntry *TheNodeList::findNode(double x, double y) {

      // search the node list for the node whose approximate is location
      // is within five pixels from the given location

   NodeListEntry* tmp1;
   short found = 0;

   tmp1 = nodeListHd;
   while ((tmp1 != NULL) && (found == 0)) {
      if ((tmp1->nodePtr()->X() > (x - 3. / SIDE))    // +|-3 due to
                                                      // inaccuracies in the GUI
       && (tmp1->nodePtr()->X() < (x + 3. / SIDE))) {
          if ((tmp1->nodePtr()->Y() > (y - 3. / SIDE))
           && (tmp1->nodePtr()->Y() < (y + 3. / SIDE))) found = 1;
          else tmp1 = tmp1->next();
      }
      else tmp1 = tmp1->next();
   }; 
   return(tmp1); //tmp1 = NULL if not found
};

void TheNodeList::refresh(graphics gr) {

                 //refreshes the drawing area using the manager's
                 // lists 
   NodeListEntry *tmp1;
   AdjacencyListEntry *tmp2;
   
   gr.clearScreen();
   tmp1 = nodeListHd;
   while (tmp1 != NULL) { 
       gr.drawNode(tmp1->nodePtr(), dnn);
       tmp2 = tmp1->nodePtr()->adjacentNodes();
       while (tmp2 != NULL) {
            if (tmp1->nodePtr()->name() < tmp2->nodePtr()->name()) {
               AdjacencyListEntry *tmp5 = tmp2->nodePtr()->adjacentNodes();
               int found = False;
               while (found == False) {
                  if (tmp5->nodePtr() == tmp1->nodePtr()) found = True;
                  else tmp5 = tmp5->next();
               };
               if (dlc == True) {
                 if (fn == PEAK)
                   gr.drawLink(tmp1->nodePtr(), tmp2->nodePtr(), tmp2->peak(),
                                                             tmp5->peak());
                 else  gr.drawLink(tmp1->nodePtr(), tmp2->nodePtr(), 
                                 tmp2->average(), tmp5->average());
               }
               else gr.drawLink(tmp1->nodePtr(), tmp2->nodePtr());
            };
            tmp2 = tmp2->next();
       };
       tmp1 = tmp1->next(); 
   };

   MCGroup *tmp3 = groupsHd;
   while ((tmp3 != NULL) && (tmp3->address() != dg)) tmp3 = tmp3->next();

   if (tmp3 != NULL) {
       tmp1 = tmp3->headm();
       while (tmp1 != NULL) {
            gr.drawDestination(tmp1->nodePtr());
            tmp1 = tmp1->next();
       };
   };
 
   //Draw Multicast Sources Only

   tmp1 = nodeListHd;
   while (tmp1 != NULL) {
      SourceList *s = tmp1->nodePtr()->sourceList();
      int j = 0;
      while (s != NULL) {
         if ((s->source()->type() == Realtime) && 
             (s->source()->address() == dg)) {
              j++;
              gr.drawSource(tmp1->nodePtr(), j);
 
             //Draw the routing tree
             if (s->source()->nodePtr()->name() == dt) {
                NodeListEntry *tmp5 = nodeListHd;
                while (tmp5 != NULL) {
                  RoutingTableEntry *rout = tmp5->nodePtr()->routingTable();
                  while (rout != NULL) {
                     if ((rout->address() == dg) && 
                         (rout->source() == s->source()->nodePtr())) {
                         NodeListEntry *tmp4 = rout->children();
                         while (tmp4 != NULL) {
                             gr.drawPath(tmp5->nodePtr(), tmp4->nodePtr());
                             tmp4 = tmp4->next();
                         };
                     };
                     rout = rout->next();
                  };
                  tmp5 = tmp5->next();
                };
            };
         };         
         s = s->next();
      };
      tmp1 = tmp1->next();
   };
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -