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


C++ NetworkAddress::getPrefixLength方法代码示例

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


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

示例1: clear

void NetworkAddressSet::clear(NetworkAddressSet &customerSet, bool verbose){
	NetworkAddressSetOrder previousSetOrder=getOrder();
	NetworkAddressSetOrder previousCustomerSetOrder=customerSet.getOrder();
	this->sort(DESCENDING_PREFIX_LENGTH_ORDER);
	customerSet.sort(DESCENDING_PREFIX_LENGTH_ORDER);
	//first aggregate the sets
	this->aggregate();
	customerSet.aggregate();
	//in order to remove or split larger blocks (smaller prefixLengths) reverse the customerSet
	customerSet.sort(ASCENDING_PREFIX_LENGTH_ORDER);
	NetworkAddressNode *customerCurrentNodePtr=customerSet.headNodePtr;
	NetworkAddress * targetSubnetPtr;
	bool deleted;
	float i=0;
	while(customerCurrentNodePtr!=0){
		deleted=false;
		targetSubnetPtr=customerCurrentNodePtr->subnetPtr;
		NetworkAddressNode * currenNodePtr=this->headNodePtr;
		NetworkAddress *candidateSubnetPtr;//the subnet to be deleted or splitted and partially deleted
		//cout<<"Target :\n"<<*targetSubnetPtr<<endl;
		while(currenNodePtr!=0){
			candidateSubnetPtr=currenNodePtr->subnetPtr;
			if(*candidateSubnetPtr==*targetSubnetPtr){//remove targetSubnetPtr
				//cout<<"**********Candidate to be directly deleted"<<endl<<*candidateSubnetPtr<<endl;
				delete removeNetworkAddress(*candidateSubnetPtr);
				//cout<<"major set after removal\n"<<*this<<endl;
				deleted=true;
				break;
			}
			if(candidateSubnetPtr->subsumes(*targetSubnetPtr)){
				//cout<<"major set before removal\n"<<*this<<endl;
				//cout<<"Candidate to be extracted and deleted"<<endl<<*candidateSubnetPtr<<endl;
				removeNetworkAddress(candidateSubnetPtr);
				NetworkAddressSet * splittedSet=candidateSubnetPtr->split(targetSubnetPtr->getPrefixLength());
				delete candidateSubnetPtr;
				//cout<<"major set after removal\n"<<*this<<endl;

				//cout<<"splitted set\n"<<*splittedSet<<endl;
				splittedSet->removeNetworkAddress(*targetSubnetPtr);
				//cout<<"splitted set after removal\n"<<*splittedSet<<endl;
				splittedSet->aggregate();
				//cout<<"splitted set after  re-aggregate\n"<<*splittedSet<<endl;
				NetworkAddressNode *tmp, *currentSplittedNodePtr=splittedSet->headNodePtr;
				while(currentSplittedNodePtr!=0){
					tmp=currentSplittedNodePtr;
					currentSplittedNodePtr=currentSplittedNodePtr->nextNodePtr;
					insert(tmp->subnetPtr);
					delete tmp;
				}
				delete splittedSet;
				//cout<<"major set after addition\n"<<*this<<endl;

				deleted=true;
				break;
			}
			currenNodePtr=currenNodePtr->nextNodePtr;
		}
		if(deleted==false){
			cout<<"ITOM Warning: Can NOT clear subnet"<<*(customerCurrentNodePtr->subnetPtr->getHumanReadableRepresentation())<<endl;
		}
		if(verbose){
			cout<<(++i/customerSet.size)*100<<" % of customer set has been processed"<<endl;
		}
		customerCurrentNodePtr=customerCurrentNodePtr->nextNodePtr;
	}
	customerSet.sort(previousCustomerSetOrder);
	this->sort(previousSetOrder);
}
开发者ID:JefGrailet,项目名称:treenet,代码行数:68,代码来源:NetworkAddressSet.cpp


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