• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/bash-94.1.2/bash-3.2/

Lines Matching +defs:table +defs:string

43 /* Make a new hash table with BUCKETS number of buckets.  Initialize
44 each slot in the table to NULL. */
68 hash_size (table)
69 HASH_TABLE *table;
71 return (HASH_ENTRIES(table));
109 hash_copy (table, cpdata)
110 HASH_TABLE *table;
116 if (table == 0)
119 new_table = hash_create (table->nbuckets);
121 for (i = 0; i < table->nbuckets; i++)
122 new_table->bucket_array[i] = copy_bucket_array (table->bucket_array[i], cpdata);
124 new_table->nentries = table->nentries;
136 /* This is the best string hash function I found.
154 hash_bucket (string, table)
155 const char *string;
156 HASH_TABLE *table;
160 return (HASH_BUCKET (string, table, h));
164 create a new hash table entry for STRING, otherwise return NULL. */
166 hash_search (string, table, flags)
167 const char *string;
168 HASH_TABLE *table;
175 if (table == 0 || ((flags & HASH_CREATE) == 0 && HASH_ENTRIES (table) == 0))
178 bucket = HASH_BUCKET (string, table, hv);
180 for (list = table->bucket_array[bucket]; list; list = list->next)
182 if (hv == list->khash && STREQ (list->key, string))
192 list->next = table->bucket_array[bucket];
193 table->bucket_array[bucket] = list;
196 list->key = (char *)string; /* XXX fix later */
200 table->nentries++;
207 /* Remove the item specified by STRING from the hash table TABLE.
209 the item isn't in this table NULL is returned. */
211 hash_remove (string, table, flags)
212 const char *string;
213 HASH_TABLE *table;
220 if (table == 0 || HASH_ENTRIES (table) == 0)
223 bucket = HASH_BUCKET (string, table, hv);
225 for (temp = table->bucket_array[bucket]; temp; temp = temp->next)
227 if (hv == temp->khash && STREQ (temp->key, string))
232 table->bucket_array[bucket] = temp->next;
234 table->nentries--;
245 hash_insert (string, table, flags)
246 char *string;
247 HASH_TABLE *table;
254 if (table == 0)
255 table = hash_create (0);
258 : hash_search (string, table, 0);
262 bucket = HASH_BUCKET (string, table, hv);
265 item->next = table->bucket_array[bucket];
266 table->bucket_array[bucket] = item;
269 item->key = string;
273 table->nentries++;
283 hash_flush (table, free_data)
284 HASH_TABLE *table;
290 if (table == 0 || HASH_ENTRIES (table) == 0)
293 for (i = 0; i < table->nbuckets; i++)
295 bucket = table->bucket_array[i];
309 table->bucket_array[i] = (BUCKET_CONTENTS *)NULL;
312 table->nentries = 0;
315 /* Free the hash table pointed to by TABLE. */
317 hash_dispose (table)
318 HASH_TABLE *table;
320 free (table->bucket_array);
321 free (table);
325 hash_walk (table, func)
326 HASH_TABLE *table;
332 if (table == 0 || HASH_ENTRIES (table) == 0)
335 for (i = 0; i < table->nbuckets; i++)
337 for (item = hash_items (i, table); item; item = item->next)
345 hash_pstats (table, name)
346 HASH_TABLE *table;
353 name = "unknown hash table";
355 fprintf (stderr, "%s: %d buckets; %d items\n", name, table->nbuckets, table->nentries);
359 for (slot = 0; slot < table->nbuckets; slot++)
361 bc = hash_items (slot, table);
382 HASH_TABLE *table, *ntable;
407 char string[256];
411 table = hash_create (0);
416 if (fgets (string, sizeof (string), stdin) == 0)
418 if (!*string)
420 temp_string = savestring (string);
421 tt = hash_insert (temp_string, table, 0);
424 fprintf (stderr, "You have already added item `%s'\n", string);
433 hash_pstats (table, "hash test");
435 ntable = hash_copy (table, (sh_string_func_t *)NULL);
436 hash_flush (table, (sh_free_func_t *)NULL);