00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef _SFGHASH_
00012 #define _SFGHASH_
00013 
00014 #include <stdlib.h>
00015 #include <string.h>
00016 #include <time.h>
00017 
00018 #include "sfhashfcn.h"
00019 
00020 
00021 
00022 
00023 #define SFGHASH_NOMEM    -2
00024 #define SFGHASH_ERR      -1
00025 #define SFGHASH_OK        0
00026 #define SFGHASH_INTABLE   1
00027 
00028 
00029 
00030 
00031 #define GH_COPYKEYS 0
00032 #define GH_USERKEYS 1
00033 
00034 
00035 
00036 
00037 typedef struct _sfghash_node
00038 {
00039   struct _sfghash_node * next, * prev;
00040 
00041   void * key;   
00042   void * data;  
00043      
00044 } SFGHASH_NODE;
00045 
00046 
00047 
00048 
00049 typedef struct _sfghash
00050 {
00051   SFHASHFCN    * sfhashfcn;
00052   int          keysize;   
00053   int          userkey;   
00054 
00055   SFGHASH_NODE ** table;  
00056   int             nrows;  
00057 
00058   unsigned       count;  
00059 
00060   void         (*userfree)( void * );  
00061 
00062   int            crow;    
00063   SFGHASH_NODE * cnode; 
00064 
00065   int splay;
00066 
00067 } SFGHASH, SFDICT;
00068 
00069 
00070 
00071 
00072 
00073 SFGHASH * sfghash_new( int nrows, int keysize, int userkeys, void (*userfree)(void*p) );
00074 void      sfghash_delete( SFGHASH * h );
00075 int       sfghash_add ( SFGHASH * h, void * key, void * data );
00076 int       sfghash_remove( SFGHASH * h, void * key);
00077 int       sfghash_count( SFGHASH * h);
00078 void    * sfghash_find( SFGHASH * h, void * key );
00079 SFGHASH_NODE * sfghash_findfirst( SFGHASH * h );
00080 SFGHASH_NODE * sfghash_findnext ( SFGHASH * h );
00081 
00082 
00083 
00084 
00085 
00086 
00087 int    sfatom_setsize( int n );
00088 int    sfatom_init();
00089 int    sfatom_reset();
00090 int    sfatom_add(char * str, void * data);
00091 int    sfatom_remove(char * str);
00092 int    sfatom_count();
00093 void * sfatom_find(char * str);
00094 SFGHASH_NODE * sfatom_findfirst();
00095 SFGHASH_NODE * sfatom_findnext();
00096 
00097 #endif
00098