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


C++ Answer类代码示例

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


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

示例1: docSource

void TrecDocumentProcessorTestCase::testProcessGZipFile()
{
    TrecDocumentProcessor processor;
    processor.init(m_pDocSchema.get(), m_pDocTemp.get());
    
    DocumentSource docSource(m_pDocSchema.get());
    RawDocumentPtr pRawDoc = new RawDocument();
    pRawDoc->setPath(getTestPath() + "/1.gz");
    docSource.setRawDocument(pRawDoc);

    Answer ans;
    makeAnswer(TEST_FILE2, ans);

    size_t i = 0;
    do
    {
        processor.process(docSource);

        DocumentPtr pDoc = docSource.stealLastDocument();
        CPPUNIT_ASSERT(pDoc);

        Document::Iterator it = pDoc->iterator();
        while (it.hasNext())
        {
            const Field* pField = it.next();
            CPPUNIT_ASSERT_EQUAL(ans[i].first, pField->getFieldSchema()->getName());
            CPPUNIT_ASSERT_EQUAL(ans[i].second, std::string(pField->getValue().c_str()));
            ++i;
        }
    } while(docSource.toBeContinued());
    CPPUNIT_ASSERT_EQUAL(ans.size(), i);
}
开发者ID:hxfxjun,项目名称:firtex2,代码行数:32,代码来源:TrecDocumentProcessorTestCase.cpp

示例2: writeTestFile

void StandardDocumentProcessorTestCase::testProcessWithEmptyField()
{
    String sPath = writeTestFile("file_with_empty_field.txt", TEST_FILE_WITH_EMPTY_FIELD);

    StandardDocumentProcessor processor;
    processor.init(m_pDocSchema.get());
    
    DocumentSource docSource(m_pDocSchema.get());
    RawDocumentPtr pRawDoc = new RawDocument();
    pRawDoc->setPath(sPath);
    docSource.setRawDocument(pRawDoc);

    processor.process(docSource);

    DocumentPtr pDoc = docSource.stealLastDocument();
    CPPUNIT_ASSERT(pDoc.isNotNull());

    Answer ans;
    makeAnswer(TEST_FILE_WITH_EMPTY_FIELD, ans);

    Document::Iterator it = pDoc->iterator();
    CPPUNIT_ASSERT_EQUAL(ans.size(), it.size());
    size_t i = 0;
    while (it.hasNext())
    {
        const Field* pField = it.next();
//        cout << ans[i].first << " : " << ans[i].second << endl;
        CPPUNIT_ASSERT_EQUAL(ans[i].first, pField->getFieldSchema()->getName());
        CPPUNIT_ASSERT_EQUAL(ans[i].second, std::string(pField->getValue().c_str()));
        ++i;
    }
}
开发者ID:Web5design,项目名称:firtex2,代码行数:32,代码来源:StandardDocumentProcessorTestCase.cpp

示例3: in

vector<Answer> Question::get_answers()
{
	const char* answers_file = Configuration::configuration->get_a_file();
	ifstream in(answers_file, ios::in | ios::binary);
	if (!in.is_open())
	{
		//ИСКЛЮЧЕНИЕ
	}
	TestingSystem::answer_msg a_msg;
	string s;
	vector<Answer> result;
	while (in.cur!= in.eof())
	{
		char c;
		in.read((char*)&c, sizeof c);
		s+=c;
		if (!a_msg.ParseFromString(s))
			a_msg.set_id(-1);
		else
		{
			s = "";
			if (a_msg.q_id() == getID())
			{
				Answer a;
				a.set_contents(a_msg.body());
				a.set_correct(a_msg.correct());
				a.set_q_id(getID());
				a.setID(a_msg.id());
				result.push_back(a);
			}
		}
	}
	in.close();
	return result;
}
开发者ID:MaxMyalkin,项目名称:TestingSystem,代码行数:35,代码来源:Question.cpp

示例4: writeTestFile

