diff prhash.h @ 1:14241f07f742

committing files from /usr/include/PR__include directly.. test..
author Sean Halle <seanhalle@yahoo.com>
date Thu, 08 Aug 2013 03:00:36 -0700
parents d460a47ed2d6
children c3829f630c2f
line diff
     1.1 --- a/prhash.h	Thu Aug 08 02:39:56 2013 -0700
     1.2 +++ b/prhash.h	Thu Aug 08 03:00:36 2013 -0700
     1.3 @@ -1,96 +1,96 @@
     1.4 -/*
     1.5 - *  Copyright 2009 OpenSourceResearchInstitute.org
     1.6 - *  Licensed under GNU General Public License version 2
     1.7 - *
     1.8 - * Author: seanhalle@yahoo.com
     1.9 - */
    1.10 -
    1.11 -#ifndef _PRHASH_H
    1.12 -#define	_PRHASH_H
    1.13 -
    1.14 -#include <stdio.h>
    1.15 -#include <string.h>
    1.16 -#include <errno.h>
    1.17 -#include <stdlib.h>
    1.18 -
    1.19 -#include <PR__include/PR__primitive_data_types.h>
    1.20 -
    1.21 -//=====================  defines  =====================
    1.22 -#define TRUE     1
    1.23 -#define FALSE    0
    1.24 -
    1.25 -#define DEFAULT_HASH_TABLE_SIZE 1 << 10
    1.26 -#define DEFAULT_POWER_OF_2_TABLE_SIZE 10
    1.27 -
    1.28 -
    1.29 -//=====================  structs  =====================
    1.30 -union hashkey_t{
    1.31 -    char hashable[8];
    1.32 -    int32 parts[2];
    1.33 -};
    1.34 -
    1.35 -typedef union hashkey_t hashkey_t;
    1.36 -
    1.37 -typedef struct _HashEntry HashEntry;
    1.38 -
    1.39 -struct _HashEntry
    1.40 - {
    1.41 -   char       *key;
    1.42 -   void       *content;
    1.43 -   HashEntry  *next;
    1.44 - };
    1.45 -
    1.46 -typedef void (*FreeEntryContentFnPtr)    ( void * );
    1.47 -
    1.48 -typedef struct
    1.49 - { int32       tableSz;
    1.50 -   int32       numEntries;
    1.51 -   HashEntry* *entries;
    1.52 -   int32       hashMask;
    1.53 -   int32       prevHash;
    1.54 -   FreeEntryContentFnPtr freeEntryContentFn;
    1.55 - }
    1.56 -HashTable;
    1.57 -
    1.58 -
    1.59 -//===========================================================================
    1.60 -//   Public functions
    1.61 -HashTable   *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
    1.62 -
    1.63 -int32        putEntryIntoTable( HashEntry *entry, HashTable *table);
    1.64 -int32        addValueIntoTable( char* key, void *value, HashTable *table);
    1.65 -HashEntry   *getEntryFromTable( char *key, HashTable *table );
    1.66 -void        *getValueFromTable( char *key, HashTable *table );
    1.67 -
    1.68 -bool8        deleteEntryFromTable( char *key, HashTable *table );
    1.69 -bool8        deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
    1.70 -bool8        deleteEntrysValueInTable( char *key, HashTable *table );
    1.71 -bool8        deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
    1.72 -void         freeHashTable( HashTable *table );
    1.73 -//char        *paramBagToString( ParamBag * bag )
    1.74 -
    1.75 -//================= Same Fns, but for 32b array key hash fn ================
    1.76 -HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn);
    1.77 -HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn );
    1.78 -
    1.79 -int32      putEntryIntoTable32( HashEntry *entry, HashTable *table);
    1.80 -HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table);
    1.81 -HashEntry *getEntryFromTable32( uint32 key[], HashTable *table );
    1.82 -void      *getValueFromTable32( uint32 key[], HashTable *table );
    1.83 -
    1.84 -bool32     deleteEntryFromTable32( uint32 key[], HashTable *table );
    1.85 -
    1.86 -//===========================================================================
    1.87 -//   Internal functions
    1.88 -void         freeHashEntryUsing( HashEntry *entry, HashTable *table );
    1.89 -unsigned int hashThisKey( char *s, int hashSz );
    1.90 -void         nullOutTablesArray( HashTable *table );
    1.91 -void         doubleTableSize( HashTable *table );
    1.92 -void         freeHashEntryButNotContent( HashEntry *entry );
    1.93 -
    1.94 -uint32 
    1.95 -jenkHash32( const uint32  *key,     /* array of uint32 values */
    1.96 -                   int32   length);  /* num uint32 in the key */
    1.97 -        
    1.98 -#endif	/* _PRIVATE_HASH_H */
    1.99 -
   1.100 +/*
   1.101 + *  Copyright 2009 OpenSourceResearchInstitute.org
   1.102 + *  Licensed under GNU General Public License version 2
   1.103 + *
   1.104 + * Author: seanhalle@yahoo.com
   1.105 + */
   1.106 +
   1.107 +#ifndef _PRHASH_H
   1.108 +#define	_PRHASH_H
   1.109 +
   1.110 +#include <stdio.h>
   1.111 +#include <string.h>
   1.112 +#include <errno.h>
   1.113 +#include <stdlib.h>
   1.114 +
   1.115 +#include <PR__include/PR__primitive_data_types.h>
   1.116 +
   1.117 +//=====================  defines  =====================
   1.118 +#define TRUE     1
   1.119 +#define FALSE    0
   1.120 +
   1.121 +#define DEFAULT_HASH_TABLE_SIZE 1 << 10
   1.122 +#define DEFAULT_POWER_OF_2_TABLE_SIZE 10
   1.123 +
   1.124 +
   1.125 +//=====================  structs  =====================
   1.126 +union hashkey_t{
   1.127 +    char hashable[8];
   1.128 +    int32 parts[2];
   1.129 +};
   1.130 +
   1.131 +typedef union hashkey_t hashkey_t;
   1.132 +
   1.133 +typedef struct _HashEntry HashEntry;
   1.134 +
   1.135 +struct _HashEntry
   1.136 + {
   1.137 +   char       *key;
   1.138 +   void       *content;
   1.139 +   HashEntry  *next;
   1.140 + };
   1.141 +
   1.142 +typedef void (*FreeEntryContentFnPtr)    ( void * );
   1.143 +
   1.144 +typedef struct
   1.145 + { int32       tableSz;
   1.146 +   int32       numEntries;
   1.147 +   HashEntry* *entries;
   1.148 +   int32       hashMask;
   1.149 +   int32       prevHash;
   1.150 +   FreeEntryContentFnPtr freeEntryContentFn;
   1.151 + }
   1.152 +HashTable;
   1.153 +
   1.154 +
   1.155 +//===========================================================================
   1.156 +//   Public functions
   1.157 +HashTable   *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
   1.158 +
   1.159 +int32        putEntryIntoTable( HashEntry *entry, HashTable *table);
   1.160 +int32        addValueIntoTable( char* key, void *value, HashTable *table);
   1.161 +HashEntry   *getEntryFromTable( char *key, HashTable *table );
   1.162 +void        *getValueFromTable( char *key, HashTable *table );
   1.163 +
   1.164 +bool8        deleteEntryFromTable( char *key, HashTable *table );
   1.165 +bool8        deleteThisEntryFromTable( HashEntry *entry, HashTable *table );
   1.166 +bool8        deleteEntrysValueInTable( char *key, HashTable *table );
   1.167 +bool8        deleteEntryFromTableAndFreeValue( char *key, HashTable *table );
   1.168 +void         freeHashTable( HashTable *table );
   1.169 +//char        *paramBagToString( ParamBag * bag )
   1.170 +
   1.171 +//================= Same Fns, but for 32b array key hash fn ================
   1.172 +HashTable *makeHashTable32(int32 powerOf2OfSz, FreeEntryContentFnPtr freeFn);
   1.173 +HashTable *makeDefaultSizeHashTable32( FreeEntryContentFnPtr freeFn );
   1.174 +
   1.175 +int32      putEntryIntoTable32( HashEntry *entry, HashTable *table);
   1.176 +HashEntry *addValueIntoTable32( uint32 key[], void *value, HashTable *table);
   1.177 +HashEntry *getEntryFromTable32( uint32 key[], HashTable *table );
   1.178 +void      *getValueFromTable32( uint32 key[], HashTable *table );
   1.179 +
   1.180 +bool32     deleteEntryFromTable32( uint32 key[], HashTable *table );
   1.181 +
   1.182 +//===========================================================================
   1.183 +//   Internal functions
   1.184 +void         freeHashEntryUsing( HashEntry *entry, HashTable *table );
   1.185 +unsigned int hashThisKey( char *s, int hashSz );
   1.186 +void         nullOutTablesArray( HashTable *table );
   1.187 +void         doubleTableSize( HashTable *table );
   1.188 +void         freeHashEntryButNotContent( HashEntry *entry );
   1.189 +
   1.190 +uint32 
   1.191 +jenkHash32( const uint32  *key,     /* array of uint32 values */
   1.192 +                   int32   length);  /* num uint32 in the key */
   1.193 +        
   1.194 +#endif	/* _PRIVATE_HASH_H */
   1.195 +