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"
27 #define HASHMASK 0x3FF
30 * inithash - Initialize the hash ready for use.
32 * This function prepares the hash ready for use. It should be called
33 * before any of the functions below are used.
38 * destroyhash - Clean up the hash after use.
40 * This function destroys the hash after use, freeing any memory that was
41 * used during its lifetime.
43 void destroyhash(void);
46 * addtohash - Adds a key to the hash.
47 * @key: The key to add.
49 * Takes a key and stores it in the hash.
51 void addtohash(struct stats_key *key);
54 * createandaddtohash - Creates a key and adds it to the hash.
55 * @keyid: The key to create and add.
57 * Takes a key, checks if it exists in the hash and if not creates it
58 * and adds it to the hash. Returns the key from the hash whether it
59 * already existed or we just created it.
61 struct stats_key *createandaddtohash(uint64_t keyid);
64 * findinhash - Finds a key in the hash.
65 * @keyid: The key we want.
67 * Finds a key in the hash and returns it.
69 struct stats_key *findinhash(uint64_t keyid);
72 * hashelements - Returns the size of the hash
74 * Returns the number of elements that have been loaded into the hash.
76 unsigned long hashelements(void);
79 * gethashtableentry - Returns an entry from the hash table.
80 * @entry: The entry to return. 0 <= entry < HASHSIZE must hold.
82 * Gets a particular entry from the hash. Useful for doing something over
83 * all entries in the hash.
85 struct ll *gethashtableentry(unsigned int entry);
87 #endif /* __HASH_H__ */