Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Hash_impl
diff PrivateHash.h @ 23:ac99f4a8ce22
First working version
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 06 Jun 2012 18:00:58 -0700 |
| parents | f5972b1ddb29 |
| children | 18ec64d06e35 bd376656f8ab |
line diff
1.1 --- a/PrivateHash.h Tue Mar 13 18:31:05 2012 -0700 1.2 +++ b/PrivateHash.h Wed Jun 06 18:00:58 2012 -0700 1.3 @@ -16,9 +16,15 @@ 1.4 #include "VMS_impl/VMS_primitive_data_types.h" 1.5 #include "VMS_impl/Services_Offered_by_VMS/Memory_Handling/vmalloc.h" 1.6 1.7 +//===================== defines ===================== 1.8 #define TRUE 1 1.9 #define FALSE 0 1.10 1.11 +#define DEFAULT_HASH_TABLE_SIZE 1 << 10 1.12 +#define DEFAULT_POWER_OF_2_TABLE_SIZE 10 1.13 + 1.14 + 1.15 +//===================== structs ===================== 1.16 union hashkey_t{ 1.17 char hashable[8]; 1.18 int parts[2]; 1.19 @@ -26,8 +32,6 @@ 1.20 1.21 typedef union hashkey_t hashkey_t; 1.22 1.23 -#define DEFAULT_HASHSIZE 1 << 10 1.24 - 1.25 typedef struct _HashEntry HashEntry; 1.26 1.27 struct _HashEntry 1.28 @@ -40,9 +44,11 @@ 1.29 typedef void (*FreeEntryContentFnPtr) ( void * ); 1.30 1.31 typedef struct 1.32 - { int tableSz; 1.33 - int numEntries; 1.34 + { int tableSz; 1.35 + int numEntries; 1.36 HashEntry* *entries; 1.37 + int32 hashMask; 1.38 + int32 prevHash; 1.39 FreeEntryContentFnPtr freeEntryContentFn; 1.40 } 1.41 HashTable; 1.42 @@ -64,6 +70,17 @@ 1.43 void freeHashTable( HashTable *table ); 1.44 //char *paramBagToString( ParamBag * bag ) 1.45 1.46 +//================= Same Fns, but for 32b array key hash fn ================ 1.47 +HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); 1.48 +HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); 1.49 + 1.50 +int putEntryIntoTable32( HashEntry *entry, HashTable *table); 1.51 +HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); 1.52 +HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); 1.53 +void *getValueFromTable32( uint32 key[], HashTable *table ); 1.54 + 1.55 +bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); 1.56 + 1.57 //=========================================================================== 1.58 // Internal functions 1.59 void freeHashEntryUsing( HashEntry *entry, HashTable *table ); 1.60 @@ -72,5 +89,9 @@ 1.61 void doubleTableSize( HashTable *table ); 1.62 void freeHashEntryButNotContent( HashEntry *entry ); 1.63 1.64 +uint32 1.65 +jenkHash32( const uint32 *key, /* array of uint32 values */ 1.66 + int32 length); /* num uint32 in the key */ 1.67 + 1.68 #endif /* _PRIVATE_HASH_H */ 1.69
