Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

adjacent_find()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

An algorithm that finds the first adjacent pair of equivalent elements in a sequence

Synopsis

#include <algorithm>

namespace std {
  template <class ForwardIterator>
    ForwardIterator
    adjacent_find(ForwardIterator start, 
                  ForwardIterator finish);

  template <class ForwardIterator, class BinaryPredicate>
    ForwardIterator
    adjacent_find(ForwardIterator start, 
ForwardIterator finish, BinaryPredicate binary_pred); }

Description

There are two variations of the adjacent_find() algorithm. The first finds equal adjacent elements in the sequence defined by iterators start and finish and returns an iterator i pointing to the first of the equal elements. The second variation lets you specify a binary function object to test for a condition. The algorithm returns an iterator i pointing to the first of the pair of elements that meet the conditions of the binary function. In other words, adjacent_find() returns the first iterator i where both i and i + 1 are in the range [start, finish) that meets one of the following conditions:

*i == *(i + 1)

or

binary_pred(*i,*(i + 1)) == true

If adjacent_find() does not find a match, it returns finish.

Complexity

adjacent_find() performs exactly find(start,finish,value) - start applications of the corresponding predicate.

Example

See Also

find()

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 25.1.5



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.