算法库(二)
来源:互联网 发布:用友软件温州总代理 编辑:程序博客网 时间:2024/05/18 11:49
1. remove:删除区间指定的值的元素.(这里并不缩小区间大小)
2. distance:计算区间元素的个数(对非顺序容器)
list<int> int_lst;
for ( int i = 0;i <= 7;i ++ )
{
int_lst.push_back( i );
int_lst.push_front( i );
}
//print list
cout<<"printlist\n";
copy(int_lst.begin(),int_lst.end(),ostream_iterator<int>(cout,"\n" ) );
list<int>::iteratoriterRemove = remove( int_lst.begin(),int_lst.end(),2 );
cout<<"removelist print\n";
copy(int_lst.begin(),int_lst.end(),ostream_iterator<int>(cout,"\n" ) );
cout<<"begin-removeiterator\n";
copy(int_lst.begin(),iterRemove,ostream_iterator<int>(cout,"\n" ) );
cout<<"removeelement counts:"<<distance( iterRemove,int_lst.end() );
输出结果:
print list
7
6
5
4
3
2
1
0
0
1
2
3
4
5
6
7
remove list print
7
6
5
4
3
1
0
0
1
3
4
5
6
7
6
7
begin-remove iterator
7
6
5
4
3
1
0
0
1
3
4
5
6
7
remove element counts:2请按任意键继续. . .
- 算法库(二)
- 算法二
- 算法二
- 算法二
- 算法二
- STL算法库-数字运算(二)
- 第三周项目二 建立算法库
- 第四周项目二 单链表算法库
- 项目二 建立链队算法库
- 【算法导论】排序算法 二
- 算法二:变动性算法
- STL算法---查找算法(二)
- STL算法---排序算法(二)
- 算法二(贪心算法)
- 算法学习(二) 贪婪算法
- 算法尝试(二)
- 二、图论算法
- STL算法之二
- linux C编程中EOF宏和feof函数的用法
- Windows下编译libevent
- 【redhat5.5】linux的LDAP认证服务器的配置及客户端pam网络验证实例
- ffmpeg分布式转码可行性构想
- java 制作图片水印
- 算法库(二)
- simhash与重复信息识别
- android 获取手机GSM/CDMA信号信息
- 移动开发中HTML5能否替代本地程序?
- Ollydbg 中断方法浅探
- problem 16 高精度乘法
- 算法库(三)
- 项目中用转dojox.grid.DataGrid的几点必知
- 算法库(四)