1 /* I2Ohash.h */ 2 3 #include "../Utilities.h" 4 5 /*--------------------------------------------------------------------*/ 6 typedef struct _I2Ohash I2Ohash ; 7 struct _I2Ohash { 8 int nlist ; 9 int grow ; 10 int nitem ; 11 I2OP *baseI2OP ; 12 I2OP *freeI2OP ; 13 I2OP **heads ; 14 } ; 15 /*--------------------------------------------------------------------*/ 16 /* 17 ------------------------------------------------------------------------ 18 ----- methods found in basics.c --------------------------------------- 19 ------------------------------------------------------------------------ 20 */ 21 /* 22 ----------------------------------------------------- 23 create and return a new instance of the I2Ohash object 24 25 created -- 98jan29, cca 26 ----------------------------------------------------- 27 */ 28 I2Ohash * 29 I2Ohash_new ( 30 void 31 ) ; 32 /* 33 ------------------------------------------- 34 set the default fields for an I2Ohash object 35 36 created -- 98jan29, cca 37 ------------------------------------------- 38 */ 39 void 40 I2Ohash_setDefaultFields ( 41 I2Ohash *hashtbl 42 ) ; 43 /* 44 ----------------------- 45 clear the data fields 46 47 created -- 98jan29, cca 48 ----------------------- 49 */ 50 void 51 I2Ohash_clearData ( 52 I2Ohash *hashtbl 53 ) ; 54 /* 55 ----------------------- 56 free the I2Ohash object 57 58 created -- 98jan29, cca 59 ----------------------- 60 */ 61 void 62 I2Ohash_free ( 63 I2Ohash *hashtbl 64 ) ; 65 /*--------------------------------------------------------------------*/ 66 /* 67 ------------------------------------------------------------------------ 68 ----- methods found in init.c ----------------------------------------- 69 ------------------------------------------------------------------------ 70 */ 71 /* 72 ------------------------------------------ 73 initializer, 74 (1) set the number of lists to nlist 75 and allocate the heads[] vector 76 (2) initialize nobj I2OP objects 77 (2) set hashtbl item growth factor to grow 78 79 created -- 98jan29, cca 80 ------------------------------------------ 81 */ 82 void 83 I2Ohash_init ( 84 I2Ohash *hashtbl, 85 int nlist, 86 int nobj, 87 int grow 88 ) ; 89 /*--------------------------------------------------------------------*/ 90 /* 91 ------------------------------------------------------------------------ 92 ----- methods found in util.c ----------------------------------------- 93 ------------------------------------------------------------------------ 94 */ 95 /* 96 --------------------------------------------------------- 97 insert the (key1, key2, value) triple into the hash table 98 99 created -- 98jan29, cca 100 --------------------------------------------------------- 101 */ 102 void 103 I2Ohash_insert ( 104 I2Ohash *hashtbl, 105 int key1, 106 int key2, 107 void *value 108 ) ; 109 /* 110 ------------------------------------------------ 111 locate the first (key1,key2,*) in the hash table 112 113 return value -- 114 0 -- no (key1,key2,*) value triple 115 1 -- (key1,key2,value) value triple found, 116 value put into *pvalue 117 118 created -- 98jan29, cca 119 ------------------------------------------------ 120 */ 121 int 122 I2Ohash_locate ( 123 I2Ohash *hashtbl, 124 int key1, 125 int key2, 126 void **pvalue 127 ) ; 128 /* 129 -------------------------------------------------- 130 remove the first (key1,key2,*) from the hash table 131 132 return value -- 133 0 -- no (key1,key2,*) value triple 134 1 -- (key1,key2,value) value triple found, 135 value put into *pvalue 136 137 created -- 98jan29, cca 138 -------------------------------------------------- 139 */ 140 int 141 I2Ohash_remove ( 142 I2Ohash *hashtbl, 143 int key1, 144 int key2, 145 void **pvalue 146 ) ; 147 /* 148 --------------------------------------------------------------- 149 return a measure of the nonuniform distribution of the entries. 150 a value of 1.0 is best. 151 152 created -- 98jan29, cca 153 --------------------------------------------------------------- 154 */ 155 double 156 I2Ohash_measure ( 157 I2Ohash *hashtbl 158 ) ; 159 /*--------------------------------------------------------------------*/ 160 /* 161 ------------------------------------------------------------------------ 162 ----- methods found in IO.c ------------------------------------------- 163 ------------------------------------------------------------------------ 164 */ 165 /* 166 ----------------------------------------------- 167 purpose -- to write the I2Ohash object to a file 168 169 created -- 98jan29, cca 170 ----------------------------------------------- 171 */ 172 void 173 I2Ohash_writeForHumanEye ( 174 I2Ohash *hashtbl, 175 FILE *fp 176 ) ; 177 /*--------------------------------------------------------------------*/ 178