-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcttrie_sw32.tcc
167 lines (157 loc) · 4.21 KB
/
cttrie_sw32.tcc
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#define XTMPLATE \
template <typename Stringview, \
XBLOCK(XSUB1,XCOMMA), \
typename FnE,typename... Fns> \
auto Switch(unsigned char ch,Stringview&& str,TrieNode< \
XBLOCK(XSUB2,XCOMMA) \
>,FnE&& fne,Fns&&... fns) \
-> decltype(fne()) \
{ \
switch (ch) { \
XBLOCK(XSUB3,XSEMIC); \
} \
return fne(); \
}
#define XCOMMA() ,
#define XSEMIC() ;
#define XSUB1(p) int Char ## p,typename Next ## p
#define XSUB2(p) Transition<Char ## p,Next ## p>
#define XSUB3(p) case Char ## p: return checkTrie(Next ## p(),(Stringview&&)str,(FnE&&)fne,(Fns&&)fns...)
#define XCAT(x,p,q) x(p ## q)
#define XBLOCK0(p,x,sep) XCAT(x,p,0)
#define XBLOCK1(p,x,sep) XBLOCK0(p,x,sep) sep() XCAT(x,p,1)
#define XBLOCK2(p,x,sep) XBLOCK1(p,x,sep) sep() XCAT(x,p,2)
#define XBLOCK3(p,x,sep) XBLOCK2(p,x,sep) sep() XCAT(x,p,3)
#define XBLOCK4(p,x,sep) XBLOCK3(p,x,sep) sep() XCAT(x,p,4)
#define XBLOCK5(p,x,sep) XBLOCK4(p,x,sep) sep() XCAT(x,p,5)
#define XBLOCK6(p,x,sep) XBLOCK5(p,x,sep) sep() XCAT(x,p,6)
#define XBLOCK7(p,x,sep) XBLOCK6(p,x,sep) sep() XCAT(x,p,7)
#define XXBLOCK(x,sep)
#define XXNUM 0
/* unused
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK0(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
*/
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK1(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK2(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK3(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK4(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK5(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK6(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK7(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#undef XXNUM
#undef XXBLOCK
#define XXBLOCK(x,sep) XBLOCK7(0,x,sep) sep()
#define XXNUM 1
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK0(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK1(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK2(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK3(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK4(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK5(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK6(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK7(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#undef XXNUM
#undef XXBLOCK
#define XXBLOCK(x,sep) XBLOCK7(0,x,sep) sep() XBLOCK7(1,x,sep) sep()
#define XXNUM 2
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK0(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK1(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK2(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK3(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK4(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK5(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK6(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK7(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#undef XXNUM
#undef XXBLOCK
#define XXBLOCK(x,sep) XBLOCK7(0,x,sep) sep() XBLOCK7(1,x,sep) sep() XBLOCK7(2,x,sep) sep()
#define XXNUM 3
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK0(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK1(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK2(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK3(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK4(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK5(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK6(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#define XBLOCK(x,sep) XXBLOCK(x,sep) XBLOCK7(XXNUM,x,sep)
XTMPLATE
#undef XBLOCK
#undef XXNUM
#undef XXBLOCK
#undef XBLOCK7
#undef XBLOCK6
#undef XBLOCK5
#undef XBLOCK4
#undef XBLOCK3
#undef XBLOCK2
#undef XBLOCK1
#undef XBLOCK0
#undef XCAT
#undef XSUB3
#undef XSUB2
#undef XSUB1
#undef XSEMIC
#undef XCOMMA
#undef XTMPLATE