The fastest ADT for retrieval on key value

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?


glowasAsked:
Who is Participating?
 
WinterMuteUKConnect With a Mentor Commented:
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
 
smeggheadCommented:
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
 
ptmcompCommented:
You can use a sorted array and binarysearch or if you need lookups HybridDictionary which is a hybrid of Hashtable and ListDictionary.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
smeggheadCommented:
Wasn't I first to suggest using hashtables ??

Smg :-(
0
 
glowasAuthor Commented:
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
 
smeggheadCommented:
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
All Courses

From novice to tech pro — start learning today.