|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dumb question?I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to sort
its contents based on the keys. Right now the only way I can think of doing this is manually creating a KeyValuePair array from its contents, sorting it, and then clearing out the contents and adding them all back in order. Should I use SortedList instead? Or would that be worse for performance since it re-sorts on every item add? Paul >> Should I use SortedList instead? Or would that be worse for performance since it re-sorts on every item add?What results did your perf testing produce when you compared them? Bob Lehmann Show quoteHide quote "PJ6" <no***@nowhere.net> wrote in message news:u3VMjltcGHA.3840@TK2MSFTNGP04.phx.gbl... > I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to sort > its contents based on the keys. > > Right now the only way I can think of doing this is manually creating a > KeyValuePair array from its contents, sorting it, and then clearing out the > contents and adding them all back in order. > > Should I use SortedList instead? Or would that be worse for performance > since it re-sorts on every item add? > > Paul > > Fine I'll perf test
Show quoteHide quote "Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message news:%23kjYuHvcGHA.1272@TK2MSFTNGP03.phx.gbl... >>> Should I use SortedList instead? Or would that be worse for performance > since it re-sorts on every item add? > > What results did your perf testing produce when you compared them? > > Bob Lehmann > > > "PJ6" <no***@nowhere.net> wrote in message > news:u3VMjltcGHA.3840@TK2MSFTNGP04.phx.gbl... >> I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to > sort >> its contents based on the keys. >> >> Right now the only way I can think of doing this is manually creating a >> KeyValuePair array from its contents, sorting it, and then clearing out > the >> contents and adding them all back in order. >> >> Should I use SortedList instead? Or would that be worse for performance >> since it re-sorts on every item add? >> >> Paul >> >> > > >I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to sort Have you considered the SortedDictionary(Of TKey, TValue) class?>its contents based on the keys. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
control array question for VB.Net 2005
File copy VB Exp 2005 Fat client - Server: Which technology? Thread Sync Queue Problem umanaged code - array error Outlook Add In is not shown for 1 user... Standarddrucker mit .Net ermitteln Regular expression rejecting invalid files licensing a third party control UBound behaviour |
|||||||||||||||||||||||