void TrecDocumentProcessorTestCase::testProcessFileMisField()
{
    string sPath = writeTestFile("trec_file3.txt", TEST_FILE_MISS_FIELD);

    TrecDocumentProcessor processor;
    processor.init(m_pDocSchema.get(), m_pDocTemp.get());
    
    DocumentSource docSource(m_pDocSchema.get());
    RawDocumentPtr pRawDoc = new RawDocument();
    pRawDoc->setPath(sPath);
    docSource.setRawDocument(pRawDoc);

    processor.process(docSource);

    DocumentPtr pDoc = docSource.stealLastDocument();
    CPPUNIT_ASSERT(pDoc);

    Answer ans;
    makeAnswer(TEST_FILE_MISS_FIELD, ans);

    Document::Iterator it = pDoc->iterator();
    CPPUNIT_ASSERT_EQUAL(ans.size(), it.size());
    size_t i = 0;
    while (it.hasNext())
    {
        const Field* pField = it.next();
//        cout << ans[i].first << " : " << ans[i].second << endl;
        CPPUNIT_ASSERT_EQUAL(ans[i].first, pField->getFieldSchema()->getName());
        CPPUNIT_ASSERT_EQUAL(ans[i].second, std::string(pField->getValue().c_str()));
        ++i;
    }
}
开发者ID:hxfxjun,项目名称:firtex2,代码行数:32,代码来源:TrecDocumentProcessorTestCase.cpp

示例5: compute

void DolphinSolver::solve(const PlayBoard<H, W>& board)
{
    const std::vector<AnswerTreeBoard<H, W>> input = {AnswerTreeBoard<H, W>(AnswerTreeBoardBase<H, W>(board))};
    const AnswerTreeBoard<H, W> result = compute(input, board.height()/2-2, board.width()/2-2, 4, 4);
    Answer answer = result.buildAnswer();
    answer.optimize();
    onCreatedAnswer(answer);
}
开发者ID:natrium11321,项目名称:procon2014_ut,代码行数:8,代码来源:DolphinSolver.cpp

示例6: GetAnswer

bool KnowledgeBase::IsSatisfiable(const Argument& arg)
{
  // get answer
  Answer *ans = GetAnswer(arg, VariableMap(), std::set<size_t>());
  // return if any valid substitution exists
  bool res = ans->next();
  delete ans;
  return res;
}
开发者ID:AMPedGames,项目名称:libgdl,代码行数:9,代码来源:knowledgebase.cpp

示例7: arg

bool KnowledgeBase::IsSatisfiable(const std::string& s_arg)
{
  Argument arg(s_arg, symbol_table, true, log);
  // get answer
  Answer *ans = GetAnswer(arg, VariableMap(), std::set<size_t>());
  // return if any valid substitution exists
  bool res = ans->next();
  delete ans;
  return res;
}
开发者ID:AMPedGames,项目名称:libgdl,代码行数:10,代码来源:knowledgebase.cpp

示例8: validate

 /**
  * Applies validation on block
  * @param block
  * @return Answer containing found error if any
  */
 Answer validate(const interface::EmptyBlock &block) const {
   Answer answer;
   ReasonsGroupType reason;
   reason.first = "EmptyBlock";
   field_validator_.validateCreatedTime(reason, block.createdTime());
   field_validator_.validateHeight(reason, block.height());
   if (not reason.second.empty()) {
     answer.addReason(std::move(reason));
   }
   return answer;
 }
开发者ID:kevinmcmahon,项目名称:iroha,代码行数:16,代码来源:empty_block_validator.hpp

示例9: throw

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

	// Extract answer index, answerset index and predicate to retrieve
	int answerindex = query.input[0].address;
	int answersetindex = query.input[1].address;
	ID predicate = query.input[2];

	// check index validity
	if (answerindex < 0 || answerindex >= resultsetCache.size()){
		throw PluginError("An invalid answer handle was passed to atom &arguments");
	}else if(answersetindex < 0 || answersetindex >= resultsetCache[answerindex].size()){
		throw PluginError("An invalid answer-set handle was passed to atom &arguments");
	}else{
		int runningindex = 0;

		// 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){

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

			// If the atom is built upon the given predicate, return it's parameters
			if (ogatom.tuple[0] == predicate){
				// special case of index "s": positive or strongly negated
				Tuple ts;
				ts.push_back(ID::termFromInteger(runningindex));
				Term t(ID::MAINKIND_TERM | ID::SUBKIND_TERM_CONSTANT, "s");
				ts.push_back(reg->storeTerm(t));
				ts.push_back(ID::termFromInteger(/*it->isStronglyNegated() ? 1 :*/ 0));	// TODO: check if the atom is strongly negated
				answer.get().push_back(ts);

				// Go through all parameters
				for (int i = 1; i < ogatom.tuple.size(); ++i){
					Tuple t;
					t.push_back(ID::termFromInteger(runningindex));
					t.push_back(ID::termFromInteger(i - 1));
					t.push_back(ogatom.tuple[i]);
					answer.get().push_back(t);
				}
				runningindex++;
			}
		}
	}
}
开发者ID:hexhex,项目名称:mergingplugin,代码行数:49,代码来源:HexExecution.cpp

