C++ Algorithm Functions search_n()
C++ Algorithm search_n() function searches the container [first,last) for the occurrence of a sequence of count elements, that is every element is searched to check whether it satisfies a given pred. An iterator to first element satifisying the condition is returned, else an iterator to last is returned.
first: It is a forward iterator to the first element of the range, where the element itself is included in the range.
last: It is a forward iterator to the last element of the range, where the element itself is not included in the range.
count: It gives the least number of elements that are supposed to be matching a condition.
val: The argument specifies the conditional value or the pred condition for which the function search_n is applied on a range.
pred: It is a Binary function that accepts two arguments, and gives a boolean result.
The function returns an iterator to the first element which matches the pred, if no such element is found then an iterator to the last element is returned.
Two times 60 has been at position 2
Value u2 has been found at position 5
The complexity of the function is linear starting from the first element to the last one.
Some or all of the container objects are accesed.
The function throws an exception if any of the container elements throws one.