?? chapter9-1.cpp
字號:
//文件名:CHAPTER9-1.cpp
#include <set>
#include <iostream>
#if _MSC_VER > 1020 // if VC++ version is > 4.2
using namespace std; // std c++ libs implemented in std
#endif
int main( )
{
set <int>::iterator s1_Iter, s2_Iter, s3_Iter, s4_Iter, s5_Iter, s6_Iter;
// Create an empty set s0 of key type integer
set <int> s0;
// Create an empty set s1 with the key comparison
// function of less than, then insert 4 elements
set <int, less<int> > s1;
s1.insert( 10 );
s1.insert( 20 );
s1.insert( 30 );
s1.insert( 40 );
// Create an empty set s2 with the key comparison
// function of geater than, then insert 2 elements
set <int, greater<int> > s2;
s2.insert(10);
s2.insert(20);
// Create a set s3 with the
// allocator of set s1
set <int>::allocator_type s1_Alloc;
s1_Alloc = s1.get_allocator( );
set <int> s3( less<int>( ), s1_Alloc );
s3.insert( 30 );
// Create a copy, set s4, of set s1
set <int> s4( s1 );
// Create a set s5 by copying the range s1[_First, _Last)
set <int>::const_iterator s1_bcIter, s1_ecIter;
s1_bcIter = s1.begin( );
s1_ecIter = s1.begin( );
s1_ecIter++;
s1_ecIter++;
// set <int> s5( s1_bcIter, s1_ecIter );
// Create a set s6 by copying the range s4[_First, _Last)
// and with the allocator of set s2
set <int>::allocator_type s2_Alloc;
s2_Alloc = s2.get_allocator( );
// set <int> s6( s4.begin( ), ++s4.begin( ), less<int>( ), s2_Alloc );
cout << "s1 =";
for ( s1_Iter = s1.begin( ); s1_Iter != s1.end( ); s1_Iter++ )
cout << " " << *s1_Iter;
cout << endl;
cout << "s2 = " << *s2.begin( ) << " " << *++s2.begin( ) << endl;
cout << "s3 =";
for ( s3_Iter = s3.begin( ); s3_Iter != s3.end( ); s3_Iter++ )
cout << " " << *s3_Iter;
cout << endl;
cout << "s4 =";
for ( s4_Iter = s4.begin( ); s4_Iter != s4.end( ); s4_Iter++ )
cout << " " << *s4_Iter;
cout << endl;
/* cout << "s5 =";
for ( s5_Iter = s5.begin( ); s5_Iter != s5.end( ); s5_Iter++ )
cout << " " << *s5_Iter;
cout << endl;
cout << "s6 =";
for ( s6_Iter = s6.begin( ); s6_Iter != s6.end( ); s6_Iter++ )
cout << " " << *s6_Iter;
cout << endl;*/
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -