Solved

The fastest ADT for retrieval on key value

Posted on 2003-11-15
6
283 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System.Security 2 27
C#  Radio button search for Date not DateTime 4 47
Simple Injector with Web Service 4 43
Need help with a Crystal Report in my C#.Net application 2 16
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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