| 1 | /* hash.h
|
|---|
| 2 | *
|
|---|
| 3 | * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2005
|
|---|
| 4 | * by Larry Wall and others
|
|---|
| 5 | *
|
|---|
| 6 | * You may distribute under the terms of either the GNU General Public
|
|---|
| 7 | * License or the Artistic License, as specified in the README file.
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #define FILLPCT 60 /* don't make greater than 99 */
|
|---|
| 11 |
|
|---|
| 12 | #ifdef DOINIT
|
|---|
| 13 | char const coeff[] = {
|
|---|
| 14 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 15 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 16 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 17 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 18 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 19 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 20 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1,
|
|---|
| 21 | 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1};
|
|---|
| 22 | #else
|
|---|
| 23 | extern const char coeff[];
|
|---|
| 24 | #endif
|
|---|
| 25 |
|
|---|
| 26 | typedef struct hentry HENT;
|
|---|
| 27 |
|
|---|
| 28 | struct hentry {
|
|---|
| 29 | HENT *hent_next;
|
|---|
| 30 | char *hent_key;
|
|---|
| 31 | STR *hent_val;
|
|---|
| 32 | int hent_hash;
|
|---|
| 33 | };
|
|---|
| 34 |
|
|---|
| 35 | struct htbl {
|
|---|
| 36 | HENT **tbl_array;
|
|---|
| 37 | int tbl_max;
|
|---|
| 38 | int tbl_fill;
|
|---|
| 39 | int tbl_riter; /* current root of iterator */
|
|---|
| 40 | HENT *tbl_eiter; /* current entry of iterator */
|
|---|
| 41 | };
|
|---|
| 42 |
|
|---|
| 43 | STR * hfetch ( HASH *tb, char *key );
|
|---|
| 44 | int hiterinit ( HASH *tb );
|
|---|
| 45 | HASH * hnew ( void );
|
|---|
| 46 | void hsplit ( HASH *tb );
|
|---|
| 47 | bool hstore ( HASH *tb, char *key, STR *val );
|
|---|