示例10: validate

      /**
       * Applies validation to given query
       * @param qry - query to validate
       * @return Answer containing found error if any
       */
      Answer validate(const interface::BlocksQuery &qry) const {
        Answer answer;
        std::string qry_reason_name = "Blocks query";
        ReasonsGroupType qry_reason(qry_reason_name, GroupedReasons());

        field_validator_.validateCreatorAccountId(qry_reason,
                                                  qry.creatorAccountId());
        field_validator_.validateCreatedTime(qry_reason, qry.createdTime());
        field_validator_.validateCounter(qry_reason, qry.queryCounter());

        if (not qry_reason.second.empty()) {
          answer.addReason(std::move(qry_reason));
        }
        return answer;
      }
开发者ID:kevinmcmahon,项目名称:iroha,代码行数:20,代码来源:blocks_query_validator.hpp

示例11: main

int main() {
	gets(input + 1);
	n = strlen(input + 1);
	pPower[0] = 1ULL;
	for (int i = 1; i <= n; ++i) {
		pPower[i] = pPower[i - 1] * P;
		prefix[i] = prefix[i - 1] * P + input[i];
	}
	for (int i = n; i >= 1; --i) {
		suffix[i] = suffix[i + 1] * P + input[i];
	}
	for (int i = n, j = 1; i >= 1; --i) {
		int length = n - i + 1;
		for (; j <= n && (j < length || hashValue(prefix, j - length, j, length) != hashValue(suffix, n + 1, i, length)); j++);
		earliest[i] = j;
	}
	Answer result;
	result.normalize();
	for (int i = 1; i <= n; ++i) {
		int longest = 1, l = 2, r = min(i, n - i + 1), pos = n + 1;
		while (l <= r) {
			int mid = l + r >> 1;
			if (hashValue(prefix, i - mid, i, mid) == hashValue(suffix, i + mid, i, mid))
				longest = mid, l = mid + 1;
			else
				r = mid - 1;
		}
		l = i + longest, r = n;
		while (l <= r) {
			int mid = l + r >> 1;
			if (earliest[mid] <= i - longest)
				pos = mid, r = mid - 1;
			else
				l = mid + 1;
		}
		Answer temp;
		temp.v.push_back(Interval(i - longest + 1, i + longest - 1));
		if (pos <= n) {
			temp.v.push_back(Interval(pos, n));
			temp.v.push_back(Interval(earliest[pos] - (n - pos), earliest[pos]));
		}
		temp.normalize();
		update(result, temp);
	}
	printf("%d\n", (int)result.v.size());
	for (int i = 0; i < (int)result.v.size(); ++i)
		printf("%d %d\n", result.v[i].first, result.v[i].second - result.v[i].first + 1);
}
开发者ID:roosephu,项目名称:hw-I,代码行数:48,代码来源:30E.cpp

示例12: retrieve

	virtual void retrieve(const Query& q, Answer& a) throw (dlvhex::PluginError)
  {
    // get input
    assert(q.input.size() == 1);
    ID pred = q.input[0];

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

    // build unifier
    OrdinaryAtom unifier(ID::MAINKIND_ATOM | ID::SUBKIND_ATOM_ORDINARYN);
    unifier.tuple.push_back(pred);
    unifier.tuple.insert(unifier.tuple.begin(), q.pattern.begin(), q.pattern.end());

    // check if <pred>(pattern) part of interpretation (=forward <pred> via external atom)
    assert(q.interpretation != 0);
    const Interpretation::Storage& bits = q.interpretation->getStorage();
    for(Interpretation::Storage::enumerator it = bits.first();
        it != bits.end(); ++it)
    {
      const OrdinaryAtom& ogatom = registry->ogatoms.getByID(ID(ID::MAINKIND_ATOM | ID::SUBKIND_ATOM_ORDINARYG, *it));
      if( ogatom.unifiesWith(unifier) )
      {
        Tuple partial;
        partial.insert(partial.begin(), ogatom.tuple.begin()+1, ogatom.tuple.end());
        a.get().push_back(partial);
      }
    }
  }
