Map
Define map:map<string,int> Word_count;
Add new element: word_count["Hengshan"]=10; This method will find if the new element is inserted directly if it is not found. You can also use Insert, such as Word_count.insert (Make_pair ("Hengshan", 10)), which is more orthodox.
Find an element: Using subscript will have a side effect, that is, if the element does not exist, an element will be created automatically, so it is better to use find. such as int aa=word_count.find ("Hengshan"), you can also use count to find out how many times an element has occurred. Use pointers to find an element without automatically adding, such as Map<string,int>::iterator it=word_count.find ("Hengshan");
if (It!=word_count.end ()) Cout<<it->second ();
Delete element: Word_count.erase ("Hengshan")
Traversal: Using iterators iterator
Sizes size
Set?
Sizes: Size
Finds find, returns the pointer type, iterator
Count, look for a few such elements
Add: Insert
Delete: Erase
Set is stored in a certain order, for example, the memory string is in the dictionary order, and the first addition to the set is irrelevant.
Basic methods for C + + containers