-
Notifications
You must be signed in to change notification settings - Fork 2
/
list.d
56 lines (43 loc) · 922 Bytes
/
list.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
56
/*
* zCListSort functions (I don't like LeGo ListS functions ... I mean why would you not start properly from index 0? :))
*/
/*
* zCListSort_GetNode
*/
func int zCListSort_GetNode(var int list, var int nr) {
if (!list) { return 0; };
if (nr < 0) { return 0; };
var int i; i = 0;
var int ptr; ptr = list;
while (ptr);
ptr = MEM_ReadInt(ptr + 8);
if (i == nr) {
return ptr;
};
i += 1;
end;
return 0;
};
/*
* zCListSort_GetData
*/
func int zCListSort_GetData(var int list, var int nr) {
if (!list) { return 0; };
var int nodePtr; nodePtr = zCListSort_GetNode(list, nr);
if (!nodePtr) { return 0; };
nodePtr = MEM_ReadInt(nodePtr + 4);
return + nodePtr;
};
/*
* zCListSort_GetLength
*/
func int zCListSort_GetLength(var int list) {
if (!list) { return 0; };
var int nr; nr = 0;
var int ptr; ptr = list;
while(ptr);
ptr = MEM_ReadInt(ptr + 8);
nr += 1;
end;
return nr;
};