diff PrivateHash.h @ 0:ee3ad252427e

Initial add
author Me
date Sat, 22 May 2010 19:49:28 -0700
parents
children 5900d90f5d71
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/PrivateHash.h	Sat May 22 19:49:28 2010 -0700
     1.3 @@ -0,0 +1,60 @@
     1.4 +/*
     1.5 + *  Copyright 2009 OpenSourceStewardshipFoundation.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 _PRIVATE_HASH_H
    1.12 +#define	_PRIVATE_HASH_H
    1.13 +
    1.14 +
    1.15 +#define TRUE     1
    1.16 +#define FALSE    0
    1.17 +
    1.18 +
    1.19 +#define HASHSIZE 101
    1.20 +
    1.21 +typedef struct _HashEntry HashEntry;
    1.22 +
    1.23 +struct _HashEntry
    1.24 + {
    1.25 +   char       *key;
    1.26 +   void       *content;
    1.27 +   HashEntry  *next;
    1.28 + };
    1.29 +
    1.30 +typedef void (*FreeEntryContentFnPtr)    ( void * );
    1.31 +
    1.32 +typedef struct
    1.33 + { int tableSz;
    1.34 +   int numEntries;
    1.35 +   HashEntry* *entries;
    1.36 +   FreeEntryContentFnPtr freeEntryContentFn;
    1.37 + }
    1.38 +HashTable;
    1.39 +
    1.40 +//===========================================================================
    1.41 +//   Internal functions
    1.42 +void         freeHashEntryUsing( HashEntry *entry, HashTable *table );
    1.43 +char*        strdup_m(char *o);
    1.44 +unsigned int hashThisKey( char *s, int hashSz );
    1.45 +void         nullOutTablesArray( HashTable *table );
    1.46 +void        *getEntryFromTable( char *key, HashTable *table );
    1.47 +void         doubleTableSize( HashTable *table );
    1.48 +void         addEntryToTable( HashEntry *entry, HashTable *table );
    1.49 +
    1.50 +//===========================================================================
    1.51 +//   Public functions
    1.52 +HashTable   *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
    1.53 +
    1.54 +void        *getValueFromTable( char *key, HashTable *table );
    1.55 +bool8        deleteEntryFromTable( char *key, HashTable *table );
    1.56 +bool8        deleteEntrysValueInTable( char *key, HashTable *table );
    1.57 +
    1.58 +int          addToTable( char* key, void *content, HashTable *table );
    1.59 +void         freeTable( HashTable *table );
    1.60 +//char        *paramBagToString( ParamBag * bag )
    1.61 +
    1.62 +#endif	/* _PRIVATE_HASH_H */
    1.63 +