|
From: Andre R. <and...@us...> - 2004-11-11 13:12:52
|
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1178/headers Modified Files: Tag: New_Tables_Experiment-branch lang.h Log Message: Further preparations for moving to dynamic allocation of hash bucket arrays: The size of a hash bucket array is now always a power of two. Computing an index into the bucket array is just a matter of masking the hash value rather than taking the rest of the division by a prime number. Hash tables now also keep track of the number of nodes they contain, so we will eventually be able to determine when to grow the hash bucket array. Index: lang.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/lang.h,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** lang.h 10 Nov 2004 17:21:43 -0000 1.4.2.1 --- lang.h 11 Nov 2004 13:12:38 -0000 1.4.2.2 *************** *** 453,464 **** #ifdef flv10tables - - #define ctinitialbuckets 11 typedef hdlhashnode **hdlhashbucketarray; #define nthhashbucket(ht,i) ((*((**(ht)).hbuckets))[i]) ! #define gethashbucketcount(ht) ((**(ht)).ctbuckets) #else --- 453,468 ---- #ifdef flv10tables typedef hdlhashnode **hdlhashbucketarray; + typedef unsigned long tyhashval; + + #define ctinitiallogsize 4 /*(2 ** 4) = 16 buckets*/ + #define nthhashbucket(ht,i) ((*((**(ht)).hbuckets))[i]) ! #define gethashbucketcount(ht) (1 << (**(ht)).logsize) ! ! #define hashtobucketindex(ht,hash) ((hash) & ((**ht).bucketmask)) #else *************** *** 469,472 **** --- 473,478 ---- #define gethashbucketcount(ht) ctbuckets + + #define hashtobucketindex(ht,hash) hash /*already handled in hash function*/ #endif *************** *** 479,486 **** #ifdef flv10tables ! unsigned long ctbuckets; ! hdlhashbucketarray hbuckets; #else --- 485,496 ---- #ifdef flv10tables + + hdlhashbucketarray hbuckets; /*handle to an array of hash node handles*/ ! unsigned long logsize; /*number of buckets = 1 << logsize*/ ! ! tyhashval bucketmask; /*mask hashval with this to obtain index into bucket array*/ ! unsigned long ctnodes; /*number of nodes in the table*/ #else |