C++.


find_first_of()


template< class ForwardIterator1, class ForwardIterator2 >

ForwardIterator1

find_first_of( ForwardIterator1 first1, ForwardIterator1 last1,

ForwardIterator2 first2, ForwardIterator2 last2 );

template< class ForwardIterator1, class ForwardIterator2,

class BinaryPredicate >

ForwardIterator1

find_first_of( ForwardIterator1 first1, ForwardIterator1 last1,

ForwardIterator2 first2, ForwardIterator2 last2,

BinaryPredicate pred );

, [first2,last2), , , [first1,last1). , synesthesia. aeiou. find_first_of()

, , e. , last1. , , pred.

#include <algorithm>

#include <vector>

#include <string>

#include <iostream.h>

 

int main()

{

string s_array[] = { "Ee", "eE", "ee", "Oo", "oo", "ee" };

 

// "ee" -- &s_array[2]

string to_find[] = { "oo", "gg", "ee" };

string *found_it =

find_first_of( s_array, s_array+6,

to_find, to_find+3 );

// :

// : ee

// &s_array[2]: 0x7fff2dac

// &found_it: 0x7fff2dac

 

if ( found_it != &s_array[6] )

cout << ": " << *found_it << "\n\t"

<< "&s_array[2]:\t" << &s_array[2] << "\n\t"

<< "&found_it:\t" << found_it << "\n\n";

vector< string, allocator > svec( s_array, s_array+6);

vector< string, allocator > svec_find( to_find, to_find+2 );

// "oo" -- svec.end()-2

vector< string, allocator >::iterator found_it2;

 

found_it2 = find_first_of(

svec.begin(), svec.end(),

svec_find.begin(), svec_find.end(),

equal_to<string>() );

 

// :

// : oo

// &svec.end()-2: 0x100067b0

// &found_it2: 0x100067b0

 

if ( found_it2 != svec.end() )

cout << " : " << *found_it2 << "\n\t"

<< "&svec.end()-2:\t" << svec.end()-2 << "\n\t"

<< "&found_it2:\t" << found_it2 << "\n";

}