コード例 #1
0
ファイル: Linkedlist(doubly).cpp プロジェクト: cdht/Algorithm
int main(){
  int foo[] = {1,2,3,4,5};
  //iterator constructor, indicating the end
  std::list<int> bar(foo,foo + sizeof(foo) / sizeof(int));
  printf("%d\n",RemoveInteger(bar,2));
  return 0;
}
コード例 #2
0
void ParameterList::RemoveInteger(const std::string name){
	try{
		unsigned int id =  FindIntegerParameter(name) - vInt_.begin();
		RemoveInteger(id);
	} catch (BadParameter& ex){
		BOOST_LOG_TRIVIAL(error) <<" ParameterList::RemoveInteger() | Can not remove"
				"parameter "<<name<<": "<<ex.what();
		throw;
	}
}
コード例 #3
0
void ParameterList::RemoveDuplicates()
{
	//We loop over the list of parameters and delete some. Therefore the size
	//changes during to loop. We enclose GetParameter in try...catch
	for(int i=0; i<GetNParameter(); i++ ){
		std::string name;
		try{
			name = GetParameter(i)->GetName();
		} catch (...){
			continue;
		}
		for(int j=i+1; j<GetNParameter(); j++ ){
			std::string name2;
			std::shared_ptr<AbsParameter> delPar;
			try{
				delPar = GetParameter(j);
				name2 = GetParameter(j)->GetName();
			} catch (...){
				continue;
			}

			if( name == name2 ){
				auto type = delPar->type();
				switch(type){
				case ParType::BOOL:
					RemoveBool(j); break;
				case ParType::INTEGER:
					RemoveInteger(j-vBool_.size()); break;
				case ParType::DOUBLE:
					RemoveDouble(j-vBool_.size()-vInt_.size()); break;
				case ParType::COMPLEX:
					RemoveComplex(j-vBool_.size()-vInt_.size()-vComplex_.size());
					break;
				case ParType::MDOUBLE:
					RemoveMultiDouble(j-vBool_.size()-vInt_.size()-vComplex_.size()
							-vMultiDouble_.size());
					break;
				case ParType::MCOMPLEX:
					RemoveMultiComplex(j-vBool_.size()-vInt_.size()-vComplex_.size()
							-vMultiDouble_.size()-vMultiComplex_.size());
					break;
				case ParType::MUNSIGNEDINTEGER:
					RemoveMultiUnsignedInteger(
							j-vBool_.size()-vInt_.size()-vComplex_.size()
							-vMultiDouble_.size()-vMultiComplex_.size()
							-vMultiUnsignedInteger_.size()
					);
					break;
				}
				j--; //decrement if a parameter is removed
			}
		}
	}
}