Ivan Novick wrote:
> CBFalconer <cbfalco...@yahoo.com> wrote:
>
>> I suggest you take a look at hash tables. I have published a
>> library for general use (GPL licensed, but other arrangements can
>> be made with me), written in portable standard C, which has various
>> features for portability. You can find it at:
>>
>> <http://cbfalconer.home.att.net/download/>
>
> If you are going to go this route why not use Apache Portable
> Runtime library?
>
> http://apr.apache.org/docs/apr/1.2/g...apr__hash.html
I took a cursory look at your reference. I think hashlib is much
more flexible, and simpler to understand and use. I KNOW it uses
only pure ISO standard code, suitable for both C90 and C99
compilers. Here is a short excerpt from the documentation
(hshusage.txt) file:
Using hashlib
=============
First, we need some way to refer to the table. So we must
have a data item of type hshtbl* to hold it. We will initialize
that by calling hshinit. This is much like opening a file. For
convenience here is the prototype for hshinit again:
/* initialize and return a pointer to the data base */
hshtbl *hshinit(hshfn hash, hshfn rehash,
hshcmpfn cmp,
hshdupfn dupe, hshfreefn undupe,
int hdebug);
Now this following is a fragment from your code:
hshtbl *mytable;
/* initialize and return a pointer to the data base */
mytable = hshinit(myhash, myrehash,
mycmp,
mydupe, myundupe,
0);
which tells hashlib all about the customizing functions you have
created. Note that all those functions can be static, unless
you have other uses for them outside your source file. You can
use those functions yourself as you please.
Don't forget the final 0 in the call to hshinit. That parameter
provides for future extensions and debugging abilities, and
passing a zero here will maintain compatibility.
You can create more than one hash table if you desire. If they
handle the same data format you can just do exactly the same
call as above, except you will need a new variable of type
hshtbl* to hold the table identification. If they don't hold
the same data type you can supply different functions to
hshinit. It is up to you.
*** end of excerpt ***
--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee, Frohe Weihnachten
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from
http://www.teranews.com