Solved

The fastest ADT for retrieval on key value

Posted on 2003-11-15
6
287 Views
Last Modified: 2010-04-16
I use ArrayList for storing object references.
However retrieval time is linear function.
Can you recommend some other ADT from .NET framework or others that can give me log(n) retrieval time?
Or even better, can you point the fastest ADT for retrieval from .Net framework?


0
Comment
Question by:glowas
6 Comments
 
LVL 10

Expert Comment

by:smegghead
ID: 9756921
You could use a HashTable. And assuming that the hash value of the keys are very varied, the speed of access will be faster.. You can also tweak the bucket values etc...
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 9758108
You can use a sorted array and binarysearch or if you need lookups HybridDictionary which is a hybrid of Hashtable and ListDictionary.
0
 
LVL 9

Accepted Solution

by:
WinterMuteUK earned 500 total points
ID: 9771734
Hashtable is what I use for mine:

Hashtable hashMe = new Hashtable();
hashMe.Add(key, value);

if you also add:
hashMe.Add(value, key);

you can search through the table for either the key or the value. But it's not needed :)

Retrieve it using:
hash[key];

0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 10

Expert Comment

by:smegghead
ID: 9882623
Wasn't I first to suggest using hashtables ??

Smg :-(
0
 

Author Comment

by:glowas
ID: 9882650
You were not specific enough. For example: "You can also tweak the bucket values etc..."
I did not understand what you mean by that...
Sorry.
0
 
LVL 10

Expert Comment

by:smegghead
ID: 9882836
ok, I just didn't want to patronise if you already knew about buckets and load factors etc... you could've asked.. not to worry though.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question