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


C++ Forest::reset方法代码示例

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


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

示例1: options

int
#ifdef _MSC_VER
__cdecl
#endif
main(int argc, char *argv[])
{
  INITLEAK;
  cin.tie(0);

  istream_arg forest_in;
  ostream_arg graphviz_out;
  const unsigned MEGS = 1024*1024;
  unsigned max_megs = (MAX_FOREST_NODES*sizeof(ForestNode)+MEGS-1)/MEGS;
  string prelude;
  options_description options("General options");
  bool help, same_rank, number_edges, pointer_nodes;

  options.add_options()
      ("help,h", bool_switch(&help),"produce help message")
      ("number-children,n", bool_switch(&number_edges),"label child edges 1,2,...,n")
      ("pointer-nodes,p", bool_switch(&pointer_nodes),"show dot-shaped pointer nodes for shared subforests")
      ("same-rank-children,s", bool_switch(&same_rank),"force children nodes to the same rank (implies -p)")
      ("graphviz-prelude,g", value<string>(&prelude), "graphviz .dot directives to be inserted in output graphs")
      ("forest-megs,M", value<unsigned>(&max_megs)->default_value(100), "Number of megabytes reserved to hold forests")
      ("in-forest-file,i", value<istream_arg>(&forest_in)->default_value(stdin_arg(),"STDIN"),"file containing one or more forests e.g. (OR (1 4) (1 3)) (1 #1(4 3) OR(#1 2))")
      ("out-graphviz-file,o", value<ostream_arg>(&graphviz_out)->default_value(stdout_arg(),"STDOUT"),"Output Graphviz .dot file (run dot -Tps out.dot -o out.ps)");

  positional_options_description pos;
  pos.add("in-forest-file", -1);
  const char *progname = argv[0];
  try {
    variables_map vm;
    store(command_line_parser(argc, argv).options(options).positional(pos).run(), vm);
    notify(vm);
#define RETURN(i) retval = i; goto done
    if (help) {
      cerr << progname << ":\n";
      cerr << options << "\n";
      cerr << "\n" << docstring << "\n";
      ABORT;
    }
    if (same_rank)
      pointer_nodes = true;
    unsigned n_nodes = max_megs*MEGS/sizeof(ForestNode);
    auto_array<ForestNode> fnodes(n_nodes);
    Forest f;

    ForestVizPrinter<> fviz(*graphviz_out, prelude);

    bool first = true;
    while (*forest_in) {
      f.reset(fnodes.begin(), fnodes.end());
      *forest_in >> f;
      if (forest_in->bad() || f.ran_out_of_space()) {
        cerr << "Error reading input forest:\n";
        show_error_context(*forest_in, cerr);
        ABORT;
      }

      if (*forest_in) {
        if (first)
          first = false;
        else
          fviz.next();
        fviz.print(f, same_rank, number_edges, pointer_nodes);
      }
    }
  } catch(std::exception& e) {
    cerr << "ERROR: " << e.what() << "\n\n";
    cerr << options << "\n";
    ABORT;
  }
  return 0;
}
开发者ID:SlyryD,项目名称:carmel,代码行数:74,代码来源:forestviz.cpp


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