From the course: C++ Templates and the STL
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
About STL algorithms - C++ Tutorial
From the course: C++ Templates and the STL
About STL algorithms
- [Instructor] The algorithm header has a number of useful template functions for operating on a range of elements. Here I have a working copy of algorithm.cpp from chapter six of the exercise files. The functions in the algorithm header are varied and we'll get into the details later in this chapter. For now, I just wanted to take a look at a couple of them to give you an idea of what's going on here. So the algorithm functions are in the algorithm header and here we have a vector of prime numbers, less than a hundred out of order so that we can sort them. Here is a sort function from the algorithm header and there's also a binary search function from the algorithm header and so when I build and run, you'll see that the sort function sorts these prime numbers into order and the binary search function is looking for the number 42 which we know is not a prime number. There's only one even prime number and that's the number two. So it's not going to find 42. On the other hand it will…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.