Chris Sells's CollectionGen [1] has a template for a strongly-typed version of the SortedList. This would allow you to store a struct in the strongly-typed SortedList without any boxing penalty, which can have quite a dramatic effect on performance, depending on how many items you're storing.
- Joel [1] http://www.sellsbrothers.com/tools/#collectionGen > -----Original Message----- > From: dotnet discussion [mailto:[EMAIL PROTECTED]] > On Behalf Of Bill Conroy > Sent: Thursday, May 23, 2002 11:19 AM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET] Hashtables and structs > > > I would suggest takign a look at > System.Collections.SortedList. I found it to be quite useful > for something like this. In my scenario the keys were what I > was sorting on. If you can use the key as the field you need > for sorting then you are set. > > As for an entry in a field of the data being stored you will > have to search over every item for this since they won't be > sorted then. > > -Bill Conroy > > > On Thu, 23 May 2002 08:23:47 -0700, Greg Gates > <[EMAIL PROTECTED]> > wrote: > > >Hello everyone: > > > >I have two basic questions regarding hashtables and structs. > > > >1) Is there any point in using a struct if the struct contains a > >string, given that a string is a reference type? > > > >2) What is the most efficent way to sort and filter a hashtable in > >.NET. For example, if I have a hashtable that contains the following > >key/values: > > > >A,object1 > >B,object2 > >C,object3 > > > >object1 has a foo field with a value of 4 > >object2 has a foo field with a value of 1 > >object3 has a foo field with a value of 2 > > > >What is the quickest way to retrieve an ordered subset of the items > >where the foo field is less than or equal to 3? > > > >thanks, Greg > > > >You can read messages from the DOTNET archive, unsubscribe > from DOTNET, > >or subscribe to other DevelopMentor lists at > >http://discuss.develop.com. > > You can read messages from the DOTNET archive, unsubscribe > from DOTNET, or subscribe to other DevelopMentor lists at > http://discuss.develop.com. > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.