[Mono-devel-list] Implemented Dictionary<K,V>

Ben Maurer bmaurer at ximian.com
Sun Feb 27 12:56:51 EST 2005


>
> ----- Original Message -----
> From: "Ben Maurer" <bmaurer at ximian.com>
> To: "Matthijs ter Woord (meddochat)" <meddochat at zonnet.nl>
> Cc: <mono-devel-list at ximian.org>
> Sent: Sunday, February 27, 2005 5:35 PM
> Subject: Re: [Mono-devel-list] Implemented Dictionary<K,V>
>
>
>> On Sun, 2005-02-27 at 10:14 +0100, Matthijs ter Woord (meddochat)
>> wrote:
>> > Hi Everybody,
>> >
>> > I implemented Dictionary<K,V>, can someone take a look at it?
>>
>> + public V this[K Index]{
> ....
>> + }
>>
>> This is a linear search. The Dictionary needs to be implemented like
> Hashtable.
>>
>
> Hmm, That's to much magic to me. Why didn't somebody else it already?

Because nobody has bothered.

Honestly, its not all that hard. For a first impl, we could do one of the
easier ways of resolving hash conflicts (like a linked list, rather than
the stuff we have in Hashtable, which is a bit harder).

> System.Collections.Generic seems important for Fx 2.0 stuff to me.

But given that it is not all that hard, it would be good to get at least a
reasonable impl the first time.

One other idea, if you really want the cheap way out, is to use Hashtable
and just do casting. It will box struct types and cost extra casting for
ref types. However, it at least gives a reasonable case for the ref types,
and a case that scales fairly well on value types.

-- Ben





More information about the Mono-devel-list mailing list