Javatpoint Logo
Javatpoint Logo

C++ Algorithm Function find_if_not()

C++ Algorithm find_if_not()function returns the value of the first element in the range for which the pred value is false otherwise the last element of the range is given.

Syntax

Parameter

first: It specifies the first element of the range.

last: It specifies the last element of the range.

pred: It is usually a unary function for which the range values are checked to return a boolean answer.

Return value

The function returns an iterator to the first element of the range for which the pred value is false. If no such element is found, then the function returns the last element.

Example 1

Output:

In the range given the very first even value is 6

Example 2

Output:

Out of the given elements, first odd element is 20
Out of the given elements, first odd element is 35

Complexity

The function moves in a linear way, starting from the first element going towards the last one. For each element of the list value of 'pred' is checked. The search goes on until a mismatch for the 'pred' value is encountered.

Data races

Either all the objects in the specified range or some of them are accessed by the function.

Exceptions

The function throws an exception if any of the argument throws one.






Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA