Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Out_List Class Reference

#include <iflist.h>

Inheritance diagram for Out_List:

Inheritance graph
[legend]
Collaboration diagram for Out_List:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Out_List ()
Out_ListWhereToGo ()
void CalRange ()
void NormalizeGradient ()
void InsertFront (Agent_List **, Agent_List *)
void Remove (Agent_List **, Agent_List *)
PrvCurPtr Find (Agent_List **, ns_addr_t)
void FreeAll (Agent_List **)
void Union (Agent_List **, Agent_List *)
virtual void print ()

Public Attributes

float gradient
double timeout
double from
double to
int num_data_send
int num_neg_recv
int num_pos_recv
int rank
bool is_sink
ns_addr_t agent_addr
Agent_Listnext

Constructor & Destructor Documentation

Out_List::Out_List  )  [inline]
 

Definition at line 133 of file iflist.h.

References from, gradient, num_data_send, num_neg_recv, num_pos_recv, timeout, and to.

00133              : From_List() { gradient = 0; from=0.0; to=0.0; num_data_send=0; 
00134                              timeout = 0.0; num_neg_recv = 0; num_pos_recv=0;}


Member Function Documentation

void Out_List::CalRange  ) 
 

Definition at line 151 of file iflist.cc.

References FROM_SLOT, GRADIENT, OUT_NEXT, and TO_SLOT.

00152 {
00153   Out_List *cur_out=this;
00154   double cur_slot=0.0;
00155 
00156   for (cur_out = this; cur_out != NULL; cur_out = OUT_NEXT(cur_out) ) {
00157 
00158     if ( GRADIENT(cur_out) <= 0.0 ) {
00159       FROM_SLOT(cur_out) = -1.0;
00160       TO_SLOT(cur_out) = -1.0;
00161       continue;
00162     }
00163 
00164     FROM_SLOT(cur_out) = cur_slot;
00165     cur_slot = cur_slot + GRADIENT(cur_out);
00166     TO_SLOT(cur_out) = cur_slot;
00167   }   
00168 
00169   return;
00170 }

PrvCurPtr Agent_List::Find Agent_List **  ,
ns_addr_t 
[inherited]
 

Definition at line 70 of file iflist.cc.

References ns_addr_t::addr_, PrvCurPtr::cur, Agent_List::next, NODE_ADDR, PORT, ns_addr_t::port_, and PrvCurPtr::prv.

Referenced by Agent_List::Union().

00071 {
00072   PrvCurPtr RetVal;
00073   Agent_List **prv, *cur;
00074 
00075   for (prv= start, cur=*start; cur != NULL; prv= &(cur->next), cur=cur->next) {
00076     if ( NODE_ADDR(cur) == addr.addr_ && PORT(cur)==addr.port_) 
00077       break;
00078   }
00079  
00080   RetVal.prv = prv;
00081   RetVal.cur = cur;
00082 
00083   return RetVal;
00084 }

void Agent_List::FreeAll Agent_List **   )  [inherited]
 

Definition at line 56 of file iflist.cc.

References Agent_List::next.

00057 {
00058   Agent_List *temp;
00059   Agent_List *next;
00060 
00061   for (temp = *prev; temp != NULL; temp=next) {
00062     next = temp->next;
00063     delete temp;
00064   }
00065 
00066   *prev = NULL;
00067 }

void Agent_List::InsertFront Agent_List **  ,
Agent_List
[inherited]
 

Definition at line 37 of file iflist.cc.

References Agent_List::next.

Referenced by Agent_List::Union().

00038 {
00039   if (cur == NULL)
00040      return;
00041 
00042   cur->next = *start;
00043   *start = cur;
00044 }

void Out_List::NormalizeGradient  ) 
 

Definition at line 173 of file iflist.cc.

References GRADIENT, and OUT_NEXT.

00174 {
00175   Out_List *cur;
00176   float sum=0.0;
00177   int   num=0; 
00178 
00179   for (cur=this; cur!=NULL; cur=OUT_NEXT(cur)) {
00180     sum = sum + GRADIENT(cur);
00181     num++;
00182   }
00183 
00184   if (num == 0) return;
00185 
00186   if (sum == 0.0) {
00187     float share= 1.0/num;
00188 
00189     for (cur=this; cur != NULL; cur = OUT_NEXT(cur)) {
00190       GRADIENT(cur) = share;
00191     }
00192     
00193     return;
00194   }
00195 
00196   for (cur=this; cur != NULL; cur = OUT_NEXT(cur)) {
00197     GRADIENT(cur) = GRADIENT(cur)/sum;
00198   }
00199 }

