课程: C++ Standard Template Library
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Sets
- [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…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。