Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

C++ Tutorial

C++ HOME C++ Intro C++ Get Started C++ Syntax C++ Output C++ Comments C++ Variables C++ User Input C++ Data Types C++ Operators C++ Strings C++ Math C++ Booleans C++ If...Else C++ Switch C++ While Loop C++ For Loop C++ Break/Continue C++ Arrays C++ Structures C++ Enums C++ References C++ Pointers

C++ Functions

C++ Functions C++ Function Parameters C++ Function Overloading C++ Scope C++ Recursion

C++ Classes

C++ OOP C++ Classes/Objects C++ Class Methods C++ Constructors C++ Access Specifiers C++ Encapsulation C++ Inheritance C++ Polymorphism C++ Files C++ Exceptions C++ Date

C++ Data Structures

C++ Data Structures & STL C++ Vectors C++ List C++ Stacks C++ Queues C++ Deque C++ Sets C++ Maps C++ Iterators C++ Algorithms

C++ How To

C++ Add Two Numbers C++ Random Numbers

C++ Reference

C++ Reference C++ Keywords C++ <iostream> C++ <fstream> C++ <cmath> C++ <string> C++ <cstring> C++ <ctime> C++ <vector> C++ <algorithm>

C++ Examples

C++ Examples C++ Real-Life Examples C++ Compiler C++ Exercises C++ Quiz C++ Syllabus C++ Study Plan C++ Certificate


C++ algorithm Library


C++ algorithm Library

The <algorithm> library has many functions that allow you to modify ranges of data from data structures.

A list of useful functions in the algorithm library can be found below.

Function Description
adjacent_find() Finds a pair of consecutive elements with the same value in a data range
all_of() Checks if all of the elements in a data range match a condition
any_of() Checks if at least one element in a data range matches a condition
binary_search() An efficient algorithm for finding if a value exists in a sorted data range
copy() Copies the values from a data range into a different data range
count() Counts the number of times that a value occurs in a data range
count_if() Counts the number of elements in a data range that match a condition
fill() Writes a value into every element of a data range
find() Finds the first element of a data range with a specified value
find_first_of() Finds the first element of a data range which matches one of several specified values
find_if() Finds the first element of a data range which matches a condition
find_if_not() Finds the first element of a data range which does not match a condition
for_each() Runs a function on every element in a data range
includes() Checks if all of the values in a sorted data range exist in another sorted data range
is_permutation() Checks if a data range is a permutation of another
is_sorted() Checks if a data range is sorted
is_sorted_until() Finds the position in a data range at which elements are no longer sorted
lower_bound() Finds the first element at or above a specified lower bound in a sorted data range
max_element() Finds the element with the highest value in a data range
merge() Merges the values of two data ranges into a new data range
min_element() Finds the element with the lowest value in a data range
none_of() Checks if none of the elements in a data range match a condition
random_shuffle() Randomly rearranges the elements in a data range
replace() Replaces all occurrences of a value in a data range with a different value
replace_copy() Creates a copy of a data range with all occurrences of a specified value replaced with a different value
replace_copy_if() Creates a copy of a data rage where all values that match a condition are replaced with a different value
replace_if() Replaces all values in a data range that match a condition with a different value
reverse() Reverses the order of elements in a data range
reverse_copy() Creates a copy of a data range with the elements in reverse order
search() Finds a specified sequence of values in a data range
sort() Sorts the values of a data range in ascending order
swap() Swaps the values of two variables
swap_ranges() Swaps the values of two data ranges of the same size
upper_bound() Finds the first element above a specified upper bound in a sorted data range

Learn more about algorithms in our C++ Algorithm Tutorial.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.