Changeset 1b20da0 in mainline for uspace/lib/c/include/adt/hash.h
- Timestamp:
- 2018-02-28T17:52:03Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3061bc1
- Parents:
- df6ded8
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/hash.h
rdf6ded8 r1b20da0 46 46 * Public domain. 47 47 */ 48 hash = ~hash + (hash << 15); 48 hash = ~hash + (hash << 15); 49 49 hash = hash ^ (hash >> 12); 50 50 hash = hash + (hash << 2); 51 51 hash = hash ^ (hash >> 4); 52 hash = hash * 2057; 52 hash = hash * 2057; 53 53 hash = hash ^ (hash >> 16); 54 return hash; 54 return hash; 55 55 } 56 56 … … 66 66 hash = hash ^ (hash >> 4); 67 67 hash = hash * 0x27d4eb2d; 68 hash = hash ^ (hash >> 15); 69 /* 68 hash = hash ^ (hash >> 15); 69 /* 70 70 * Lower order bits are mixed more thoroughly. Swap them with 71 71 * the higher order bits and make the resulting higher order bits … … 76 76 77 77 /** Produces a uniform hash affecting all output bits from the skewed input. */ 78 static inline size_t hash_mix(size_t hash) 78 static inline size_t hash_mix(size_t hash) 79 79 { 80 80 #ifdef __32_BITS__ … … 88 88 89 89 /** Use to create a hash from multiple values. 90 * 90 * 91 91 * Typical usage: 92 92 * @code … … 102 102 static inline size_t hash_combine(size_t seed, size_t hash) 103 103 { 104 /* 104 /* 105 105 * todo: use Bob Jenkin's proper mixing hash pass: 106 106 * http://burtleburtle.net/bob/c/lookup3.c 107 107 */ 108 seed ^= hash + 0x9e3779b9 108 seed ^= hash + 0x9e3779b9 109 109 + ((seed << 5) | (seed >> (sizeof(size_t) * 8 - 5))); 110 return seed; 110 return seed; 111 111 } 112 112
Note:
See TracChangeset
for help on using the changeset viewer.