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;

  • 相关阅读:
    基于ROS-Unity的移动机器人虚实交互场景构建方法的研究
    ROS连接ABB机械臂调试详细教程-ROS(indigo)和ABB RobotStudio 6.03.02-
    ROS#资讯汇总(ROS、C#、.NET和Unity3D)
    论文阅读:A review and comparison of ontology-based approaches to robot autonomy ALBERTO
    商业RDF三元组数据库AllegroGraph
    Qt编写的项目作品30-录音播放控件(雨田哥作品)
    Qt编写的项目作品29-RTSP播放器+视频监控(海康SDK版本)
    Qt编写的项目作品28-RTSP播放器+视频监控(mpv版本)
    Qt音视频开发23-通用视频控件
    Qt音视频开发22-通用GPU显示
  • 原文地址:https://www.cnblogs.com/sofard/p/10450808.html
Copyright © 2011-2022 走看看