map of common usage

concept:

  map translation as a map, it is a common STL containers.

definition:

  map <key, value> mp; eg: map <string, int> mp; string to establish a mapping of type int.

access:

  (1) Access by subscript: eg: mp [ 'c'] c corresponds to access int.

  (2) through the iterator:

      map <typename1, typename2> :: iterator it; map by it-> first access key, it-> second value corresponding to the access key.

Common functions:

  (1) find (key): // return key mapped to key iterator popular talk return position pointer.

  (2) erase (it): // it is an iterator need to remove elements;

      mp.erase (first, last): // remove elements between the [first, last).  

  (3)size();

  (4)clear():

 

Guess you like

Origin www.cnblogs.com/aiqinger/p/12646403.html