2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
10 * generic hash functions
13 #ifndef SATSOLVER_HASH_H
14 #define SATSOLVER_HASH_H
16 #include "pooltypes.h"
19 typedef unsigned int Hashval;
20 /* mask for hash, used as modulo operator to ensure 'wrapping' of hash
21 values -> hash table */
22 typedef unsigned int Hashmask;
24 /* inside the hash table, Ids are stored. Hash maps: string -> hash -> Id */
25 typedef Id *Hashtable;
28 #define HASHCHAIN_START 7
29 #define HASHCHAIN_NEXT(h, hh, mask) (((h) + (hh)++) & (mask))
31 /* very simple hash function
35 strhash(const char *str)
39 while ((c = *(const unsigned char *)str++) != 0)
48 relhash(Id name, Id evr, int flags)
50 return name + 7 * evr + 13 * flags;
54 /* compute bitmask for value
55 * returns smallest (2^n-1) > num
57 * used for Hashtable 'modulo' operation
59 static inline Hashmask
60 mkmask(unsigned int num)
63 while (num & (num - 1))
68 #endif /* SATSOLVER_HASH_H */