Check out example codes for "iterate through map". It will help you in understanding the concepts better.

Code Example 1

// Java program to demonstrate iteration over  
// Map.entrySet() entries using for-each loop 
  
import java.util.Map; 
import java.util.HashMap; 
  
class IterationDemo  
{ 
    public static void main(String[] arg) 
    { 
        Map<String,String> gfg = new HashMap<String,String>(); 
      
        // enter name/url pair 
        gfg.put("GFG", "geeksforgeeks.org"); 
        gfg.put("Practice", "practice.geeksforgeeks.org"); 
        gfg.put("Code", "code.geeksforgeeks.org"); 
        gfg.put("Quiz", "quiz.geeksforgeeks.org"); 
          
        // using for-each loop for iteration over Map.entrySet() 
        for (Map.Entry<String,String> entry : gfg.entrySet())  
            System.out.println("Key = " + entry.getKey() + 
                             ", Value = " + entry.getValue()); 
    } 
}

Code Example 2

//traditional way (long)
for(map<string,int>::iterator it=m.begin(); it!=m.end(); ++it)
	if(it->second)cout<<it->first<<" ";
//easy way(short) just works with c++11 or later versions
for(auto &x:m)
	if(x.second)cout<<x.first<<" ";
//condition is just an example of use

Learn ReactJs, React Native from akashmittal.com