468,536 Members | 1,510 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,536 developers. It's quick & easy.

Looking for an unsorted List class

Hi,

I need to store (key,Value) pairs, but I don't want them sorted.

I need to access to the keys or values by index. I also need to access the
indexes using keys or values. The only class that seems to support that is
the SortedList, but there is no way to have it unsorted !

Does someone have a solution to this problem ?

Thanks a lot
David
Nov 20 '05 #1
3 3293

"David Scemama" <da**********@wanadoo.fr> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I need to store (key,Value) pairs, but I don't want them sorted.

I need to access to the keys or values by index. I also need to access the
indexes using keys or values. The only class that seems to support that is
the SortedList, but there is no way to have it unsorted !

Does someone have a solution to this problem ?


Perhaps
Collections.Specialized.ListDictionary
fits the bill.

or roll your own

Class UnsortedList
Implements IDictionary

private items as new ArrayList()

. . .

David
Nov 20 '05 #2
Or

You could consider using a DataTable and DataView class to sort it as you
want.

Regards - OHM
David Browne wrote:
"David Scemama" <da**********@wanadoo.fr> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I need to store (key,Value) pairs, but I don't want them sorted.

I need to access to the keys or values by index. I also need to
access the indexes using keys or values. The only class that seems
to support that is the SortedList, but there is no way to have it
unsorted !

Does someone have a solution to this problem ?


Perhaps
Collections.Specialized.ListDictionary
fits the bill.

or roll your own

Class UnsortedList
Implements IDictionary

private items as new ArrayList()

. . .

David


Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
Nov 20 '05 #3
With ListDictionnary, I miss the functions I need to access the data.

But what if I create an Icomparer that always returns 1 ? the pairs should
be sorted in the insertion order ?

Public Class UnsortedList
Implements IComparer

Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer
Implements System.Collections.IComparer.Compare
Return 1
End Function
End Class

public usc as UnsortedList = New UnsortedList
public slVar as SortedList = New SortedList(usc)

is that supposed to work ?

Thanks david

"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:Oo**************@TK2MSFTNGP10.phx.gbl...

"David Scemama" <da**********@wanadoo.fr> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
Hi,

I need to store (key,Value) pairs, but I don't want them sorted.

I need to access to the keys or values by index. I also need to access the indexes using keys or values. The only class that seems to support that is the SortedList, but there is no way to have it unsorted !

Does someone have a solution to this problem ?


Perhaps
Collections.Specialized.ListDictionary
fits the bill.

or roll your own

Class UnsortedList
Implements IDictionary

private items as new ArrayList()

. . .

David

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Thomas Wegener | last post: by
reply views Thread by hg | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.