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


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

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


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

示例1: PluginError

void
PredicatesAtom::retrieve(const Query& query, Answer& answer) throw (PluginError)
{
	RegistryPtr reg = query.interpretation->getRegistry();

	// Retrieve answer index and answer-set index
	int answerindex = query.input[0].address;
	int answersetindex = query.input[1].address;

	// check index validity
	if (answerindex < 0 || answerindex >= resultsetCache.size()){
		throw PluginError("An invalid answer handle was passed to atom &predicates");
	}else if(answersetindex < 0 || answersetindex >= resultsetCache[answerindex].size()){
		throw PluginError("An invalid answer-set handle was passed to atom &predicates");
	}else{
		// Go through all atoms of the given answer_set
		for(Interpretation::Storage::enumerator it =
		    (resultsetCache[answerindex])[answersetindex]->getStorage().first();
		    it != (resultsetCache[answerindex])[answersetindex]->getStorage().end(); ++it){

			if (!reg->ogatoms.getIDByAddress(*it).isAuxiliary()){
				ID ogid(ID::MAINKIND_ATOM | ID::SUBKIND_ATOM_ORDINARYG, *it);
				const OrdinaryAtom& ogatom = reg->ogatoms.getByID(ogid);

				Tuple t;
				t.push_back(ogatom.tuple[0]);
				t.push_back(ID::termFromInteger(ogatom.tuple.size() - 1));
				answer.get().push_back(t);
			}
		}
	}
}
开发者ID:hexhex,项目名称:mergingplugin,代码行数:32,代码来源:HexExecution.cpp

示例2: joinTuple

Tuple Database::joinTuple(set<pair<int, int>> pairs, Tuple t1, Tuple t2){
	Tuple newTuple;
	for (int i = 0; i<t1.size(); i++){
		newTuple.push_back(t1[i]);
	}
	for (auto i : t2){
		newTuple.push_back(i);
	}
	return newTuple;
}
开发者ID:mountain01,项目名称:VSProjects,代码行数:10,代码来源:Database.cpp

示例3: do_product

Tuple Relation::do_product(Tuple t1, Tuple t2) {
	Tuple t = Tuple();
	for (auto item : t1) {
		t.push_back(item);
	}
	for (auto item2 : t2) {
		t.push_back(item2);
	}
	return t;
}
开发者ID:boxershorts7,项目名称:School,代码行数:10,代码来源:Relation.cpp

示例4: 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

示例5: predToTuple

Tuple Interpretter::predToTuple(Predicate query) {
    Tuple out;
    for (auto item : query.getParams()) {
        out.push_back(item.toString());
    }
    return out;
}
开发者ID:thelinguist,项目名称:CS-236,代码行数:7,代码来源:Interpretter.cpp

示例6: kb

void
TestRacerNRQL::runRacerRetrieveTest()
{
  std::stringstream sst;

  Tuple tup;
  tup.push_back(Term("X"));
  tup.push_back(Term("Y"));

  AtomSet as;
  AtomPtr ap1(new Atom("foo(X)"));
  AtomPtr ap2(new Atom("moo(X,Y)"));
  as.insert(ap1);
  as.insert(ap2);

  KBManager kb("DEFAULT");
  DLQuery::shared_pointer dlq(new DLQuery(Ontology::createOntology(test),as,tup));
  Query q(kb,dlq,Term(""),Term(""),Term(""),Term(""),AtomSet());

  NRQLRetrieve<NRQLConjunctionBuilder> nrql(q);

  sst << nrql;
     
  std::string s = sst.str();
 
  std::cout << s << std::endl;

  CPPUNIT_ASSERT(s == "(retrieve ($?X $?Y) (and ($?X $?Y |http://www.test.com/test#moo|) ($?X |http://www.test.com/test#foo|)) :abox DEFAULT)");
}
开发者ID:hexhex,项目名称:dlplugin,代码行数:29,代码来源:TestRacerNRQL.cpp

示例7: precalculate

