#include <stdio.h>
#include <sys/types.h>
#include "general.h"
#include "sih.h"
#include <stdlib.h>
Go to the source code of this file.
Defines | |
#define | HASH_VERSION 940728 |
#define | SIH_KEY(STRING, KEY) |
Functions | |
int | nearest_prime_up (int num) |
sih_t * | sih_create (int initial_size, double max_occupancy, double growth_ratio, int warn_on_update) |
void | sih_add (sih_t *ht, char *string, int32 intval) |
char | sih_lookup (sih_t *ht, char *string, int32 *p_intval) |
void * | sih_val_write_to_file (sih_t *ht, FILE *fp, char *filename, int verbosity) |
void * | sih_val_read_from_file (sih_t *ht, FILE *fp, char *filename, int verbosity) |
Definition in file sih.c.
|
Definition at line 41 of file sih.c. Referenced by sih_val_read_from_file(), and sih_val_write_to_file(). |
|
Value: {\ int i = 0; \ char *pstr = STRING; \ KEY = 0; \ do {KEY += *pstr++ << (0xF & --i);} while (*pstr); \ } Definition at line 42 of file sih.c. Referenced by sih_add(), and sih_lookup(). |
|
return the nearest prime not smaller than 'num' Definition at line 50 of file sih.c. Referenced by sih_add(), and sih_create(). |
|
Add an entry to hash
Definition at line 91 of file sih.c. References fprintf(), free(), sih_t::growth_ratio, int32, intval, sih_slot_t::intval, sih_t::max_occupancy, nearest_prime_up(), sih_t::nentries, sih_t::nslots, quit(), rr_calloc(), SIH_KEY, sih_t::slots, sih_slot_t::string, and sih_t::warn_on_update. Referenced by load_arpa_lm(), and read_wlist_into_siht(). |
|
Create a string to integer hash
Definition at line 69 of file sih.c. References sih_t::growth_ratio, MAX, sih_t::max_occupancy, nearest_prime_up(), sih_t::nentries, sih_t::nslots, quit(), rr_calloc(), rr_malloc(), sih_t::slots, and sih_t::warn_on_update. Referenced by load_arpa_lm(), and main(). |
|
Lookup the hash table
Definition at line 145 of file sih.c. References int32, sih_slot_t::intval, sih_t::nslots, quit(), SIH_KEY, sih_t::slots, and sih_slot_t::string. Referenced by compute_perplexity(), gen_fb_list(), load_arpa_lm(), main(), and validate(). |
|
Read the value from a file to a hash
Definition at line 227 of file sih.c. References fprintf(), sih_t::growth_ratio, HASH_VERSION, int32, sih_slot_t::intval, sih_t::max_occupancy, sih_t::nentries, sih_t::nslots, quit(), rr_calloc(), rr_fread(), rr_malloc(), sih_t::slots, sih_slot_t::string, verbosity, and sih_t::warn_on_update. Referenced by load_lm(), and read_voc(). |
|
Read/Write from/to a file an (almost) ready-to-use hash table. The hash-table is a string->int mapping. All intvals are written out, whether or not they belong to active entries. All strings are writen out too, where an empty entry is represented in the file as a null string (null strings as entries are not allowed).
Definition at line 181 of file sih.c. References fprintf(), sih_t::growth_ratio, HASH_VERSION, int32, sih_slot_t::intval, sih_t::max_occupancy, sih_t::nentries, sih_t::nslots, quit(), rr_fwrite(), sih_t::slots, sih_slot_t::string, verbosity, and sih_t::warn_on_update. Referenced by write_bin_lm(). |