Talk:Associative array/Iteration: Difference between revisions

no edit summary
(This is the problem)
No edit summary
Line 4:
 
::Hi! Yes this is IMO the problem with this task. An associative array is not required to provide a conversion to an ordered set of pairs (key, value), which technically is what you described. Yes, it can, but so can any container on any finite machine. You can always order any finite set. The question whether any unordered map shall provide such conversion (in place (a view) or physical (a copy)) is another issue. There can be arguments for and against it. But it is not a programming task, it is a question of a container library design. Phyton's library took one choice, other libraries could do another. --[[User:Dmitry-kazakov|Dmitry-kazakov]] 10:05, 3 August 2009 (UTC)
 
::: Dmitry, it's sufficient that many programmers using many different mappings will want to iterate over all items or keys in the the mapping (with that guarantees that every item will be visited once and only once). Regardless of whether that iteration conforms to any particular ordering it's clearly a suitable basis for comparison among different languages. If my work requires me to deal with some Java code using their HashMap collections then I'm very likely to need info on the closest equivalent to Python ''.keys()'' or ''.items()'' dictionary methods. Some mapping libraries, classes or types in some languages don't support this then it should absolutely be documented here (so that the programmer adopting such a language and learning about it here will KNOW that he or she must maintain a separate list of the valid keys).
Anonymous user