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

equal()

Module:  Standard C++ Library   Library:  Algorithms


Function

Local Index

No Entries

Summary

Algorithm that compares two ranges of values for equality

Synopsis

#include <algorithm>

namespace std {
  template <class InputIterator1, class InputIterator2>
  bool equal(InputIterator1 start1, InputIterator1 finish1,
             InputIterator2 start2);

 template <class InputIterator1, class InputIterator2,
           class BinaryPredicate>
 bool equal(InputIterator1 start1, InputIterator1 finish1,
            InputIterator2 start2, BinaryPredicate
            binary_pred);
}

Description

The equal() algorithm does a pairwise comparison of all of the elements in one range with all of the elements in another range to see if they match. The first version of equal() uses operator==() as the comparison function, and the second version allows you to specify a binary predicate as the comparison function. The first version returns true if all of the corresponding elements are equal to each other. The second version of equal() returns true if for each pair of elements in the two ranges, the result of applying the binary predicate is true. In other words, equal() returns true if both of the following are true:

If one of these conditions is not true, equal() returns false.

This algorithm assumes that all iterators in the range [start2, start2 + (finish1 - start1)] are dereferenceable.

Complexity

equal() performs at most finish1 - start1 comparisons or applications of the predicate.

Example

Standards Conformance

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



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.