Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A container that stores UNIQUE elements in a specific SORTED order. It's typically implemented as a Red-Black Tree.
insert(val): Adds unique element in O(log N).erase(val): Removes element in O(log N).find(val): Returns iterator to element, or end().count(val): Returns 1 if present, 0 if not.std::set is sorted. O(log N) for most operations.
std::unordered_set uses hashing. O(1) average time.
If you insert 30, 10, 20 into a set, it will automatically store them as 10, 20, 30. This makes it ideal for finding distinct values in sorted order.