On 13 Feb, 06:45, "Branco Medeiros" <branco.medei...@gmail.com> wrote:
> On Feb 13, 12:03 am, "pamela fluente" <pamelaflue...@libero.it> wrote:
>
> > Sometimes I define a
> > System.Collections.Generic.Dictionary(Of Key, ...)
>
> > but actually I only use the Key part. Is there any collection which I
> > can use
> > which is similar to a Dictionary, but without the value part ?
> > I mean just a list of unique key Object , with a O(1) retrieval
> > operation ?
>
> > -Pam
>
> I'm particularly fond of
> System.Collections.ObjectModel.KeyedCollection(Of Key, Item). It's
> usefull when the item is also the key, or the key is a property of the
> item itself. Unfortunately its an abstract class, which means you must
> inherit it, because there's a GetKeyForItem method that needs
> implementation. Indexed access is O(1), while keyed access is near
> O(1) -- or so the docs say. Besides, it has the definite advantage (to
> me) that it keeps the insertion order (which a Dictionary won't).
Hmm I might give it a try. Isn't strange that there isn't a collection
of keys only ? I think it could be nice to have it
>
> HTH.
>
> Regards,
>
> Branco.
|