/* -*- C++ -*- */ /************************************************************************* * Copyright(c) 1995~2005 Masaharu Goto (root-cint@cern.ch) * * For the licensing terms see the file COPYING * ************************************************************************/ #include #include #include #include #include "sample.dll" #include template class disp { public: void operator()(T& x) { cout << x << " " ; } }; test1() { vector a; for(float i=0;i<5;i++) a.push_back(i); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; reverse(a.begin(),a.end()); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; } test2() { list a; for(float i=0;i<5;i++) a.push_back(i); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; reverse(a.begin(),a.end()); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; } test3() { map x; //map x; x["PI"]=3.1415; x["a"]=1.234; cout << x["PI"] << " " ; cout << x["a"] << " " ; cout << endl; } test4() { string name="Masaharu"; string family; family="Goto"; cout << name << " " << family << endl; } test5() { deque a; for(float i=0;i<5;i++) a.push_back(i); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; reverse(a.begin(),a.end()); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; } test6() { bitset<8> a; } test7() { set a; //for(float i=0;i<5;i++) a.push_back(i); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; reverse(a.begin(),a.end()); for_each(a.begin(),a.end(),disp()); cout << endl; for_each(a.rbegin(),a.rend(),disp()); cout << endl; } ostream& operator<<(ostream& ost,fvector& a) { ost << "size=" << a.size() << " : "; for_each(a.begin(),a.end(),disp()); cout << endl; } test8() { fvector vec; vector vecvec; for(float j=0;j<3;j++) { for(float i=0;i()); cout << endl; } main() { test1(); test2(); test3(); test4(); test5(); //test6(); //test7(); test8(); }