Looking for an unsorted List class

  • Thread starter Thread starter David Scemama
  • Start date Start date
D

David Scemama

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
 
David Scemama said:
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
 
Or

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

Regards - OHM


David said:
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 (e-mail address removed)
 
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
 
Back
Top