... implementation of a set
is identical to that of a multiset
, except that a set
must have unique keys. Therefore, if an attempt is made to insert a duplicate key into a set
, the duplicate is ignored—this is the intended mathematical behavior of a set, so it’s not considered an error. A set
supports bidirectional iterators (but not random-access iterators). If the order of the keys is not important, you can use unordered_set
(header <unordered_set>
) instead. Figure 15.16 demonstrates a set
of double
s.
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.