[Mono-dev] FW: [Bug 349875] Dictionary<TKey, TValue> stores values out of order.

Juraj Skripsky js at hotfeet.ch
Wed Dec 19 14:54:09 EST 2007


You're right, it's just the definition of (specified) "behavior" that we
don't agree on.

MS left out any ordering guarantees for Dictionary'2 on purpose.
Specifying an order would have opened a very nasty can of worms. What
would be the expected order after adding the keys 1, 2, 3, then removing
2 and then adding 4? 1-3-4 or 1-4-3?

Thanks anyway for filling the bug report! Even if it wasn't really a
bug, it's good to have as many people as possible testing and
questioning the correctness of Mono.

- Juraj


On Wed, 2007-12-19 at 14:40 -0500, Josh Mouch wrote:
> I recall reading somewhere that when possible, mono will try to mimic the
> behavior of .Net, to make it easier for people to migrate from the later to
> the former.  I can't find that reference now, so maybe it's all in my head.
> :)
> 
> 
> -----Original Message-----
> From: Juraj Skripsky [mailto:js at hotfeet.ch] 
> Sent: Wednesday, December 19, 2007 2:17 PM
> To: Josh Mouch
> Cc: mono-devel-list at lists.ximian.com
> Subject: Re: FW: [Bug 349875] Dictionary<TKey, TValue> stores values out of
> order.
> 
> Hi Josh,
> 
> Mono is support to follow the MS .net _design_ not the _implementation_.
> If the docs don't state that you can depend on the order of the
> elements, you shouldn't do so. I consider an app relying on this order
> to be buggy.
> 
> - Juraj
> 
> PS: please always send a copy of such mails to the mailing lists. Others
> might be interested.
> 
> 
> On Wed, 2007-12-19 at 14:09 -0500, Josh Mouch wrote:
> > Isn't mono supposed to mimic MS .Net behavior?
> > 
> > Josh
> > 
> > -----Original Message-----
> > From: bugzilla_noreply at novell.com [mailto:bugzilla_noreply at novell.com] 
> > Sent: Wednesday, December 19, 2007 2:07 PM
> > To: josh+novell at mouch.name
> > Subject: [Bug 349875] Dictionary<TKey, TValue> stores values out of order.
> > 
> > https://bugzilla.novell.com/show_bug.cgi?id=349875
> > 
> > User juraj at hotfeet.ch added comment
> > https://bugzilla.novell.com/show_bug.cgi?id=349875#c1
> > 
> > 
> > Juraj Skripsky <juraj at hotfeet.ch> changed:
> > 
> >            What    |Removed                                         |Added
> >
> ----------------------------------------------------------------------------
> >                  CC|
> |juraj at hotfeet.ch
> >              Status|NEW
> |RESOLVED
> >          Resolution|
> |INVALID
> > 
> > 
> > 
> > 
> > --- Comment #1 from Juraj Skripsky <juraj at hotfeet.ch>  2007-12-19 12:06:33
> MST ---
> > According to MS.NET docs, this behavior is perfectly fine for the Values
> > property (see
> > http://msdn2.microsoft.com/en-us/library/ekcfxy3x.aspx):
> > 
> > "The order of the values in the Dictionary<(Of <(TKey,
> > TValue>)>)..::.ValueCollection is unspecified, but it is the same order as
> the
> > associated keys in the Dictionary<(Of <(TKey, TValue>)>)..::.KeyCollection
> > returned by the Keys property."
> > 
> > As for the enumeration of the Dictionary'2 itself, the documentation does
> not
> > state a required ordering of the returned elements.
> > 
> > Setting to resolved/fixed.
> > Please reopen if the docs support your claim.
> > 
> > 
> 




More information about the Mono-devel-list mailing list