Solved

The fastest ADT for retrieval on key value

Posted on 2003-11-15
6
277 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 10

Expert Comment

by:smegghead
Comment Utility
Wasn't I first to suggest using hashtables ??

Smg :-(
0
 

Author Comment

by:glowas
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now