Algorithms (C++)

Algorithms often return iterators that indicate the results of the algorithms. Algorithm find, for example, locates an element and returns an iterator to that element. If the element is not found, it returns the "one past the end" iterator that was passed in to define the end of the range to be searched, which can be tested to determine whether an element was not found. Standard Libray algorithms create yet another opportunity for reuse - using the rich collection of popular algorithms can save you much time and effort.

remove, remove_if, remove_copy, remove_copy_if
The code demonstrates removing values from a sequence with algorithms remove, remove_if, remove_copy, and remove_copy_if.

Output:

replace, replace_if, replace_copy, replace_copy_if
The code demonstrates replacing values from a sequence using algorithms replace, replace_if, replace_copy, and replace_copy_if.

Output:

\\

Basic Searching and Sorting Algorithms
The code demonstrates some basic searching and sorting capabilities, including find, find_if, sort, and binary_search.

Output:

Attempting to sort a container by using an iterator other than a random-access iterator is a compilation error. Function sort requires a random_access iterator