Learn how a random access iterator can access any element at any position in the container. It also has the capabilities of all the other iterators.
- [Instructor] The random access iterator…is the most complete iterator of 'em all.…It may be used to access any element at any position…in a container.…This iterator offers all of the functionality…of a C pointer.…Here I have a working copy of ra-iterator.cpp…where ra stands for random access.…From chapter three of the exercise files,…here we'll be using the vector container…because it's a container that allows random access…and uses a random access iterator.…
Here I construct a vector of ints…with 10 elements, one through 10,…and a iterator object from the vector of ints class.…And of course, this iterator can do everything…a forward iterator can do.…It can do everything a bidirectional iterator can do.…The range-based for loop works.…All of that works plus we may access elements directly.…So, here I take an iterator, I set it to begin…and I add five to it and it will get us the element…at zero plus five position.…
Which would be, if this is zero, one, two, three,…four, five, it would be the number six.…And when I build and run,…
- 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.