void SimpleFilter::precalculate(int order, int mask)
{
  if (mask & (H2D_FN_DX | H2D_FN_DY | H2D_FN_DXX | H2D_FN_DYY | H2D_FN_DXY))
    error("Filter not defined for derivatives.");

  Quad2D* quad = quads[cur_quad];
  int np = quad->get_num_points(order);
  Node* node = new_node(H2D_FN_VAL, np);

  // precalculate all solutions
  for (int i = 0; i < num; i++)
    sln[i]->set_quad_order(order, item[i]);

  for (int j = 0; j < num_components; j++)
  {
    // obtain corresponding tables
    scalar* tab[10];
    for (int i = 0; i < num; i++)
    {
      int a = 0, b = 0, mask = item[i];
      if (mask >= 0x40) { a = 1; mask >>= 6; }
      while (!(mask & 1)) { mask >>= 1; b++; }
      tab[i] = sln[i]->get_values(num_components == 1 ? a : j, b);
      if (tab[i] == NULL) error("Value of 'item%d' is incorrect in filter definition.", i+1);
    }

		Tuple<scalar*> values;
		for(int i = 0; i < this->num; i++)
			values.push_back(tab[i]);

    // apply the filter
		filter_fn(np, values, node->values[j][0]);
  }
开发者ID:MathPhys,项目名称:hermes,代码行数:33,代码来源:filter.cpp

示例8: 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

示例9: hc

void
CallHexFileAtom::retrieve(const Query& query, Answer& answer) throw (PluginError)
{
	RegistryPtr reg = query.interpretation->getRegistry();

	std::string programpath;
	std::string cmdargs;
	InterpretationConstPtr inputfacts = query.interpretation;
	try{
		const Tuple& params = query.input;

		// load program
		programpath = reg->terms.getByID(params[0]).getUnquotedString();

		// Retrieve command line arguments
		if (params.size() > 1 + arity){
			cmdargs = reg->terms.getByID(params[1 + arity]).getUnquotedString();
		}

		// Build hex call identifier
		HexCall hc(HexCall::HexFile, programpath, cmdargs, inputfacts);

		// request entry from cache (this will automatically add it if it's not contained yet)
		Tuple out;
		out.push_back(ID::termFromInteger(resultsetCache[hc]));
		answer.get().push_back(out);
	}catch(PluginError){
		throw;
	}catch(...){
		std::stringstream msg;
		msg << "Nested Hex program \"" << programpath << "\" failed. Command line arguments were: " << cmdargs;
		throw PluginError(msg.str());
	}
}
开发者ID:hexhex,项目名称:mergingplugin,代码行数:34,代码来源:HexExecution.cpp

示例10: evalRules

void Interpretter::evalRules(vector <Rule>& rulelist) {

    for (Rule rule : rulelist) {
        cout << rule.toString();
        output += rule.toString();
        
        //get the first rule, then iterate thru the rest, adding to the new "joined" Relation
        Relation joined = db[rule.getPredicates()[0].getID()];
        
        // set a joined scheme, based on predicate[0]'s params. And give it to me in tuple format
        joined.redoScheme(rule.getPredicates()[0].getParams());
        if (rulelist.size() > 1) {
            vector <Relation> processedPreds;
            if (rule.getPredicates().size() > 1) {
                
                //for each Predicate (after the first) in the rule
                for (int i = 1; i < rule.getPredicates().size(); i++) {
                    Relation r = db[rule.getPredicates()[i].getID()];
                    Tuple predT = predToTuple(rule.getPredicates()[i]);
                    
                    Relation selected = r.select(predT);
                    //output += selected.toString();
                    
                    //Relation projected = selected.project(predT);
                    //output += projected.toString();
                    
                    Relation renamed = selected.rename(predT);
                    processedPreds.push_back(renamed);
                    joined = joined.join(renamed);
                }
            }
        }

        Tuple renameScheme;
        //cout << "rule.getName() = " << rule.getName() << endl;
        for (auto item : rule.getParams()) {
            renameScheme.push_back(item.getVal());
        }
        //cout << "joined" << joined.toString();
        Relation projectRule = joined.project2(renameScheme); //project with the original columns
        //Relation renameRule = projectRule.rename(renameScheme); // use the original scheme
        //cout << renameRule.toString();
        int prevSize = db[rule.getName()].getRelSize();
        for (auto tuple : projectRule.getTuples()) {

            db[rule.getName()].add(tuple);

            //if it actually added
            if (db[rule.getName()].getRelSize() > prevSize) {
                output += db[rule.getName()].tupleToString(tuple);
                prevSize = db[rule.getName()].getRelSize();
                addedTuples++;
            }
        }
        
    }
}
开发者ID:thelinguist,项目名称:CS-236,代码行数:57,代码来源:Interpretter.cpp

示例11: lazy_class_exec

packToken lazy_class_exec(packMap scope) {
  packMap _this = scope->find("this")->asMap();
  Function* func = (*_this)["func"].asFunc();
  packList args = (*_this)["args"].asList();

  Tuple tuple;
  // Copy the tokens from this.args:
  for (packToken item : args->list) {
    tuple.push_back(item);
  }

  // Copy the tokens received as exec() arguments:
  args = scope->find("arglist")->asList();
  for (packToken item : args->list) {
    tuple.push_back(item);
  }

  return Function::call(_this, func, &tuple, packMap(scope->parent));
}
开发者ID:VinGarcia,项目名称:cpp-code-parser,代码行数:19,代码来源:global-setup.cpp

示例12: initFacts

void Database::initFacts(vector<Predicate> facts){
	for(int i = 0; i < (int)facts.size(); i++){
		Predicate r = facts[i];
		string name = r.getID();
		Tuple t;
		for(int j = 0; j < (int)r.getParameters().size(); j++)
			t.push_back(r.getParameters()[j].getValue());
		addTuple(name, t);
	}
}
开发者ID:jrasm91,项目名称:cs236,代码行数:10,代码来源:database.cpp

示例13: retrieve

	virtual void retrieve(const Query& q, Answer& a) throw (dlvhex::PluginError)
  {
    // get inputs
    assert(q.input.size() == 3);
    ID preddisarm = q.input[0];
    ID predlook = q.input[1];
    ID time = q.input[2];
    LOG(INFO,"calculating senseNotArmed2 extatom for " << preddisarm << "/" << predlook << "/" << time);

    // get outputs
    assert(q.pattern.size() == 0);

    // check if <preddisarm>(time) and <predlook>(time) part of interpretation
    Tuple tdisarm;
    tdisarm.push_back(preddisarm);
    tdisarm.push_back(time);
    ID iddisarm = registry->ogatoms.getIDByTuple(tdisarm);

    Tuple tlook;
    tlook.push_back(predlook);
    tlook.push_back(time);
    ID idlook = registry->ogatoms.getIDByTuple(tlook);

    if( iddisarm == ID_FAIL || idlook == ID_FAIL )
    {
      // cannot be part of interpretation -> return no tuple as condition not true
      return;
    }

    // check interpretation
    assert(q.interpretation != 0);
    if( q.interpretation->getFact(iddisarm.address) &&
        q.interpretation->getFact(idlook.address) )
    {
      // found both facts
      Tuple t;
      a.get().push_back(t);
    }
  }
开发者ID:imchaozhang,项目名称:DLVHEX-2.4,代码行数:39,代码来源:TestPlainHEX.cpp

示例14: join_tuples

Tuple Relation::join_tuples(Tuple t1, Tuple t2, std::vector<std::pair<int, int>> common_attributes) {
	Tuple t = Tuple();

	for (auto item : t1) {
		t.push_back(item);
	}

	int num_attributes = t2.size();

	for (int i = 0; i < num_attributes; i++) {
		// Make sure you aren't adding common attributes twice
		bool is_common_attribute = false;
		for (auto pair : common_attributes) {
			if (i == pair.second)
				is_common_attribute = true;
		}

		if (!is_common_attribute) {
			t.push_back(t2.at(i));
		}
	}

	return t;
}
开发者ID:boxershorts7,项目名称:School,代码行数:24,代码来源:Relation.cpp

示例15: project

Relation Relation::project(vector<int> &indexList){
	Relation r = Relation(name);
	for(int i = 0; i < (int)indexList.size(); i++)
		r.schema.attributes.push_back(schema.attributes[indexList[i]]);
	if(indexList.size() != 0){
		set<Tuple>::iterator it;
		for(it = tuples.begin(); it != tuples.end(); it++){
			Tuple newTuple = Tuple();
			for(int j = 0; j < (int)indexList.size(); j++)
				newTuple.push_back((*it)[indexList[j]]);
			r.tuples.insert(newTuple);
		}
	}
	return r;

}
开发者ID:abrinck,项目名称:cs236,代码行数:16,代码来源:Relation.cpp


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