When someone tells you what to do, ask for justification.
Iteration
Iterating any data structure with a data set is no problem at all in general.
If you want to iterate in a specific way, in a specific structure, and you want a specific result, then you may have a problem.
Essentially all basic data structures can be iterated into complexity Linear o(n). Only it would not be so some very complex and very specific structure that practically nobody uses. You can’t do it in less time than that, and it won’t take any more. So much so that no one puts what the complexity is for this algorithm, it is "always" the same.
Do you want to iterate in a specific order? Does it need to be in the order the elements were entered? Or does it need a specific classification? If you need something like this it is better to use another structure if you can. Maps usually do not have defined order. There are even implementations that allow order, but can only be used in specific circumstances, most maps use scattering tables, which do not allow order.
Alternatives
If you need the order use a array or structure based on it. It’s great in the vast majority of needs.
If you need the sorted data then it should be more interesting to use a tree, which is a linked list that has more than one path to follow in the sequence.
It is very rare for the pure linked list to be useful, usually only when it does not need to be manipulated after being created, except at the (s) tip(s) and also does not need random access, which makes other structures also suitable.
Linked lists, as learned in the course of computing, are essentially not used in the "real world". More sophisticated implementations, probably combined with other structures, may be useful in certain scenarios.
It is very common for people to think that inserting and removing an element from a linked list can be done in constant complexity, because the operation itself is really constant. But you almost always need to get to the point where the element will be inserted or removed, and then the complexity is linear.
I must be one of the few people who use linked list in database under certain circumstances. I used where it gave me some advantage over the normal index that DB already has. Although today it is rare that I have this need. It has to weigh everything to decide which is the best structure.
Do not misjudge
I’ve seen people turn one array on a map to be able to index in constant time instead of linear. I am not saying that this is useless in all cases, but almost always the complexity has become O(n + k) in the best case, that is only disadvantage. The person forgets to count the time of the copy of the structure. If he had done in the array would be O(n) in the worst case and O(1) in the best.
Perhaps your problem is more suitable for a linked list, but we are not sure what that problem would be. It may require the joint use of more than one structure, and one of them is a linked list (maybe non-traditional).
Your colleague is probably considering these data structures in an abstract way. A linked list, conceptually, is a structure suitable for iteration, but potentially slow for access to specific items. Hashmap is more efficient than the linked list for access to specific items, which does not mean it is slow to iterate. Actually it will depend on the implementation. In a quick search, I found no references to avoid hashmap iteration.
– bfavaretto
Thank you but if I belong to the structure given as an example. Would you have to create a linkedlist to get the data? or hashmap iteration time is negligible?
– João Marques
Why not just get the key list and iterate with a for normal or Iterator? It seems that you are worried about microtimizations.
– bfavaretto
I would just like to know all the possible solutions to determine whether they are relevant or not. I can only know if the x option is better in order to understand why the other y and z are not so good. To that end I would like to understand my colleague’s point of view.
– João Marques