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;

  • 相关阅读:
    2、容器初探
    3、二叉树:先序,中序,后序循环遍历详解
    Hebbian Learning Rule
    论文笔记 Weakly-Supervised Spatial Context Networks
    在Caffe添加Python layer详细步骤
    论文笔记 Learning to Compare Image Patches via Convolutional Neural Networks
    Deconvolution 反卷积理解
    论文笔记 Feature Pyramid Networks for Object Detection
    Caffe2 初识
    论文笔记 Densely Connected Convolutional Networks
  • 原文地址:https://www.cnblogs.com/sofard/p/10450808.html
Copyright © 2011-2022 走看看