


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



vector< int > iseq1;
vector< double > iseq2( 10, -1 );
vector< double >( 10, 50 );
pair< string, int > myPair( "up", 15 );
pair< double, int >( 3.14, 7 ); // Types given explicitly make_pair( 3.14, 7 ); // Types inferred by the compiler.
vector< pair< string, double > > pseq( 100, make_pair( string("height"), -1.0 ) );
vector< vector< int > > matrix1;
vector< vector< int > > matrix2( 10, vector< int >( 20, 3 ) );
vector< int >::iterator pos;
iseq1.size()
matrix2.size()
matrix2[ 0 ].size()
iseq2.front()
iseq2.back()
iseq1.begin()
iseq1.end()
iseq2[ 5 ]
matrix2[ 7 ]
matrix2[ 7 ][ 3 ]
iseq1.begin() + 5
myPair.first
myPair.second
// Using integer index for ( unsigned int i = 0; i < iseq1.size(); i++ ) cout << iseq1[ i ] << endl;
// Using iterators for ( vector< int > :: iterator pos = iseq1.begin(); pos != iseq1.end(); pos++ ) cout << *pos << endl;
sort( iseq2.begin(), iseq2.end() );
sort( pseq.begin(), pseq.end() );
// Return true if a should come before b bool myComparison( pair< string, double > const &a, pair< string, double > const &b ) { if ( a.first.length() < b.first.length() ) return true; if ( b.first.length() < a.first.length() ) return false;
return a.second < b.second; }
sort( pseq.begin(), pseq.end(), myComparison );
find( iseq1.begin(), iseq1.end(), 5 )
reverse( iseq2.begin(), iseq2.end() );