本文整理汇总了C++中Stage::input方法的典型用法代码示例。如果您正苦于以下问题:C++ Stage::input方法的具体用法?C++ Stage::input怎么用?C++ Stage::input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stage
的用法示例。
在下文中一共展示了Stage::input方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[]) {
if (argc == 1) {
Stage st;
st.input(std::cin);
st.output(std::cout);
Data res = solve(st);
simulate(st, std::cout, res.records);
std::cout << res.count << std::endl;
}
else if (strcmp(argv[1], "calc") == 0) {
if (argc != 2) help();
std::vector<std::string> problems;
std::ifstream ifs("dat/LIST");
std::string in;
while (ifs >> in) problems.push_back(in);
for (std::string i: problems) {
std::ifstream ifs(("dat/" + i + ".dat").c_str());
if (!ifs) std::cerr << "FILE NOT EXISTS -- " <<
"dat/" << i << ".dat" << std::endl;
std::ofstream ofs(("asi1024/" + i).c_str());
Stage st;
st.input(ifs);
Data res = solve(st);
for (Record r: res.records) {
ofs << r.y << " " << r.x << std::endl;
st.swap(r.y, r.x);
}
std::cerr << i << "\t" << st.score <<
"\t(Node: " << res.count << ")" << std::endl;
st.clear();
}
}
else if (strcmp(argv[1], "eval") == 0) {
示例2:
AbstractSlot * Stage::getSlot(const std::string & path)
{
const auto names = cppassist::string::split(path, '.', true);
Stage * stage = this;
for (size_t i=0; i<names.size(); i++)
{
const std::string & name = names[i];
// Ignore own stage name at the beginning
if (name == stage->name() && i == 0)
{
continue;
}
// Check if stage is a pipeline and has a substage with the given name
if (stage->isPipeline())
{
Pipeline * pipeline = static_cast<Pipeline *>(stage);
Stage * sub = pipeline->stage(name);
if (sub)
{
stage = sub;
continue;
}
}
// If there is no more substage but more names to fetch, return error
if (i != names.size() - 1)
{
return nullptr;
}
// Check if stage has a slot with that name
auto inputSlot = stage->input(name);
if (inputSlot) {
return inputSlot;
}
auto outputSlot = stage->output(name);
if (outputSlot) {
return outputSlot;
}
}
return nullptr;
}