Learn how a bidirectional iterator will access a sequence container in either direction. It's like a forward iterator that can also go backward.
- [Instructor] The bidirectional iterator…may be used to access the sequence of a container…in either direction.…Here I have a working copy of bidi-iterator.cpp,…where bidi stands for bidirectional,…from chapter three of the exercise files.…The set container type uses a bidirectional iterator.…It can be iterated either forward or backward.…And so here we have a set, we've initialized it…with integers from one through 10,…and we have an iterator object for the set,…and you'll notice I have a simple for loop.…
An interesting thing about the end member function…in all of these containers that have an end…member function is that it returns an iterator…that points past the end, and it does that specifically…so that these for loops work the way that you expect.…But when we're iterating backward,…it does not do what we expect,…because this end is past the end,…and begin is not past the beginning,…it's right at the beginning, and so what we need to do here,…we can't put our decrement in that continue space…in the for loop, rather we have to put it in our cout,…
- 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.