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


C++ Tuple::clear方法代码示例

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


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

示例1: project

Relation Relation::project(vector<int>& index1)
{
	Relation temp;

	Tuple tempTuplele;

	for(int i=0; i<index1.size(); i++)
	{
		temp.my_values.ADD(my_values.scheme_string(index1[i]));
	}

	for (set<Tuple>::iterator it = Tuple_Set.begin(); it != Tuple_Set.end(); ++it)
	{
		for(int i = 0; i < index1.size(); i++)
		{
			tempTuplele.push_back((*it)[index1[i]]);
		}

		temp.Tuple_Set.insert(tempTuplele);
		tempTuplele.clear();
	}

	temp.my_name = my_name;

	return temp;
}
开发者ID:kurtiscc,项目名称:Discrete-Structures,代码行数:26,代码来源:Relation.cpp

示例2: project

void Relation::project(map<int, string>& variables)
{
	set<Tuple> newTuples;
	Scheme newScheme;
	Tuple t;

	for (auto& v : variables){
		newScheme.addAttribute(scheme.getAttributes().at(v.first));
	}

	for (auto& tup : tuples){
		for (auto& v : variables)
		{
			t.addAttValue(tup.at(v.first));
		}
		if (variables.size() > 0){
			newTuples.insert(t);
			t.clear();
		}
	}

	tuples = newTuples;
	scheme = newScheme;
	setName("project");
}
开发者ID:hectorlugo,项目名称:CS236,代码行数:25,代码来源:Relation.cpp

示例3: reallocate

template<class T> void Tuple<T>::join(Tuple<T>& t) {
    int old_sz = sz;
    reallocate(t.size()+size());
    assert(alloc_sz >= sz);
    for(int i=0; i<t.sz; i++)
	data[i+old_sz] = t.data[i];
    t.clear();
}
开发者ID:LittleForker,项目名称:the-omega-project,代码行数:8,代码来源:Tuple.c

示例4: parseFacts

void Database::parseFacts()
{
	Tuple tup;
	for (int i = 0; i < Facts.size(); i++){
		if (relations.count(Facts[i].getData())){
			setTupleAttributeValues(tup, i);
			relations[Facts[i].getData()].addTuple(tup);
			tup.clear();
		}
	}
}
开发者ID:hectorlugo,项目名称:CS236,代码行数:11,代码来源:Database.cpp

示例5: execProject

void Join::execProject(const Tuple &left_tuple,
                       const Tuple &right_tuple,
                       Tuple &output_tuple) const
{
    output_tuple.clear();

    for (ColID i = 0; i < numOutputCols(); ++i) {
        if (selected_input_col_ids_[i] < left_child_->numOutputCols()) {
            output_tuple.push_back(left_tuple[selected_input_col_ids_[i]]);
        } else {
            output_tuple.push_back(right_tuple[selected_input_col_ids_[i]
                                   - left_child_->numOutputCols()]);
        }
    }
}
开发者ID:hyunjung,项目名称:cardinality,代码行数:15,代码来源:Join.cpp

示例6: PluginError


//.........这里部分代码省略.........
	//check number and type of arguments
	if (parms.size()!= 2)
	  {
	    throw PluginError("Wrong number of arguments");
	  }
	else
	  {
	    if(parms[0].isSymbol() && parms[1].isSymbol()) 
	      {
		matrixPred = parms[0].getString();
		//std::cout << "Matrixpraedikat: " << matrixPred << std::endl;
		constantPred = parms[1].getString();
		//std::cout << "Vektorpraedikat: " << vectorPred << std::endl;
	      }
	    else
	      {
		throw PluginError("Wrong type of arguments");
	      }
	  }
	//get complete Interpretation of given predicates in query
	AtomSet totalInt = query.getInterpretation();
	AtomSet matrixInt;
	AtomSet constantInt;
      
	if (totalInt.empty()) 
	  {
	    throw PluginError("Could not find any interpretion");
	  }
	else 
	  {
	    // separate interpretation into facts of first predicate (matrix)
	    totalInt.matchPredicate(matrixPred, matrixInt);
	    // and into facts of second predicate (vector)
	    totalInt.matchPredicate(constantPred, constantInt);
	  }
	
	int mRows = 0;
	int mColumns = 0;
	int cRows = 0;
	int cColumns = 0;
	evaluateMatrix(matrixInt, mRows, mColumns);
	evaluateVector(constantInt, cRows, cColumns);
	
	if(mRows != cRows) throw PluginError("Coefficient matrix and target vector(s) or matrix do not have the same dimensions.");

	std::vector <std::vector <std::string> > matrix(mRows);
	for(int i = 0; i < mRows; i++)
	  matrix[i].resize(mColumns);
	
	std::vector <std::vector <std::string> > constants(cRows);
	for (int i = 0; i < cRows; i++)
	  constants[i].resize(cColumns);

	//write the values of the Atoms in the Interpretation into std::vectors for further processing
	convertMatrixToVector(matrixInt, mRows, mColumns, matrix);
	convertMatrixToVector(constantInt, cRows, cColumns, constants); 

	//check if matrix and target vector or matrix are fully defined
	checkVector(matrix, mRows, mColumns, matrixPred);
	checkVector(constants, cRows, cColumns, constantPred);
	 
	//convert matrix to MatrixRank-expression and calculate rank of coefficient matrix A 
	std::string coeffMRankExpr = toMatrixRankExpr(matrix, mRows, mColumns);
	//std::cout << "MatrixRank expression: " << coeffMRankExpr << std::endl;
	int coeffMRank = calculateRank(argc, argv, coeffMRankExpr);

	//convert matrix A and target b to MatrixRank-expression and calculate rank
	//of extended coefficient matrix [A,b]
	std::string extendedMRankExpr = toMatrixRankExpr(matrix, mRows, mColumns, constants, cRows, cColumns);
	//std::cout << "Extended MatrixRank expression: " << extendedMRankExpr << std::endl;
	int extCoeffMRank = calculateRank(argc, argv, extendedMRankExpr);

	//compare calculated ranks and number of matrix colums, iff they are equal, 
	//a unique solution for the matrix equation exists
	if ((coeffMRank == extCoeffMRank) && (coeffMRank == mColumns))
	  {
	    std::string linSolExpr = toLinearSolveExpr(matrix, mRows, mColumns, constants, cRows, cColumns);
	    std::vector <std::string> result;
	    result = calculateSolution(argc, argv, linSolExpr);
	    if(result.size() != mColumns*cColumns)
	      throw PluginError("Wrong number of arguments in result vector");
	    Tuple out;
	    int index = 0;

	    //fill the result values with correct indices into Tuple out
	    //and add all Tuples to Answer
	    for (int r = 1; r <= mColumns; r++)
	      {
		for(int c = 1; c<= cColumns; c++)
		  {
		    out.push_back(Term(r));
		    out.push_back(Term(c));
		    out.push_back(Term(result[index],true));
		    answer.addTuple(out);
		    out.clear();
		    index++;
		  }
	      }
	  }
      }      
开发者ID:hexhex,项目名称:mathematicaplugin,代码行数:101,代码来源:UniqueLinSolve.cpp


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