void Agent_List::print  )  [virtual, inherited]
 

Definition at line 104 of file iflist.cc.

References ns_addr_t::addr_, Agent_List::agent_addr, Agent_List::next, and ns_addr_t::port_.

00105 {
00106   Agent_List *cur;
00107 
00108   for (cur=this; cur!=NULL; cur=cur->next) {
00109     printf("(%d,%d)\n", cur->agent_addr.addr_, cur->agent_addr.port_);
00110   }
00111 }

void Agent_List::Remove Agent_List **  ,
Agent_List
[inherited]
 

Definition at line 47 of file iflist.cc.

References Agent_List::next.

00048 {
00049   if (cur == NULL)
00050     return;
00051 
00052   *prev = cur->next;  
00053 }

void Agent_List::Union Agent_List **  ,
Agent_List
[inherited]
 

Definition at line 89 of file iflist.cc.

References AGENT_NEXT, AGT_ADDR, PrvCurPtr::cur, Agent_List::Find(), and Agent_List::InsertFront().

00090 {
00091   PrvCurPtr RetVal;
00092   Agent_List *dupAgent;
00093   
00094   for (Agent_List *cur=list1; cur != NULL; cur=AGENT_NEXT(cur)) {
00095     RetVal = Find(result, AGT_ADDR(cur));
00096     if (RetVal.cur == NULL) {
00097       dupAgent = new Agent_List;
00098       *dupAgent = *cur;
00099       InsertFront(result, dupAgent);
00100     }
00101   }
00102 }

Here is the call graph for this function:

Out_List * Out_List::WhereToGo  ) 
 

Definition at line 134 of file iflist.cc.

References FROM_SLOT, OUT_NEXT, TO_SLOT, and Random::uniform().

00135 {
00136   Out_List *cur_out;
00137   double slot = Random::uniform();
00138 
00139   for (cur_out = this; cur_out!=NULL; cur_out = OUT_NEXT(cur_out) ) {
00140     if (slot >= FROM_SLOT(cur_out) && slot < TO_SLOT(cur_out) )
00141       return cur_out;
00142   }
00143 
00144   if (cur_out == NULL && this != NULL)
00145     printf("Something must be wrong! \n");
00146 
00147   return cur_out;
00148 }

Here is the call graph for this function:


Member Data Documentation

ns_addr_t Agent_List::agent_addr [inherited]
 

Definition at line 95 of file iflist.h.

Referenced by Agent_List::Agent_List(), and Agent_List::print().

double Out_List::from
 

Definition at line 127 of file iflist.h.

Referenced by Out_List().

float Out_List::gradient
 

Definition at line 125 of file iflist.h.

Referenced by DiffusionProb::CalGradient(), Out_List(), and DiffusionProb::Print_IOlist().

bool From_List::is_sink [inherited]
 

Definition at line 117 of file iflist.h.

Referenced by DiffusionProb::add_outlist(), DiffusionProb::consider_new(), DiffusionProb::consider_old(), and From_List::From_List().

Agent_List* Agent_List::next [inherited]
 

Definition at line 96 of file iflist.h.

Referenced by Agent_List::Agent_List(), DiffusionRate::consider_new(), DiffusionProb::consider_new(), DiffusionProb::consider_old(), OmniMcastAgent::ConsiderNew(), FloodingAgent::ConsiderNew(), Agent_List::Find(), Agent_List::FreeAll(), DiffusionRate::GradientTimeOut(), Agent_List::InsertFront(), Agent_List::print(), and Agent_List::Remove().

int Out_List::num_data_send
 

Definition at line 129 of file iflist.h.

Referenced by DiffusionProb::ForwardData(), DiffusionRate::FwdOriginal(), Out_List(), and DiffusionProb::Print_IOlist().

int Out_List::num_neg_recv
 

Definition at line 130 of file iflist.h.

Referenced by Out_List().

int Out_List::num_pos_recv
 

Definition at line 131 of file iflist.h.

Referenced by Out_List().

int From_List::rank [inherited]
 

Definition at line 116 of file iflist.h.

Referenced by DiffusionProb::add_outlist(), DiffusionProb::CalGradient(), DiffusionProb::consider_new(), DiffusionProb::consider_old(), and From_List::From_List().

double Out_List::timeout
 

Definition at line 126 of file iflist.h.

Referenced by Out_List().

double Out_List::to
 

Definition at line 128 of file iflist.h.

Referenced by Out_List().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:06:36 2004 for NS2.26SourcesOriginal by doxygen 1.3.3