2 * hash.h - hashing routines mainly used for caching key details.
4 * Copyright 2000-2002 Jonathan McDowell <noodles@earth.li>
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "keystructs.h"
28 #define HASHMASK 0x3FF
31 * inithash - Initialize the hash ready for use.
33 * This function prepares the hash ready for use. It should be called
34 * before any of the functions below are used.
39 * destroyhash - Clean up the hash after use.
41 * This function destroys the hash after use, freeing any memory that was
42 * used during its lifetime.
44 void destroyhash(void);
47 * addtohash - Adds a key to the hash.
48 * @key: The key to add.
50 * Takes a key and stores it in the hash.
52 void addtohash(struct stats_key *key);
55 * createandaddtohash - Creates a key and adds it to the hash.
56 * @keyid: The key to create and add.
58 * Takes a key, checks if it exists in the hash and if not creates it
59 * and adds it to the hash. Returns the key from the hash whether it
60 * already existed or we just created it.
62 struct stats_key *createandaddtohash(uint64_t keyid);
65 * findinhash - Finds a key in the hash.
66 * @keyid: The key we want.
68 * Finds a key in the hash and returns it.
70 struct stats_key *findinhash(uint64_t keyid);
73 * hashelements - Returns the size of the hash
75 * Returns the number of elements that have been loaded into the hash.
77 unsigned long hashelements(void);
80 * gethashtableentry - Returns an entry from the hash table.
81 * @entry: The entry to return. 0 <= entry < HASHSIZE must hold.
83 * Gets a particular entry from the hash. Useful for doing something over
84 * all entries in the hash.
86 struct ll *gethashtableentry(unsigned int entry);
88 #endif /* __HASH_H__ */