Re: Hash table & threading

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




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.
>
>


.



Relevant Pages

  • Re: The flaw of Java is that it is digsined for enforsing clean code for idiots
    ... goto &struct; ... if($base_type eq 'HASH'){ ... elsif($base_type eq 'ARRAY'){ ... overrides struct accessor method"); ...
    (comp.lang.java.advocacy)
  • Duck Typed Concepts for Ruby (was Re: A use case for an ordered hash)
    ... An Sequencable mixin can be defined that implements all sorts of operations such as append, concat, splice, sort, etc. ... extending an instance of Array with Sorted if the array is known to be sorted. ... Now returning to the thread at hand we can see that the difference between the associative array and hash hierarchies is that the hash hierarchy depends upon Hashable keys. ...
    (comp.lang.ruby)
  • Re: Suggestions for double-hashing scheme
    ... >> The items that are being moved are the items in the hash table itself, ... >> which are of fixed size (they are in an array, ... > typedef struct { ... One "uchar" aka 'unsigned char' is plenty to hold a probe ...
    (comp.programming)
  • Re: advice on good perl idiom
    ... Therefore you want to store that result in an auxiliary variable ... $bestV = check; ... using an array, I feel like I should be doing something with a hash. ...
    (comp.lang.perl.misc)
  • Re: Binary search trees or hash tables?
    ... Talking about containers made me wanting to reconsider my choice of hash ... tables as the basis for the mapping key/value I have in my library. ... struct pair { ... Let's say that on average it is 50%: to store n ...
    (comp.lang.c)