-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash.h
63 lines (55 loc) · 1.59 KB
/
hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Licensed under the MIT License.
#include <stddef.h>
#include <stdint.h>
#include "object.h"
/** Defines a method that a type implements to hash an object. */
typedef size_t (*Hash)(Object item, size_t size);
/**
* Computes the Daniel J. Bernstein (djb2) hash digest.
*
* @param item the object.
* @param size the size of the `item` argument.
* @return A hash code for the given item.
*/
size_t djb2_hash(Object item, size_t size);
/**
* Computes the PJW hash function used for Unix ELF files.
*
* @param item the object.
* @param size the size of the `item` argument.
* @return A hash code for the given item.
*/
size_t pjw_hash(Object item, size_t size);
/**
* Computes the PJW hash function used for Unix ELF files and returns a value
* truncated to exactly 32 bits.
*
* @param item the object.
* @param size the size of the `item` argument.
* @return A 32-bit hash code for the given item.
*/
uint32_t pjw_hash32(Object item, size_t size);
/**
* Computes the SDBM hash digest.
*
* @param item the object.
* @param size the size of the `item` argument.
* @return A hash code for the given item.
*/
size_t sdbm_hash(Object item, size_t size);
/**
* Computes a hash by padding an integer value.
*
* @param item the object.
* @param size the size of the `item` argument.
* @return A hash code for the given item.
*/
size_t long_hash(Object item, size_t size);
/**
* Computes a hash by padding an integer value.
*
* @param item the object.
* @param size the size of the `item` argument.
* @return A hash code for the given item.
*/
size_t long_long_hash(Object item, size_t size);