Learn how the STL algorithm library includes a number of useful functions for operating on a range of elements in a container.
- [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 find 47,…and so if I come here and I say 47,…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.