Join Eduardo Corpeño for an in-depth discussion in this video Vector insertion, part of C++ Standard Template Library.
- [Lecturer] We are now ready to write the remaining…rounds of element insertion.…Now it's the push front round's turn.…Since it uses the exact same structure…as the push back round,…let me copy that part of the code.…Let's remember to re-initialize…the value variable here at line 29.…I will also change the message at line 30…from pushing back to pushing front.…
And the only line t hat really needs…to be modified is line number 35…where we'll need to push at the front…rather than at the back of the vector.…Now notice that vector does not have…a push front function.…So we'll use the insert function instead.…This function is widely overloaded…just as most functions in large libraries.…We're interested in the version that receives…an iterator to access the position…where you want the value to be inserted,…and the value itself.…
Since we want to push to the front…we'll call the insert function to push…into the beginning of the vector.…So that's one example where the begin function is useful…because it will provide the iterator…
- Why the STL is important
- Containers and iterators
- Vectors and lists
- Stacks and dequeues
- Associative containers
Skill Level Advanced
1. The Standard Template Library
2. Vectors and Lists
3. Stacks, Queues, and Deques
4. Associative Containers
- 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.