Re: Hash table & threading
- From: "Dan Bass" <Not Listed>
- Date: Tue, 28 Jun 2005 08:45:57 +0100
It all depends how you want to access your data. The point of a hash table
is that it's indexed by a value derived from the key, where an Array holds
single values in an numerically indexed fashion.
If you want to call the value for key "xyz" for example, then hash tables
are far more efficient. The Array would have to go through each element to
check for the value each time you want to access a value. The larger your
data set is, the more efficient the hash table becomes.
The other thing with ArrayList for example, is that it stores a single value
that is indexed by "i" where "i" is the next available integer. To get a
name/value pair you'd first have to create a struct (or class I suppose)
which contains two strings, name and value. Then create these and store
these in your array.
The more you look at it, the more you realise your requirement pushes you in
one direction or another.
"Ravi" <Ravi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:00BCE3F4-4482-47EA-8BD0-EB1050CE12E3@xxxxxxxxxxxxxxxx
> Hi,
> I am working on a winform app. I need to use an object which can store
> some information(key/value pairs) and also can be acessed by multiple
> threads(read/write). From what I heard Hash table is best suited for it.
> My
> question is
> Why hash table. why can't we use an array.
> I thought hash table uses more memory than array. Correct me if am wrong.
>
>
.
- References:
- Hash table & threading
- From: Ravi
- Hash table & threading
- Prev by Date: Re: C# Classes - Problem with using class as object properties
- Next by Date: Re: using splitter
- Previous by thread: Hash table & threading
- Next by thread: ThreadPool wait for threads to finish
- Index(es):
Relevant Pages
|