PageRenderTime 18ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/runtime/typeinfo/ti_ulong.d

http://github.com/wilkie/djehuty
D | 45 lines | 30 code | 9 blank | 6 comment | 4 complexity | c3e73bfa16a81a0c2b87921b4c3d3961 MD5 | raw file
 1/*
 2 * ti_ulong.d
 3 *
 4 * This module implements the TypeInfo for the ulong type.
 5 *
 6 */
 7
 8module runtime.typeinfo.ti_ulong;
 9
10class TypeInfo_m : TypeInfo {
11	char[] toString() {
12		return "ulong";
13	}
14
15	hash_t getHash(void *p) {
16		return *cast(uint *)p + (cast(uint *)p)[1];
17	}
18
19	int equals(void *p1, void *p2) {
20		return *cast(ulong *)p1 == *cast(ulong *)p2;
21	}
22
23	int compare(void *p1, void *p2) {
24		if (*cast(ulong *)p1 < *cast(ulong *)p2) {
25			return -1;
26		}
27		else if (*cast(ulong *)p1 > *cast(ulong *)p2) {
28			return 1;
29		}
30
31		return 0;
32	}
33
34	size_t tsize() {
35		return ulong.sizeof;
36	}
37
38	void swap(void *p1, void *p2) {
39		ulong t;
40
41		t = *cast(ulong *)p1;
42		*cast(ulong *)p1 = *cast(ulong *)p2;
43		*cast(ulong *)p2 = t;
44	}
45}