2 * hash.h - hashing routines mainly used for caching key details.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2000-2002 Project Purple
8 * $Id: hash.h,v 1.5 2003/10/11 21:52:18 noodles Exp $
14 #include "keystructs.h"
18 #define HASHMASK 0x3FF
21 * inithash - Initialize the hash ready for use.
23 * This function prepares the hash ready for use. It should be called
24 * before any of the functions below are used.
29 * destroyhash - Clean up the hash after use.
31 * This function destroys the hash after use, freeing any memory that was
32 * used during its lifetime.
34 void destroyhash(void);
37 * addtohash - Adds a key to the hash.
38 * @key: The key to add.
40 * Takes a key and stores it in the hash.
42 void addtohash(struct stats_key *key);
45 * createandaddtohash - Creates a key and adds it to the hash.
46 * @keyid: The key to create and add.
48 * Takes a key, checks if it exists in the hash and if not creates it
49 * and adds it to the hash. Returns the key from the hash whether it
50 * already existed or we just created it.
52 struct stats_key *createandaddtohash(uint64_t keyid);
55 * findinhash - Finds a key in the hash.
56 * @keyid: The key we want.
58 * Finds a key in the hash and returns it.
60 struct stats_key *findinhash(uint64_t keyid);
63 * hashelements - Returns the size of the hash
65 * Returns the number of elements that have been loaded into the hash.
67 unsigned long hashelements(void);
70 * gethashtableentry - Returns an entry from the hash table.
71 * @entry: The entry to return. 0 <= entry < HASHSIZE must hold.
73 * Gets a particular entry from the hash. Useful for doing something over
74 * all entries in the hash.
76 struct ll *gethashtableentry(unsigned int entry);
78 #endif /* __HASH_H__ */