本文整理汇总了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);
}
}
}
}
示例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;
}
示例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;
}
示例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()]);
}
}
}
示例5: predToTuple
Tuple Interpretter::predToTuple(Predicate query) {
Tuple out;
for (auto item : query.getParams()) {
out.push_back(item.toString());
}
return out;
}
示例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)");
}
示例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]);
}
示例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;
}
示例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());
}
}
示例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++;
}
}
}
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}