C++ Algorithm Function equal()C++ Algorithm equal()function compares the elements in both the containers and returns a true value if all the elements in both the containers are found to be matching. The first range is from [first1,last1) and the second starts from first2. SyntaxParameterfirst1: It is an input iterator to the first element of the [first1, last1). last1: It is an input iterator to the last element of the [first1, last1). first2: It is an input iterator to the first element of the [first2, last2). pred: It is a binary function that accepts two elements as arguments and performs the task designed by the function. Return valueThe function returns the value true if all the elements in both the containers match, otherwise it returns false. Example 1Output: Both the containers have matching elements. Both the containers do not have equal elements. Example 2Output: The vector consists of: 10, 20,30,40,50 Both the containers have equal elements. ComplexityThe function has linear complexity from the first1 element to the last1 element. Data racesObjects in both ranges are accessed. ExceptionsThe function throws an exception if any of the argument throws one. Next TopicC++ Algorithm find Function |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India