view PrivateHash.h @ 0:ee3ad252427e

Initial add
author Me
date Sat, 22 May 2010 19:49:28 -0700
parents
children 5900d90f5d71
line source
1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 */
8 #ifndef _PRIVATE_HASH_H
9 #define _PRIVATE_HASH_H
12 #define TRUE 1
13 #define FALSE 0
16 #define HASHSIZE 101
18 typedef struct _HashEntry HashEntry;
20 struct _HashEntry
21 {
22 char *key;
23 void *content;
24 HashEntry *next;
25 };
27 typedef void (*FreeEntryContentFnPtr) ( void * );
29 typedef struct
30 { int tableSz;
31 int numEntries;
32 HashEntry* *entries;
33 FreeEntryContentFnPtr freeEntryContentFn;
34 }
35 HashTable;
37 //===========================================================================
38 // Internal functions
39 void freeHashEntryUsing( HashEntry *entry, HashTable *table );
40 char* strdup_m(char *o);
41 unsigned int hashThisKey( char *s, int hashSz );
42 void nullOutTablesArray( HashTable *table );
43 void *getEntryFromTable( char *key, HashTable *table );
44 void doubleTableSize( HashTable *table );
45 void addEntryToTable( HashEntry *entry, HashTable *table );
47 //===========================================================================
48 // Public functions
49 HashTable *makeHashTable( int numHashSlots, FreeEntryContentFnPtr freeFn );
51 void *getValueFromTable( char *key, HashTable *table );
52 bool8 deleteEntryFromTable( char *key, HashTable *table );
53 bool8 deleteEntrysValueInTable( char *key, HashTable *table );
55 int addToTable( char* key, void *content, HashTable *table );
56 void freeTable( HashTable *table );
57 //char *paramBagToString( ParamBag * bag )
59 #endif /* _PRIVATE_HASH_H */