Learn about the set, a sorted container that holds only unique elements; the multiset, which allows duplicates; and the unordered set, which provides hashed keys.
- [Narrator] A set is a container…that holds a sorted set of elements.…The set class holds only unique elements,…where the multiset class allows duplicates.…The unordered_set does not sort elements…and instead provides hashed keys for faster access.…Here I have a working copy of set.cpp…from chapter two of the exercise files.…And you'll notice I have the set header…and the unordered_set header included.…
And we have our convenience functions…for printing and for messages.…And then down here, starting in line 24,…I declare a set of strings,…and I initialize it with an initializer list.…And we report on the size of the set and print out the set.…And so when I build and run...…Scroll up here to the top.…And we can see I construct the set.…The set has five elements, so the size of set.…
And, here's the ordered.…Now it's alphabetical,…it's not in numerical order obviously.…So, five four one three two, that's alphabetical.…And, I can use the insert method…to insert a new element, six.…And you notice that it shows up in alphabetical order there.…
- 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.