Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > Hash_impl
comparison PrivateHash.h @ 24:b032601956bb
Works -- with send-receive plus normal dependencies
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 14 Jun 2012 18:44:46 -0700 |
| parents | f5972b1ddb29 |
| children | 18ec64d06e35 bd376656f8ab |
comparison
equal
deleted
inserted
replaced
| 7:b88bd4beb714 | 8:166369394f1a |
|---|---|
| 14 #include <stdlib.h> | 14 #include <stdlib.h> |
| 15 | 15 |
| 16 #include "VMS_impl/VMS_primitive_data_types.h" | 16 #include "VMS_impl/VMS_primitive_data_types.h" |
| 17 #include "VMS_impl/Services_Offered_by_VMS/Memory_Handling/vmalloc.h" | 17 #include "VMS_impl/Services_Offered_by_VMS/Memory_Handling/vmalloc.h" |
| 18 | 18 |
| 19 //===================== defines ===================== | |
| 19 #define TRUE 1 | 20 #define TRUE 1 |
| 20 #define FALSE 0 | 21 #define FALSE 0 |
| 21 | 22 |
| 23 #define DEFAULT_HASH_TABLE_SIZE 1 << 10 | |
| 24 #define DEFAULT_POWER_OF_2_TABLE_SIZE 10 | |
| 25 | |
| 26 | |
| 27 //===================== structs ===================== | |
| 22 union hashkey_t{ | 28 union hashkey_t{ |
| 23 char hashable[8]; | 29 char hashable[8]; |
| 24 int parts[2]; | 30 int parts[2]; |
| 25 }; | 31 }; |
| 26 | 32 |
| 27 typedef union hashkey_t hashkey_t; | 33 typedef union hashkey_t hashkey_t; |
| 28 | |
| 29 #define DEFAULT_HASHSIZE 1 << 10 | |
| 30 | 34 |
| 31 typedef struct _HashEntry HashEntry; | 35 typedef struct _HashEntry HashEntry; |
| 32 | 36 |
| 33 struct _HashEntry | 37 struct _HashEntry |
| 34 { | 38 { |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 typedef void (*FreeEntryContentFnPtr) ( void * ); | 44 typedef void (*FreeEntryContentFnPtr) ( void * ); |
| 41 | 45 |
| 42 typedef struct | 46 typedef struct |
| 43 { int tableSz; | 47 { int tableSz; |
| 44 int numEntries; | 48 int numEntries; |
| 45 HashEntry* *entries; | 49 HashEntry* *entries; |
| 50 int32 hashMask; | |
| 51 int32 prevHash; | |
| 46 FreeEntryContentFnPtr freeEntryContentFn; | 52 FreeEntryContentFnPtr freeEntryContentFn; |
| 47 } | 53 } |
| 48 HashTable; | 54 HashTable; |
| 49 | 55 |
| 50 | 56 |
| 62 bool8 deleteEntrysValueInTable( char *key, HashTable *table ); | 68 bool8 deleteEntrysValueInTable( char *key, HashTable *table ); |
| 63 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); | 69 bool8 deleteEntryFromTableAndFreeValue( char *key, HashTable *table ); |
| 64 void freeHashTable( HashTable *table ); | 70 void freeHashTable( HashTable *table ); |
| 65 //char *paramBagToString( ParamBag * bag ) | 71 //char *paramBagToString( ParamBag * bag ) |
| 66 | 72 |
| 73 //================= Same Fns, but for 32b array key hash fn ================ | |
| 74 HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn); | |
| 75 HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn ); | |
| 76 | |
| 77 int putEntryIntoTable32( HashEntry *entry, HashTable *table); | |
| 78 HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table); | |
| 79 HashEntry *getEntryFromTable32( uint32 key[], HashTable *table ); | |
| 80 void *getValueFromTable32( uint32 key[], HashTable *table ); | |
| 81 | |
| 82 bool32 deleteEntryFromTable32( uint32 key[], HashTable *table ); | |
| 83 | |
| 67 //=========================================================================== | 84 //=========================================================================== |
| 68 // Internal functions | 85 // Internal functions |
| 69 void freeHashEntryUsing( HashEntry *entry, HashTable *table ); | 86 void freeHashEntryUsing( HashEntry *entry, HashTable *table ); |
| 70 unsigned int hashThisKey( char *s, int hashSz ); | 87 unsigned int hashThisKey( char *s, int hashSz ); |
| 71 void nullOutTablesArray( HashTable *table ); | 88 void nullOutTablesArray( HashTable *table ); |
| 72 void doubleTableSize( HashTable *table ); | 89 void doubleTableSize( HashTable *table ); |
| 73 void freeHashEntryButNotContent( HashEntry *entry ); | 90 void freeHashEntryButNotContent( HashEntry *entry ); |
| 74 | 91 |
| 92 uint32 | |
| 93 jenkHash32( const uint32 *key, /* array of uint32 values */ | |
| 94 int32 length); /* num uint32 in the key */ | |
| 95 | |
| 75 #endif /* _PRIVATE_HASH_H */ | 96 #endif /* _PRIVATE_HASH_H */ |
| 76 | 97 |
