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


C++ list::find方法代码示例

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


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

示例1: read_counterexample

void modelchecker_smvt::read_counterexample(
    const std::list<std::string> &file,
    std::list<std::string>::const_iterator it,
    abstract_modelt &abstract_model,
    const threadst &threads,
    abstract_counterexamplet &counterexample)
{
  while(it!=file.end() && 
      (std::string(*it, 0, 1)=="*" ||
       std::string(*it, 0, 1)=="-" ||
       std::string(*it, 0, 5)=="Trace"))
    it++;

  abstract_statet abstract_state;

  bool data_set=false;

  std::vector<smv_ce_thread_infot> thread_infos;
  thread_infos.resize(threads.size());

  {
    unsigned i=0;
    for(threadst::const_iterator t_it=threads.begin();
        t_it!=threads.end();
        t_it++, i++)
      thread_infos[i].build(inlined, *t_it);
  }

  for(; it!=file.end(); it++)
  {
    //std::cout << "Xx " << *it << "\n";

    if(std::string(*it, 0, 3)=="-- ")
      break;
    else if(*it=="resources used:")
      break;
    else if(std::string(*it, 0, 6)=="state " ||
        std::string(*it, 0, 10)=="-> State: " ||
        std::string(*it, 0, 10)=="-> Input: " ||
        *it=="")
    {
      if(!data_set) continue;

      read_counterexample_store(
          abstract_model, counterexample, thread_infos, abstract_state);

      data_set=false;
    }
    else
    {
      std::string::size_type p=it->find('=');

      if(p==std::string::npos)
        throw "unexpected line in counterexample: "+*it;

      std::string original_variable(*it, 0, p-1);
      std::string value(*it, p+2, std::string::npos);

      while(!original_variable.empty() &&
          original_variable[0]==' ')
        original_variable.erase(0, 1);

      std::string variable=original_variable;

      unsigned thread_nr=0;
      bool thread_local=false;

      if(variable.empty())
        throw "failed to get variable name";
      else if(variable[0]=='t') // checked for emptyness above
      {
        thread_local=true;
        thread_nr=safe_str2unsigned(variable.c_str()+1);

        std::string::size_type q=original_variable.find('.');

        if(q==std::string::npos)
          throw "unexpected line in counterexample: "+*it;

        variable=std::string(original_variable, q+1, std::string::npos);

        if(variable.empty())
          throw "failed to get sub-variable name from "+original_variable;
      }

      if(variable=="PC")
      {
        thread_infos[thread_nr].PC=safe_str2unsigned(value.c_str());
        data_set=true;
      }
      else if(variable=="runs")
      {
        thread_infos[thread_nr].runs=ce_boolean(value);
        data_set=true;
      }
      else if(has_prefix(variable, "b"))
      {
        unsigned nr=safe_str2unsigned(variable.c_str()+1);
        if(nr>=abstract_model.variables.size())
          throw "invalid variable in abstract counterexample: "+
//.........这里部分代码省略.........
开发者ID:olivo,项目名称:BP,代码行数:101,代码来源:modelchecker_smv.cpp

示例2: read_counterexample_cadence_smv

void modelchecker_smvt::read_counterexample_cadence_smv(
  const std::list<std::string> &file,
  std::list<std::string>::const_iterator it,
  abstract_modelt &abstract_model,
  const threadst &threads,
  abstract_counterexamplet &counterexample)
{
  while(it!=file.end() && *it!="{")
    it++;

  if(it==file.end())
    throw "unexpected end of counterexample";

  it++;

  std::vector<smv_ce_thread_infot> thread_infos;
  thread_infos.resize(threads.size());

  {
    unsigned i=0;
    for(threadst::const_iterator t_it=threads.begin();
        t_it!=threads.end();
        t_it++, i++)
      thread_infos[i].build(inlined, *t_it);
  }

  for(; it!=file.end(); it++)
  {
    if(*it=="}")
      break; // done with the trace

    if(std::string(*it, 0, 8)!="/* state")
      throw "expected state in counterexample, but got "+*it;
      
    abstract_statet abstract_state;
    abstract_state.predicate_values.resize(
      abstract_model.variables.size());

    it++;
    if(it==file.end())
      throw "unexpected end of counterexample";

    for(; it!=file.end(); it++)
    {
      if(std::string(*it, 0, 1)=="#")
      {
        // ignore
      }
      else if(*it=="}")
      {
        // done with the state
        read_counterexample_store(
          abstract_model, counterexample, thread_infos, abstract_state);
        break;
      }
      else
      {
        std::string::size_type p=it->find('=');

        if(p==std::string::npos)
          throw "unexpected line in counterexample: "+*it;

        std::string original_variable(*it, 0, p-1);
        std::string value(*it, p+2, std::string::npos);

        while(!original_variable.empty() &&
              original_variable[0]==' ')
          original_variable.erase(0, 1);

        while(!original_variable.empty() &&
              original_variable[original_variable.size()-1]==' ')
          original_variable.erase(original_variable.size()-1, std::string::npos);

        std::string variable=original_variable;

        if(!variable.empty() && variable[0]=='\\')
          variable.erase(0, 1);

        unsigned thread_nr=0;

        if(variable.empty())
          throw "failed to get variable name";
        else if(variable[0]=='t') // checked for emptyness above
        {
          thread_nr=atoi(variable.c_str()+1);

          std::string::size_type q=original_variable.find('.');

          if(q==std::string::npos)
            throw "unexpected line in counterexample: "+*it;

          variable=std::string(original_variable, q+1, std::string::npos);

          if(!variable.empty() && variable[0]=='\\')
            variable.erase(0, 1);

          if(variable.empty())
            throw "failed to get sub-variable name from "+original_variable;
        }

//.........这里部分代码省略.........
开发者ID:olivo,项目名称:BP,代码行数:101,代码来源:modelchecker_smv.cpp


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