stl库学习
楚江课的救赎
这个作者很懒,什么都没留下…
展开
-
stl库remove()学习
我将从remove的复习开始这个条款,因为remove是STL中最糊涂的算法。误解remove很容易,驱散所有关于remove行为的疑虑——为什么它这么做,它是怎么做的——是很重要的。这是remove的声明:templateForwardIterator remove(ForwardIterator first, ForwardIterator last, const T&转载 2013-01-24 11:08:11 · 698 阅读 · 0 评论 -
stl 对vector存对象
#include #include #include #include #include using namespace std;class fun1{ int a; int b; public: fun1(int x,int y):a(x),b(y){} int get_x(){return a;} int get_y(){retur原创 2013-03-04 23:24:16 · 691 阅读 · 0 评论 -
stl实现计数存对象,实现更高形式的抽象
#include #include #include #include #include using namespace std;class fun{private:int a;int b;public: fun(int x=0,int y=0){a=x;b=y;} bool operator==(fun &a){if(this->a==a.a&&t原创 2013-03-06 13:10:07 · 754 阅读 · 0 评论 -
stl的排序 和 用算法实现的排序比较
#include#include#include#include#include#include#includeusing namespace std;templatevoid swap1(Type &a,Type &b){ Type temp=a; a=b; b=temp;}templatevoid Perm(Ty原创 2013-03-09 00:46:43 · 880 阅读 · 0 评论 -
深度拷贝的重要性
#include #include #include using namespace std; class CDemo { public: CDemo():str(Null){}; ~CDemo() { if(str) delete[] str; };转载 2013-04-07 00:04:22 · 2137 阅读 · 0 评论 -
map初始化
#include #include using namespace std;using std::map;int main(){ map > myMap; cout myMap.insert (std::make_pair('a',std::make_pair(120,230))); cout std::pair &原创 2013-03-22 21:20:36 · 1420 阅读 · 0 评论 -
map<string,int>
#include #include #include #include #include using namespace std;void main(){ typedef map::iterator mit; map ma; mit it; ifstream in("in.txt"); int c=0; string str; string st; while(原创 2013-04-10 18:42:59 · 3678 阅读 · 0 评论 -
it=ilist.erase(it);笔记
#include#include#includeusing namespace std;int main(){ int ia[] = { 0, 1, 1, 2,2, 3, 5, 8, 13, 21, 55, 89 }; vectorint> ivec; listint> ilist; for( int原创 2013-07-27 13:05:50 · 993 阅读 · 0 评论 -
stl中的remove返回的是什么
我将从remove的复习开始这个条款,因为remove是STL中最糊涂的算法。误解remove很容易,驱散所有关于remove行为的疑虑——为什么它这么做,它是怎么做的——是很重要的。这是remove的声明:templateForwardIterator remove(ForwardIterator first, ForwardIterator last, const T&转载 2014-06-06 11:44:43 · 719 阅读 · 0 评论