I have populated HashMap with keys and values.
Now I need to iterate over all pair (key, values).
How to do this?
CHashMap don't have a method CHashMap.items().
I'd suggest to use CopyTo to copy the map content into an array. See CopyTo for IMap. https://www.mql5.com/en/docs/standardlibrary/generic/imap
Once you got the keys in your array you just loop over it.
Another possibility is to use an array of objects instead of CHashMap. (per @nicholi shen)
Definitely this. I have found very little use for dictionaries in MQL, however, if you are using CHashMap and need iterate the items then use the CopyTo method.
CHashMap<string, int> d;
for (int i=0; i<d.Count(); i++)
Print(keys[i], " ", values[i]);