Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

equal()

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