开发者ID:imchaozhang,项目名称:DLVHEX-2.4,代码行数:29,代码来源:TestPlainHEX.cpp

示例13: main

int main(int argc, char* argv[]) {
  Test test;
  Solution sol;
  Answer ans;
  chrono::time_point<chrono::system_clock> ts0, ts1, ts2, ts3, ts4;
  ofstream outfile;
  outfile.open("output.txt");

  ts0 = std::chrono::system_clock::now();
  vector<int> tin = test.generate();

  ts1 = std::chrono::system_clock::now();
  vector<int> touts = sol.maxSlidingWindow(tin, TK);

  ts2 = std::chrono::system_clock::now();
  vector<int> touta = ans.maxSlidingWindow(tin, TK);

  ts3 = std::chrono::system_clock::now();
  if (touts.size() != touta.size()) {
    cout << "Error, solution size not equal" << endl;
    return -1;
  } else {
    for(int i=0; i<touts.size(); i++) {
      if (touts[i] != touta[i]) {
        cout << "Error, solution vector item: " << i << " not equal" << endl;
        return -2;
      } else {
        outfile << touts[i] << endl;
      }
    }
  }
  ts4 = std::chrono::system_clock::now();
  chrono::duration<double> e10 = ts1-ts0;
  chrono::duration<double> e21 = ts2-ts1;
  chrono::duration<double> e32 = ts3-ts2;
  chrono::duration<double> e43 = ts4-ts3;
  cout << argv[0] << " All test passed ~" << endl;
  cout << argv[0] << " Elapsed time generate test case:   " << e10.count() << endl;
  cout << argv[0] << " Elapsed time my solution O(N):     " << e21.count() << endl;
  cout << argv[0] << " Elapsed time official O(N) answer: " << e32.count() << endl;
  cout << argv[0] << " Elapsed time comparison result:    " << e43.count() << endl;

  outfile.close();
  return 0;
}
开发者ID:baiyz,项目名称:leetcode,代码行数:45,代码来源:lc239.cpp

示例14: validate

      /**
       * Applies validation to given query
       * @param qry - query to validate
       * @return Answer containing found error if any
       */
      Answer validate(const interface::Query &qry) const {
        Answer answer;
        std::string qry_reason_name = "Query";
        ReasonsGroupType qry_reason(qry_reason_name, GroupedReasons());

        field_validator_.validateCreatorAccountId(qry_reason,
                                                  qry.creatorAccountId());
        field_validator_.validateCreatedTime(qry_reason, qry.createdTime());
        field_validator_.validateCounter(qry_reason, qry.queryCounter());

        if (not qry_reason.second.empty()) {
          answer.addReason(std::move(qry_reason));
        }

        auto reason = boost::apply_visitor(query_field_validator_, qry.get());
        if (not reason.second.empty()) {
          answer.addReason(std::move(reason));
        }

        return answer;
      }
开发者ID:kevinmcmahon,项目名称:iroha,代码行数:26,代码来源:query_validator.hpp

示例15: main

/*! エントリポイント
 * \param [in] argc 引数の数
 * \param [in] argv コマンド文字列の配列
 */
int main(int argc, const char *argv[])
{
	using namespace std;
	// オプション解析
	signal(SIGINT, interrupt);
	vector<string> args;
	for(int i = 1;i < argc;i++){
		args.push_back(argv[i]);
	}
	options = parse_options(args);
	if(options["stat"] != "ok"){
		return -1;
	}

	// IOストリーム用意
	boost::shared_ptr<istream> ifs;
	boost::shared_ptr<ostream> ofs;
	if(options["input"] != ""){
		ifs.reset(new ifstream(options["input"].c_str(), ios::in));
	}else{
		ifs.reset(&cin, noop());
	}
	if(options["output"] != ""){
		ofs.reset(new ofstream(options["output"].c_str(), ios::out));
	}else{
		ofs.reset(&cout, noop());
	}

	Problem problem(ifs);
	Answer answer;

	if(options["bruteforce"] != "") Solve<AlgorithmBruteForce>(problem, answer);
	Solve<AlgorithmFillOne>(problem, answer);

	answer.Output(ofs);

	return (0);
}
开发者ID:natsuki-i,项目名称:mio,代码行数:42,代码来源:main.cpp


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