C++ STL疑惑知识点

 

 1.remove的问题

用法参考:http://www.cnblogs.com/heyonggang/p/3263568.html

 

 

 

参考:http://zhidao.baidu.com/question/458494170.html

 

 

 

 

 

2.用find搜索数组中是否存在某个值

参考:http://www.cnblogs.com/heyonggang/p/3241789.html

由于指针的行为与作用在内置数组上的迭代器一样,因此也可以使用find来搜索数组

复制代码
1 int ia[6] = {27 , 210 , 12 , 47 , 109 , 83};
2 int search_value = 83;
3 int *result = find(ia , ia + 6 , search_value);
4 cout<<"The value "<<search_value
5     <<(result == ia + 6 ? " is not present" : "is present")
6     <<endl;
复制代码

如果需要传递一个子区间,则传递指向这个子区间的第一个元素以及最后一个元素的下一位置的迭代器(或指针)。

例如,在下面对find函数的调用中,只搜索了ia[1]和ia[2]:

复制代码
//only search elements ia[1] and ia[2]
int *result = find(ia + 1 , ia + 3 , search_value);
复制代码
posted on 2013-08-17 15:08  猿人谷  阅读(577)  评论(0编辑  收藏  举报