-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash.cpp
62 lines (48 loc) · 846 Bytes
/
hash.cpp
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
#include "hash.h"
u32 get_hash(String s)
{
u32 hash = 5381;
for (auto it : s) hash = ((hash << 5) + hash) + it;
return hash;
}
u32 get_hash(char c)
{
// @Fixme: replace this madeup hash function with something real
u32 hash = 5381;
return (hash << 5) + (c << 2) + c;
}
// For key_down_state_table
u32 get_hash(u32 x)
{
return x;
}
u32 get_hash(i64 x)
{
if (x < 0) return -x;
return x;
}
u32 get_hash(_type_Type x)
{
return static_cast<u32>(x.hash_code());
}
bool equal(i64 a, i64 b)
{
return a == b;
}
bool equal(u64 a, u64 b)
{
return a == b;
}
bool equal(u32 a, u32 b)
{
return a == b;
}
bool equal(_type_Type a, _type_Type b)
{
return a == b;
}
u32 get_hash(u64 x)
{
// Doing nothing becase we assume that we already do ui_get_hash()!
return static_cast<u32>(x);
}