zoukankan      html  css  js  c++  java
  • 第十一章 泛型算法 C++ PRIMER

    vector<int>::const_iterator result = find(vector.begin(). vector.end(),search_value); 如果查找失败,分会end()  如果有两个,会返回哪一个的迭代器?

    int *reauslt = find(ia,ia+6,search_value); 也可以同样处理字符串

    算法要以<algorithm><numeric>,依赖于迭代器和迭代器的算法实现,算法可能改变值,可能移动元素,单从不直接添加或者删除元素

    int sum = accumulate(vec.begin(),vec.end(),42); 最后一个参数是必须的,因为accumulate并不知道叠加的类型     在程序中直接写一个“12345”,系统认为string 还是 char*, 是不是const ?

    fill(vec.begin().vec.end(),0); 在指定范围内插入第三个参数

    unique函数也不改变迭代器的大小,只是将重复的放到了后面

    vector<string>::iterator end_unique = unique(words.begin(),words.end());

    words.erase(end_unique,words.end()); ////这个erase还是要好好看看的

    stable_sort(words.begin(),words.end(),isshorter);

    swap();的用法,我还没有找到,应该好好找找

    后面高级点的迭代器没有看,第一遍,千万不要太贪

    berkeleysong
  • 相关阅读:
    Direct2D Simple
    波动+灰度图+噪点的简单实现
    控制台和窗口应用程序转换
    read from plist file
    1366X768成为全球最流行屏幕分辨率
    游戏框架类
    Animation in Cocos2diphone
    透射
    11.20
    11.19
  • 原文地址:https://www.cnblogs.com/berkeleysong/p/3735170.html
Copyright © 2011-2022 走看看