zoukankan      html  css  js  c++  java
  • [STL]用法

    string:
    find()用法
     
    用find()可以,?STL的string提供七种参数形式的find(),如果你可以确定你要查找的字符串靠后或者同时有多个子字符串符合,应该使用rfind()系列或者find_last_of()系列函数来查找,STL的string提供了100个以上的操作函数,五个find()函数原型及简单说明:
    (1)size_typestring::find(charc)const;
    (2)size_typestring::find(charc,size_typeidx)const;
    (3)size_typestring::find(conststring&str)const;
    (4)size_typestring::find(conststring&str,size_typeidx)const;
    (5)size_typestring::find(constchar*cstr)const;
    (6)size_typestring::find(constchar*cstr,size_typeidx)const;
    (7)size_typestring::find(constchar*cstr,size_typeidx,size_typechars_len)const;
    说明:
    1>.以上函数如果查找失败返回string::npos,如果成功:
    函数(1)返回从头开始的第一个字符所在位置
    函数(2)返回从idx开始的第一个字符所在位置
    函数(3)返回从头开始的第一个子字符串所在位置
    函数(4)返回从idx开始的第一个子字符串所在位置
    函数(5)返回从头开始的与char*串相等的第一个子串所在位置
    函数(6)返回从idx开始的与char*串相等的第一个子串所在位置
    函数(7)返回从idx开始的与char*串前chars_len个字符相等的第一个子串所在位置
     
    substr(截取开始位置,截取长度);
     
    set:
     
    algorithm:
    find()用法
    如查找的元素存在则返回该元素的迭代器。否则返回set.end();
    删除特定元素t:
    erase(remove(a.begin(),a.end(),t),a.end());

    去除重复的元素:

    erase(unique(a.begin(),a.end()),a.end())
     
  • 相关阅读:
    逻辑思维题:称金币
    Windows7中Emacs 24 shell使用Gitbash
    Android中Touch事件分析--解决HorizontalScrollView滑动和按钮事件触发问题
    hdu 3732 Ahui Writes Word
    lucene基本原理
    elasticsearch分析系列
    主流的自动化运维工具
    IDEA在当前类中查找方法快捷键--转
    迷你MVVM框架 avalonjs 0.81发布
    最火的前端开源项目
  • 原文地址:https://www.cnblogs.com/iyjhabc/p/2987489.html
Copyright © 2011-2022 走看看