?
Solved

The fastest ADT for retrieval on key value

Posted on 2003-11-15
6
Medium Priority
?
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

770 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