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

📄 wired-flows.cc

📁 对ns2软件进行UMTS扩展
💻 CC
字号:
/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- *//* By Pablo Martin and Paula Ballester, * Strathclyde University, Glasgow. * June, 2003.*//* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code and binary code must contain * the above copyright notice, this list of conditions and the following * disclaimer. * * 2. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed at Strathclyde University of * Glasgow, Scotland. * * 3. The name of the University may not be used to endorse or promote * products derived from this software without specific prior written * permission. * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software * is provided "as is" without express or implied warranty of any kind.*/#include "wired-flows.h"#include <iostream.h>SLList:: SLList(){ Head = new List;  Tail=Head;  CurrentPtr = Head;}SLList:: ~SLList(){ ListPtr temp = Head;  CurrentPtr = Head;  while(CurrentPtr != NULL)  {CurrentPtr = CurrentPtr->Next;   delete temp;   temp=CurrentPtr;  }} void SLList::AddANode(){Tail->Next = new List; Tail=Tail->Next;}void SLList::AddANode(int src, int flow, double rate, char* type){Tail->Next = new List; Tail=Tail->Next;Tail->src_ = src;Tail->flow_ = flow;Tail->rate_ = rate;if (strcmp(type, "audio") == 0) {	Tail->type_ = 0;}if (strcmp(type, "video") == 0) {	Tail->type_ = 1;}if (strcmp(type, "mail") == 0) {	Tail->type_ = 2;}if (strcmp(type, "fax") == 0) {	Tail->type_ = 3;}if (strcmp(type, "speech") == 0) {	Tail->type_ = 4;}if (strcmp(type, "ftp") == 0) {	Tail->type_ = 5;}if (strcmp(type, "http") == 0) {	Tail->type_ = 6;}return;} ListPtr SLList::Previous(ListPtr index){ListPtr temp=Head; if(index==Head) //special case, index IS the head :)  { return Head;  } while(temp->Next != index) { temp=temp->Next; } return temp;}/*void SLList::Advance(){ if(CurrentPtr->Next != NULL)  {  CurrentPtr=CurrentPtr->Next;  }}void SLList::Rewind(){ if(CurrentPtr != Head)  { CurrentPtr=Previous(CurrentPtr);  }}*/void SLList::DeleteANode(ListPtr corpse){ ListPtr temp;  if(corpse == Head) //case 1 corpse = Head   {temp=Head;    Head=Head->Next;    delete temp;   }  else if(corpse == Tail) //case 2 corpse is at the end  { temp=Previous(corpse);    temp->Next=NULL;    delete corpse;    Tail=temp;  }  else //case 3 corpse is in middle somewhere  {temp=Previous(corpse);   temp->Next=corpse->Next;   delete corpse;  }  CurrentPtr=Head; //Reset the class tempptr}void SLList::DeleteANode(int src, int flow){ ListPtr temp, corpse;  corpse = GetNode(src, flow);  if(corpse == Head) //case 1 corpse = Head   {temp=Head;    Head=Head->Next;    delete temp;   }  else if(corpse == Tail) //case 2 corpse is at the end  { temp=Previous(corpse);    temp->Next=NULL;    delete corpse;    Tail=temp;  }  else //case 3 corpse is in middle somewhere  {temp=Previous(corpse);   temp->Next=corpse->Next;   delete corpse;  }  CurrentPtr=Head; //Reset the class tempptr}double SLList::lookforrate(int src, int flow){ ListPtr t=Head;  while (t!=NULL){  	if ((t->src_==src) && (t->flow_==flow)){		return t->rate_;  	}  	t=t->Next;  }  return -1;}int SLList::lookfortype(int src, int flow){ ListPtr t=Head;  while (t!=NULL){	if ((t->src_==src) && (t->flow_==flow)){		return t->type_;  	}  	t=t->Next;  }  return (-1);}ListPtr SLList::GetNode(int src, int flow){ ListPtr t=Head;  while (t!=NULL){  	if ((t->src_==src) && (t->flow_==flow)){		return t;  	}  	t=t->Next;  }  return NULL;}

⌨️ 快捷键说明

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