Talk:Associative array/Iteration

From Rosetta Code

Hmm, associative array is not defined ordered. It is an unordered map. For example, it can have keys of complex numbers or images etc, which are unordered. Whether and if an associative array has some internal indices, different from the unordered keys, of full or partial order making indexation better than O(n) is an implementation detail. I tempted to suggest renaming to iteration over an ordered map, but looking at the implementations, I realized that it is rather an ordered view of some unordered map using an alternative ordered key. Any container can have such alternative views. It is not special to associative array, or better to say has nothing to do with them. --Dmitry-kazakov 08:23, 3 August 2009 (UTC)

Hi Dmitry, iterating over all the members of an associative array is quite a common practice in Python. The keys/values may not appear in any particular order, but you must be guaranteed to go over each and every key/value only once. Python has the added assurance that if the associative array is unchanged, iterating over all keys , then iterating over all values will give the values in corresponding order to their keys; but that is not called for in this task. --Paddy3118 09:32, 3 August 2009 (UTC)