I've gone through various texts. The only thing I got is that set is an associative container consisting of sorted and unique keys. Now if there are no values to map using key so where is the association in the set.
A Container is an object used to store other objects and taking care of the management of the memory used by the objects it contains.
An AssociativeContainer is an ordered Container that provides fast lookup of objects based on keys.
std::set is an associative container that contains a sorted set of unique objects of type Key
So what makes it associative? The fact that elements in a set are referenced by their key and not by their absolute position in the container. The key, of course, is the element itself. Think of it as a map where the keys are values are equal and given that, where the duplicate copy of the same content is eliminated.
So what about an unordered set then? std::unordered_set meets the requirements of Container, AllocatorAwareContainer and UnorderedAssociativeContainer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With