Learn about sets and how they differ from the rest of containers covered so far.
- [Instructor] We are now ready to talk about sets.…Recall that a set is an associative container,…which means that it addresses its elements by content…rather than by location or index.…We'll do this demo the usual way…we've been doing the previous demos,…this time with one round of insertions…and one round of deletions.…The part that makes this demo special…is that we'll see all four different variants…of the set container by only changing its declaration.…
Recall that a set can be either ordered or unordered,…and it can also either accept duplicates or not.…We'll see all four combinations,…so let's start with the code.…In lines four, five, and six,…we have the required header files.…These are iostream, set, and unordered_set.…So let's define in line number 11 one set of integers,…which we will name this_set.…
Next, we'll use the usual temporary variable,…and we will start with the first round of insertions.…We'll iterate until we get something negative,…ask for a value, and store it in temp.…
And if it's positive, in line 19 we will insert it.…
- 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.