Learn how modifying algorithms make changes to elements in a sequence, which includes algorithms for copy, reverse, and more.
- The STL contains additional modifying algorithms…that make changes to sequences.…There are quite a few of these, so let's get started.…Here I have a working copy of modify.cpp…from Chapter six of the exercise files.…The simplest of the modifying algorithms…is the copy function.…Copy makes a copy of the source range to the target,…and so you give it a source range with begin and end…and a target begin, and when I build and run…our v1 is the prime numbers, our v2 is…filled with zeros of the same size…and then copy, copies v1 to v2.…
There's also a copy_n version, does the same thing…but instead of the end iterator,…you give it a number of items to copy.…Let's say we're going to copy 15 of these items…and you'll notice that it does exactly that.…There's a copy_backward algorithm…which does not do what you might think it does.…This copies the elements back to front,…but the result is in the original order.…So, instead of a begin point for the second container,…we give it an end point, and when we build and run…our results look exactly as they did with copy…
- 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.