PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/runtime/typeinfo/ti_uint.d

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