Associative containers (C++)

The following containers are defined in the current revision of the C++ standard: set, map, multiset, multimap.

[1] Associative containers are guaranteed to perform operations of insertion, deletion, and testing whether an element is in it, in logarithmic time – O(log n).

As such, they are typically implemented using self-balancing binary search trees and support bidirectional iteration.

As stated earlier, map and set only allow one instance of a key or element to be inserted into the container.

Then user can input a word to query how many times it has occurred in the previously entered series.

The above example also demonstrates that the operator [] inserts new objects (using the default constructor) in the map if there is not one associated with the key.

If it doesn't find it, an iterator to the end of the map is returned and it outputs that the key could not be found.