Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Generics: difference between Dictionary, SortedDictionary and SortedList

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cody - 27 Aug 2005 20:23 GMT
They all seem to be kind of a hashtable and using different algorithms but
what is the actual difference?
When should I use which one?
Daniel O'Connell [C# MVP] - 27 Aug 2005 20:55 GMT
> They all seem to be kind of a hashtable and using different algorithms but
> what is the actual difference?
> When should I use which one?

Dictionary is a hashtable, SortedDictionary is a dictionary implemented as a
red-black tree and maintains an order. SortedList appears to be implemented
as a list, using a straight sequential algorithm to locate keys.
Daniel O'Connell [C# MVP] - 27 Aug 2005 20:59 GMT
> They all seem to be kind of a hashtable and using different algorithms but
> what is the actual difference?
> When should I use which one?

Oops, forgot to complete that. Each one has different uses, obviously.
Dictionary has no order, so it is appropriate in any circumstance where
order is irrelevent. SortedList would have linear search time, as the last
key in the list will require comparisions to every preceding key, I wouldn't
use it for alot of items if you will be accessing them randomly. I suspect
it would be a good choice if you will access the items in sequence however.
SortedDictionary uses a tree and has a an O(log n) retrieval time, use it
when you will be doing random(key by indexer) retrevials with a fair number
of items, I suspect it won't be as efficent as SortedList when accessing
items in sequence, but I've run no tests to prove that.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.