++


includes()


template< class InputIterator1, class InputIterator2 >

bool

includes( InputIterator1 first1, InputIterator1 last1,

InputIterator2 first2, InputIterator2 last2 );

template< class InputIterator1, class InputIterator2,

class Compare >

bool

includes( InputIterator1 first1, InputIterator1 last1,

InputIterator2 first2, InputIterator2 last2,

Compare comp );

includes() , [first1,last1) [first2,last2). , , ;   - comp.

#include <algorithm>

#include <vector>

#include <iostream.h>

int main()

{

int ia1[] = { 13, 1, 21, 2, 0, 34, 5, 1, 8, 3, 21, 34 };

int ia2[] = { 21, 2, 8, 3, 5, 1 };

// includes

sort( ia1, ia1+12 ); sort( ia2, ia2+6 );

 

// : ia2 ia1?

 

bool res = includes( ia1, ia1+12, ia2, ia2+6 );

cout << " ia2 ia1? "

<< (res ? "" : "") << endl;

 

vector< int, allocator > ivect1( ia1, ia1+12 );

vector< int, allocator > ivect2( ia2, ia2+6 );

 

//

sort( ivect1.begin(), ivect1.end(), greater<int>() );

sort( ivect2.begin(), ivect2.end(), greater<int>() );

res = includes( ivect1.begin(), ivect1.end(),

ivect2.begin(), ivect2.end(),

greater<int>() );

 

// : ivect2 ivect1?

cout << " ivect2 ivect1? "

<< (res ? "" : "") << endl;

 

}




- -  - -  - -