当前位置: 首页>>代码示例>>C++>>正文


C++ Dictionary::Count方法代码示例

本文整理汇总了C++中Dictionary::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ Dictionary::Count方法的具体用法?C++ Dictionary::Count怎么用?C++ Dictionary::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary::Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Write

void Write(Dictionary<TK, TV> const &a) {
    Write("Count = ");
    var len = a.Count();
    Write(len);
    WriteChar(NewLine);
    if (len) {
        var p = a.UsedNodeHead();
Lab1:
        Write(p->Key);
        Write(", ");
        Write(p->Value);
        WriteChar(NewLine);
        if ((p = p->UsedNext))
            goto Lab1;
    }
}
开发者ID:chenweihua,项目名称:69net,代码行数:16,代码来源:Console.hpp

示例2: SimulationRun

void SimulationRun(string RunParameterNames[])
{
	ifstream TraceFile;
	bool RunValid=true;
	if(PrimaryProtocol==NULL)
	{
		cerr<<"RUN ERROR: No protocol specified!"<<endl;
		RunValid=false;
	}
	if(TraceFileName=="")
	{
		cerr<<"RUN ERROR: No trace file specified!"<<endl;
		RunValid=false;
	}
	if(RunValid)
	{
		TraceFile.open(TraceFileName.c_str());
		if(!TraceFile.is_open())
		{
			cerr<<"RUN ERROR: Cannot open trace file!"<<endl;
			RunValid=false;
		}
		else if(TraceFile.bad()||TraceFile.fail())
		{
			cerr<<"RUN ERROR: Stream was corrupted!"<<endl;
			RunValid=false;
		}
	}
	if(!RunValid){return;}//Immediately break and cancel the run if there are execution errors.
	ResetGlobalVariables();
	int VehicleNum,BeginTime,EndTime;
	float x,y;
	int NextSimulationTime;
	int VehicleNumMask=1;//The modulo of the vehicle num and this value determines whether a vehicle is omitted to get a different set of vehicles in the simulation.
	int VehicleNumMaskOffset=0;
	bool MaskExists=CheckRunVariableExists("VehicleNumMask");
	bool OffsetExists=CheckRunVariableExists("VehicleNumMaskOffset");
	if(MaskExists!=OffsetExists){cerr<<"ERROR: Must specify both VehicleNumMask and VehicleNumMaskOffset for this input to be effective!"<<endl;}
	else if(MaskExists)
	{
		VehicleNumMask=GetRunVariableInteger("VehicleNumMask");
		VehicleNumMaskOffset=GetRunVariableInteger("VehicleNumMaskOffset");
	}
	while (TraceFile >> NextSimulationTime >> VehicleNum >> x >> y >> BeginTime >> EndTime)// loop through all input
	{
		TimeMax=max(NextSimulationTime+1,TimeMax);
		if((--VehicleNum)%VehicleNumMask==VehicleNumMaskOffset)
		{
			VehicleNum/=VehicleNumMask;
			VehicleMax=max(VehicleNum+1,VehicleMax);
			for(int i=Vehicles.Count();i<VehicleMax;i++){Vehicles.PushObj(new Vehicle("OBU#"+to_string((long long int)i)));}
			Vehicle* CurrentVehicle=Vehicles[VehicleNum];
			if(CurrentVehicle->v_begin_t==-1)
			{
				CurrentVehicle->v_begin_t=BeginTime;
				CurrentVehicle->v_begin_x=x;
				CurrentVehicle->v_begin_x=y;
				CurrentVehicle->v_end_t=EndTime;
			}
		}
	}
	OutputVariables.Set("VehicleMax",to_string((long long int)VehicleMax));
	OutputVariables.Set("TimeMax",to_string((long long int)TimeMax));
	OutputVariables.Set("TraceFile",TraceFileName);
	OutputVariables.Set("ProtocolName",ProtocolName);
	
	TraceFile.clear();
	TraceFile.seekg(0, TraceFile.beg);  // reposition to beginning of input file
	if(TraceFile.bad()||TraceFile.fail())
	{
		cerr<<"RUN ERROR: Could not reset stream!"<<endl;
		RunValid=false;
	}
	
	int PeakAnonymitySetSize=0;//Used to calculate one of our metrics later.
	float PeakAnonymityDistance=0;
	if(CheckRunVariableExists("GlobalMessageLimit")){NetworkObject::GlobalMessageLimit=GetRunVariableInteger("GlobalMessageLimit");}
	SetGlobalVehicleMaxMessagePerTick(CheckRunVariableExists("VehicleMessageLimit")?GetRunVariableInteger("VehicleMessageLimit"):0);
	time_t SimulationBeginTime=time(NULL);
	RunValid=RunValid&&PrimaryProtocol->SimulationBegin();
	bool TraceFileEOF=false;
	while(!TraceFileEOF)
	{
		TraceFile>>NextSimulationTime>>VehicleNum>>x>>y>>BeginTime>>EndTime;
		TraceFileEOF=TraceFile.eof();
		if(!TraceFileEOF&&(TraceFile.bad()||TraceFile.fail()))
		{
			cerr<<"RUN ERROR: Stream became corrupted during simulation!"<<endl;
			RunValid=false;
			break;
		}
		if(SimulationTime==-1){SimulationTime=NextSimulationTime;}//This prevents a logic error that causes a simulation tick before the first batch of tracefile data has been processed.
		if(TraceFileEOF||SimulationTime!=NextSimulationTime)
		{
			RunValid=RunValid&&PrimaryProtocol->SimulationTick();
			if(!RunValid){break;}//This short-circuits the execution if a critical error as occurred.
			//This loop adds to the average counters in each vehicle.
			//Average counters are processed after the simulation to get various anonymity statistics.
			//As such, these values are not menaingful until they have been finalized later.
			for(int i=0;i<VehicleMax;i++)
//.........这里部分代码省略.........
开发者ID:vanetprivacy,项目名称:cox,代码行数:101,代码来源:VANETSimulator.cpp


注:本文中的Dictionary::Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。