zoukankan      html  css  js  c++  java
  • C++字符串按照指定规则切割的功能模板类,常用的一段检测记录运行时间的代码

    template <typename T>

    struct vector_split

    {

        typedef typename std::vector<T>::iterator its;

         void operator()(std::vector<T>& data,std::vector<T>& seprate,std::vector<its>& result)

         {

            std::vector<int> ab;

            

            its ini;

            result.clear();

            its i=data.begin(),itend=data.end();

             its first=ini,second=ini;

            its aim_f =seprate.begin(),aim_e=seprate.end();

            while(i!=itend)

            {

                

                while(i!=itend &&

                      (std::find_if(aim_f, aim_e, [&](const T& T_va){return T_va == *i;})!=aim_e)

                      ) ++i;

                first=i;

                while(i!=itend &&

                      (std::find_if(aim_f, aim_e, [&](const T& T_va){return T_va == *i;})==aim_e)

                      ) ++i;

                second=--i;++i;

                

                if(first!=ini && first !=itend){

                    result.push_back(first);

                    result.push_back(second);

                   first =ini;second=ini;

                }

     

            }

     

        }

    };

    auto start = std::chrono::high_resolution_clock::now();

     

    //耗时操作

     

    auto stop = std::chrono::high_resolution_clock::now();

     

    auto time_consume=stop-start;

    std::cout<<j<<" computing time  :"<<time_consume.count()<<"mileseconds"<<std::endl;

  • 相关阅读:
    使用 libevent 和 libev 提高网络应用性能
    An existing connection was forcibly closed by the remote host
    各种浏览器的兼容css
    vs输出窗口,显示build的时间
    sass
    网站设置404错误页
    List of content management systems
    css footer not displaying at the bottom of the page
    强制刷新css
    sp_executesql invalid object name
  • 原文地址:https://www.cnblogs.com/sofard/p/10450808.html
Copyright © 2011-2022 走看看