Translations of this page?:

find_end

Syntax:

    #include <algorithm>
    forward_iterator find_end( forward_iterator start, forward_iterator end, forward_iterator2 seq_start, forward_iterator2 seq_end );
    forward_iterator find_end( forward_iterator start, forward_iterator end, forward_iterator2 seq_start, forward_iterator2 seq_end, BinPred bp );

The find_end() function searches for the sequence of elements denoted by seq_start and seq_end. If such a sequence is found between start and end, an iterator to the first element of the last found sequence is returned. If no such sequence is found, an iterator pointing to end is returned.

If the binary predicate bp is specified, then it is used to when elements match.

For example, the following code uses find_end() to search for two different sequences of numbers. The the first chunk of code, the last occurence of “1 2 3” is found. In the second chunk of code, the sequence that is being searched for is not found:

   int nums[] = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 };
   int* result;
   int start = 0;
   int end = 11;
 
   int target1[] = { 1, 2, 3 };
   result = find_end( nums + start, nums + end, target1 + 0, target1 + 3 );
   if( *result == nums[end] ) {
     cout << "Did not find any subsequence matching { 1, 2, 3 }" << endl;
   } else {
     cout << "The last matching subsequence is at: " << *result << endl;
   }
 
   int target2[] = { 3, 2, 3 };
   result = find_end( nums + start, nums + end, target2 + 0, target2 + 3 );
   if( *result == nums[end] ) {
     cout << "Did not find any subsequence matching { 3, 2, 3 }" << endl;
   } else {
     cout << "The last matching subsequence is at: " << *result << endl;
   }

Related Topics: adjacent_find, find, find_first_of, find_if, search_n

 
• • • IndexRecent changesRSScc