Learn how the conditional algorithms test a range of elements against a Boolean function. Tests are provided for all-of, any-of, or none-of elements.
- [Instructor] The STL has a few simple algorithms…for testing conditions on ranges of elements.…Here I have a working copy of conditional dot CPP…from chapter six of the exercise files.…These conditional algorithms use a predicate function…and so I here have a function called is prime,…a template function that takes one argument…so it's a unary predicate, and when I come down here…into main, you see I have a vector of ints…containing a list of prime numbers under 100.…
And then we have this all of function, which is from…the algorithm header, which tests all of the elements…in a container against a predicate and in this case,…it's testing if they are prime numbers,…and it returns true or false.…And when I build and run, of course my list of prime numbers…are all prime, but if I were to come in here…and add another one, say 40, which is not a prime number.…And when I build and run, it says false.…
Course, these don't need to be in order.…I can put that wherever I want and it will still…test it accurately, and it says…
- 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.