![]() |
VOOZH | about |
std::equal() helps to compares the elements within the range [first_1,last_1) with those within range beginning at first_2. Syntax 1:
template bool equal (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2) first_1, last_1 : Initial and final positions of the first sequence. All the elements are present within a range [first_1,last_1) first2 : Initial position of the second sequence. Returns : true, if all of the elements in both ranges match; otherwise false
Output:
Vector contains : 10, 20, 30, 40, 50 The contents of both sequences are equal.
Syntax 2:
template bool equal (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred); first_1, last_1 : Initial and final positions of the first sequence. All the elements are present within a range [first_1,last_1) first2 : Initial position of the second sequence. pred : Binary function that accepts two elements as argument and returns a value convertible to boolean. Returns : true, if all of the elements in both ranges match; otherwise false
Output:
Vector contains : 10, 20, 30, 40, 50 The contents of both sequences differ.
Time complexity: O(n)
Related Articles: