[Mono-bugs] [Bug 428216] [PATCH] return Dictionary keys as in added order

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Sep 22 11:02:13 EDT 2008


User jpryor at novell.com added comment

--- Comment #4 from Jonathan Pryor <jpryor at novell.com>  2008-09-22 09:02:13 MDT ---
For one thing, the MSDN docs do NOT say that the order of .Keys and .Values
will be the same as the insertion order.  That's an implementation detail. 
Perhaps we should copy it, perhaps not, but it is NOT documented.

For another, I'm missing the point of your patch. 
Dictionary`2.KeyCollection.Enumerator.Current would return
host.keySlots[current] with your patch, instead of host_enumerator.CurrentKey.

But what's Dictionary`2.Enumerator.CurrentKey do?  "return dictionary.keySlots

The only significant change I see is in Enumerator.MoveNext(), where e.g.
Dictionary`2.KeyCollection.Enumerator.MoveNext() just increments an integer,
while Dictionary`2.Enumerator.MoveNext() goes through the dictionary.table or
dictionary.linkSlots arrays.

Wouldn't it be easier to just make Dictionary`2.Enumerator.MoveNext() increment
an index value (as your Dictionary`2.KeyCollection.Enumerator.MoveNext() does),
thus implicitly making KeyCollection & ValueCollection get your updated
behavior, at the "cost" of making Dictionary`2.Enumerator return elements in
insertion order instead of...whatever order it currently uses.  Which shouldn't
matter, as the order of returned values isn't defined (afaik).

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list