newbie16 newbie16 - 3 years ago 205
C++ Question

c++ stl associative container & user defined type

I classified c++ stl associative container by following criteria (set, map) (normal, multi) (ordered, unordered).

There are 8 cases (2 * 2 * 2).


  1. set


    • multiset


      • unordered_multiset

      • (ordered)multiset


    • set


      • unordered_set

      • (ordered)set



  2. map


    • multimap


      • unordered_multimap

      • (ordered)multimap


    • map


      • unordered_map

      • (ordered)map





I want to ensure myself that for each container, in order to use user defined class as key which functions should be defined. Below is my answer to my question.


  1. set


    • multiset


      • unordered_multiset :
        hash function
        ,
        comparison function for equality

      • (ordered)multiset :
        comparison function for <


    • set


      • unordered_set :
        hash function
        ,
        comparison function for equality

      • (ordered)set :
        comparison function for <



  2. map


    • multimap


      • unordered_multimap :
        hash function
        ,
        comparison function for equality

      • (ordered)multimap :
        comparison function for <


    • map


      • unordered_map :
        hash function
        ,
        comparison function for equality

      • (ordered)map :
        comparison function for <





Is it correct?

Answer Source

Yes, that is completely correct.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download