Talk:Associative array/Iteration: Difference between revisions

m
moved Talk:Associative arrays/Iteration to Talk:Associative array/Iteration: Named to match Associative array page
(they '''should''', since often it's useful)
m (moved Talk:Associative arrays/Iteration to Talk:Associative array/Iteration: Named to match Associative array page)
 
(3 intermediate revisions by 3 users not shown)
Line 14:
 
::::::: I think so since every language I know provides a way of iterating an "associative array", by pairs or giving back an array of keys and since it is often implemented because it's something one may need, often enough (and in fact, a lot of people use iteration over associative arrays alot in everyday programming). Currently I am using the [[:Category:Judy]] library to associate a data structure with a "symbol"; I am not interested in a way of iterating over the associations since the only intention is just to retrieve the data given the symbol, and this library itself does not provide a way of doing such an iteration over the associations. But if I were writing a language, I would implement for sure a way of iterating over it (it can be just extra memory, no killing performance too much: just another operation to keep track of the created "symbols"/keys). It does not mean that every language has it of course, but it's my opinion that if a language has associative arrays, it must give a way of iterating over them, since, as said, it's often useful. And my current knowledge of (high level) languages confirm this. --[[User:ShinTakezou|ShinTakezou]] 13:52, 5 August 2009 (UTC)
 
:::::::: Addendum: indeed Judy library too allow to iterate over key-value pairs! --[[User:ShinTakezou|ShinTakezou]] 12:20, 11 August 2009 (UTC)
 
::::::: Sometimes I think you're being really obstructive. While yes, it's possible that a particular implementation of an associative map might not allow iteration, the majority of implementations do (whether or not they're thread-safe, which might or might not be something of note to be mentioned, depending on the respective languages' norms) and I'm not aware offhand of any language that provides only uniterable associative maps; those that don't provide iterable maps tend to not provide maps at all. Iteration over a map — even given that it's a possibly slow thing to do — is just too useful in practice. (And for in-memory implementations where a single thread “owns” the map, it's actually fairly fast; usually straight linear in the number of elements.) —[[User:Dkf|Donal Fellows]] 14:20, 5 August 2009 (UTC)