Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

find_end


Algorithm

Summary

Finds the last occurrence of a sub-sequence in a sequence.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

None

Synopsis

#include <algorithm>

template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1 find_end(ForwardIterator1 first1, 
                          ForwardIterator1 last1,
                          ForwardIterator2 first2, 
                          ForwardIterator2 last2);
template <class Forward Iterator1, class ForwardIterator2, 
          class BinaryPredicate>
  ForwardIterator1 find_end(ForwardIterator1 first1, 
                            ForwardIterator1 last1,
                            ForwardIterator2 first2,
                            ForwardIterator2 last2,
                            BinaryPredicate pred);

Description

The find_end algorithm finds the last occurrence of a sub-sequence, indicated by [first2, last2), in a sequence, [first1,last1). The algorithm returns an iterator pointing to the first element of the found sub-sequence, or last1 if no match is found.

More precisely, the find_end algorithm returns the last iterator i in the range [first1, last1 - (last2-first2)) such that for any non-negative integer n < (last2-first2), the following corresponding conditions hold:

Or returns last1 if no such iterator is found.

Two versions of the algorithm exist. The first uses the equality operator as the default binary predicate, and the second allows you to specify a binary predicate.

Complexity

At most (last2-first2)*(last1-first1-(last2-first2)+1) applications of the corresponding predicate are done.

Example

Program Output

Warnings

If your compiler does not support default template parameters, then you always need to supply the Allocator template argument. For instance, you have to write:

vector<int, allocator<int> >

instead of:

vector<int>

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

Algorithms, find, find_if, adjacent_find



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998