-
Notifications
You must be signed in to change notification settings - Fork 0
/
lhs_link.h
44 lines (38 loc) · 1.47 KB
/
lhs_link.h
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
#pragma once
#define lhslink_init(s, m) \
(s)->m = 0
#define lhslink_forward(s, m, p, n) \
{ \
(p)->n = (s)->m; \
(s)->m = (p); \
}
#define lhslink_back(s, m, p, n) \
{ \
(s)->m = (p)->n; \
}
#define lhslink_removeif(t, s, m, n, f) \
{ \
t** l = &(s)->m; \
for (; *l; ) \
{ \
t* e = *l; \
if (!(f) || (f)((s), e)) \
{ \
*l = e->n; \
} \
else \
{ \
l = &e->n; \
} \
} \
}
#define lhslink_foreach(t, s, m, n, c, u) \
{ \
t* l = s->m; \
for (; l; ) \
{ \
t* e = l->n; \
(c)((s), l, (u)); \
l = e; \
} \
}