Mail Archives: djgpp/1999/06/16/10:51:38
From: | "Christopher Nelson" <paradox AT gye DOT satnet DOT net>
|
To: | <djgpp AT delorie DOT com>
|
Subject: | Re: hashes or hash arrays
|
Date: | Tue, 15 Jun 1999 11:53:27 -0600
|
Message-ID: | <01beb757$f8b371e0$d8c2ddd0@thendren>
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook Express 4.71.1712.3
|
X-MimeOLE: | Produced By Microsoft MimeOLE V4.71.1712.3
|
Reply-To: | djgpp AT delorie DOT com
|
-----Original Message-----
From: Shaggs <jud AT tminet DOT com>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Monday, June 14, 1999 10:12 AM
Subject: hashes or hash arrays
>how do you creat a hash array in c/c++. Its so usefull in pearl, but i
>havn'e heard a thing about it in c, except a little bit which suggests it
is
>done
You have to do it yourself, or find a library that does it for you. A hash
array/list, is a *somewhat* ordered list that reduces lookup time by
searching smaller lists. The way it works is this:
You have an array with n elements. From some type of information in
the objects that you want to store you need to generate a hash *key*. That
may be as simple as doing the pointer%n, or may be much more complicated.
In the end, the hash key must be greater than -1 and less than n. Then you
simply walk down the list contained in the array element that the hash key
refers to.
-={C}=-
- Raw text -