forked from dlang/phobos
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ti_Aint.d
56 lines (45 loc) · 848 Bytes
/
ti_Aint.d
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
import string;
// int[]
class TypeInfo_Ai : TypeInfo
{
uint getHash(void *p)
{ int[] s = *(int[]*)p;
uint len = s.length;
int *str = s;
uint hash = 0;
while (len)
{
hash *= 9;
hash += *(uint *)str;
str++;
len--;
}
return hash;
}
int equals(void *p1, void *p2)
{
int[] s1 = *(int[]*)p1;
int[] s2 = *(int[]*)p2;
return s1.length == s2.length &&
memcmp((void *)s1, (void *)s2, s1.length * int.size) == 0;
}
int compare(void *p1, void *p2)
{
int[] s1 = *(int[]*)p1;
int[] s2 = *(int[]*)p2;
uint len = s1.length;
if (s2.length < len)
len = s2.length;
for (uint u = 0; u < len; u++)
{
int result = s1[u] - s2[u];
if (result)
return result;
}
return cast(int)s1.length - cast(int)s2.length;
}
int tsize()
{
return (int[]).size;
}
}