/* ECP: FILEname=fig10_22.c */ /* 1*/ #include /* 2*/ #include /* 3*/ #define NotFound (-1) /* 4*/ typedef struct HashEntry /* 5*/ { /* 6*/ char *Word; /* 7*/ int Num; /* 8*/ } Cell; /* 9*/ typedef struct HashStr /*10*/ { /*11*/ Cell *Array; /* The Array Of Cells */ /*12*/ int Size; /* Current Number Of Elements in Table */ /*13*/ int MaxSize; /* Maximum Table Size */ /*14*/ } *HashTbl; /*15*/ static const HaInitSize = 17; /* 1*/ unsigned int /* 2*/ Hash( const char *Key, const unsigned int TableSize ) /* 3*/ { /* 4*/ unsigned int HashVal = 0; /* 5*/ while( *Key != '\0' ) /* 6*/ HashVal = HashVal * 37 + *Key++; /* 7*/ return HashVal % TableSize; /* 8*/ }