/** * hash.h * An specification of hash tables, based loosely on code from K&R 2nd, * pp. 143-145. */ #ifndef __HASH_H__ #define __HASH_H__ // +-------+---------------------------------------------------------- // | Types | // +-------+ /** * Hash tables. */ struct hash { int size; struct nlist *contents[]; }; // struct hash // +-----------+------------------------------------------------------ // | Functions | // +-----------+ /** * new_hash(size) - create a new hash table of the specified size. * Returns a pointer to the table upon success or NULL upon failure. */ struct hash *new_hash (int size); /** * install - install a new key/value pair in the hash table. * Returns 1 upon success and 0 upon failure. */ int install (struct hash *hash, char *key, char *value); /** * find - given a key, find the corresponding value. * Returns the corresponding value if found, and NULL if not found. */ char *find (struct hash *hash, char *key); #endif // __HASH_H__