Map, filter, and reduce are three functional methods that are used to transform data in most popular programming languages, but they don't exist in C++ or its libraries or do they? Troy shows us how to implement these function in the STL in this video.
- [Instructor] Many languages, libraries, and databases…have three important methods:…map, filter, and reduce.…At first glance, C++ seems to be lacking these functions.…And that surprises some developers,…but the STL does have something close.…If you wish to map over a collection,…transform or for_each are your replacements.…If you wish to remove or keep items in a collection,…then copy_if or remove_if are what you're looking for.…
And finally, if you need to reduce a collection…to a scalar, try accumulate.…These functions are not immutable,…but they work with all kinds of collections.…Let's take a look at some code.…Our sample begins with two lambda expressions.…So here we have header.…And here we have render.…And these are just little helper functions…to make the output look a little nicer.…Then we have a collection called inCollection,…and it's just got some numbers in there.…
And what we're going to do is transform.…Now transform is similar to map,…it allows you to go over a collection…and modify all the elements in a collection.…
- Major new C++ features
- Turning on modern C++
- Letting the compiler help
- Using the new features correctly
- Using auto type deduction
- Using lambdas
- Range-based for loops
- How C++ and the Standard Template Library name things
- Making the best of the filesystem library
- Managing objects
Skill Level Beginner
1. What Is Modern C++?
2. Tools That Improve Your Code
3. Using the New Features Correctly
4. Don't Reinvent the Wheel
5. Managing Objects
- 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.