PowerCollections has a nice MultiDictionary and OrderedMultiDictionary
implementation.

http://www.codeplex.com/PowerCollections

Sébastien

On 1/22/08, Frans Bouma <[EMAIL PROTECTED]> wrote:
>
> > I wrote a lot of code working with Dictionary`2 for this sort of
> > scenario, then I realised I needed duplicate "Keys", so I built my own
> > NameValueList(Of TName, TValue) inheriting from List(Of
> > KeyValuePair(Of TName, TValue))
>
>         Duplicate key dictionaries are easy to create. Derive a class from
> Dictionary<K, V>, and also write or use a collection class which can hold
> only
> unique values. That's your value.
> public class MultiValueDictionary<K, V> : Dictionary<K,
> UniqueValueList<V>>
> {
>         // ...
>
> }
>
> The Add routine obtains the UniqueValueList for the specified key and adds
> the
> value. So with this you can simply keep on adding key-value pairs and
> still
> have O(1) of retrieving a key's values.
>
> For a unique value list, check for example:
> http://ewbi.blogs.com/develops/2006/10/uniquestringlis.html
>
> which is easy to rework to use any type.
> Or if you're on .NET 3.5, you can use the HashSet of course :)
>
>                 Frans
>
>
> >
> > Regards,
> > Mark Hurd, B.Sc.(Ma.)(Hons.)
> >
> > On 22/01/2008, Miika Makinen <[EMAIL PROTECTED]> wrote:
> > > Hi guys,
> > > What do you think? Do you think there's a reason to use
> namevaluecollection
> > > in .Net 2+ application? Does it perform better?
> > >
> > > Dictionary<string,string> is nice as you can quite easily refactor
> later
> to
> > > use some other types as keys or values...
> > >
> > > Miika
> >
> > ===================================
> > This list is hosted by DevelopMentorR  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor(R)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>



-- 
Sébastien
www.sebastienlorion.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to