@@ -20,25 +20,27 @@ namespace boost
20
20
class link_cut_trees
21
21
{
22
22
public:
23
- inline link_cut_trees (ElementParentMap p, ElementChildMap l, ElementChildMap r) : parent(p), left(l), right(r) {}
23
+ link_cut_trees (ElementParentMap p, ElementChildMap l, ElementChildMap r) : parent(p), left(l), right(r) {}
24
24
25
- inline link_cut_trees (const link_cut_trees &c)
25
+ link_cut_trees (const link_cut_trees &c)
26
26
: parent(c.parent), left(c.left), right(c.right) {}
27
27
28
28
template <class Element >
29
- inline void make_tree (Element x)
29
+ void make_tree (Element x)
30
30
{
31
- make_path (x);
31
+ put (parent, x, x);
32
+ put (right, x, x);
33
+ put (left, x, x);
32
34
}
33
35
34
36
template <class Element >
35
- inline Element find_root (Element x)
37
+ Element find_root (Element x)
36
38
{
37
39
return find_tail (expose (x));
38
40
}
39
41
40
42
template <class Element >
41
- inline void link (Element x, Element y)
43
+ void link (Element x, Element y)
42
44
{
43
45
BOOST_ASSERT (find_root (x) == x); // Element x must be a tree root
44
46
Element r = expose (x);
@@ -47,7 +49,7 @@ namespace boost
47
49
}
48
50
49
51
template <class Element >
50
- inline void cut (Element x)
52
+ void cut (Element x)
51
53
{
52
54
expose (x);
53
55
std::pair<Element, Element> uv = split (x);
@@ -56,7 +58,7 @@ namespace boost
56
58
}
57
59
58
60
template <class Element >
59
- inline Element lowest_common_ancestor (Element x, Element y)
61
+ Element lowest_common_ancestor (Element x, Element y)
60
62
{
61
63
BOOST_ASSERT (find_root (x) == find_root (y)); // Elements x and y must have same root
62
64
expose (x);
@@ -68,7 +70,7 @@ namespace boost
68
70
ElementChildMap left, right;
69
71
70
72
template <class Element >
71
- inline Element get_parent (Element x) const
73
+ Element get_parent (Element x) const
72
74
{
73
75
Element x_parent = get (parent, x);
74
76
if (get (left, x_parent) == x || get (right, x_parent) == x)
@@ -77,19 +79,19 @@ namespace boost
77
79
}
78
80
79
81
template <class Element >
80
- inline Element get_successor (Element x) const
82
+ Element get_successor (Element x) const
81
83
{
82
84
return get (parent, x);
83
85
}
84
86
85
87
template <class Element >
86
- inline void put_successor (Element x, Element x_successor)
88
+ void put_successor (Element x, Element x_successor)
87
89
{
88
90
put (parent, x, x_successor);
89
91
}
90
92
91
93
template <class Element >
92
- inline void rotate (const Element x, const ElementChildMap &side)
94
+ void rotate (const Element x, const ElementChildMap &side)
93
95
{
94
96
const ElementChildMap &opposite = (&side == &left) ? right : left;
95
97
const Element pivot = get (side, x);
@@ -120,7 +122,7 @@ namespace boost
120
122
}
121
123
122
124
template <class Element >
123
- inline ElementChildMap& get_side (Element x)
125
+ ElementChildMap& get_side (Element x)
124
126
{
125
127
Element x_parent = get_parent (x);
126
128
if (get (left, x_parent) == x)
@@ -129,7 +131,7 @@ namespace boost
129
131
}
130
132
131
133
template <class Element >
132
- inline void splay (Element x)
134
+ void splay (Element x)
133
135
{
134
136
for (Element x_parent = get_parent (x); x != x_parent; x_parent = get_parent (x))
135
137
{
@@ -153,7 +155,7 @@ namespace boost
153
155
}
154
156
155
157
template <class Element >
156
- inline Element expose (Element x)
158
+ Element expose (Element x)
157
159
{
158
160
Element r = x;
159
161
while (true )
@@ -172,22 +174,14 @@ namespace boost
172
174
}
173
175
174
176
template <class Element >
175
- inline void make_path (Element x)
176
- {
177
- put (parent, x, x);
178
- put (right, x, x);
179
- put (left, x, x);
180
- }
181
-
182
- template <class Element >
183
- inline Element find_path (Element x)
177
+ Element find_path (Element x)
184
178
{
185
179
splay (x);
186
180
return x;
187
181
}
188
182
189
183
template <class Element >
190
- inline Element find_tail (Element x)
184
+ Element find_tail (Element x)
191
185
{
192
186
while (get (right, x) != x)
193
187
x = get (right, x);
@@ -196,7 +190,7 @@ namespace boost
196
190
}
197
191
198
192
template <class Element >
199
- inline Element join (Element u, Element v, Element w)
193
+ Element join (Element u, Element v, Element w)
200
194
{
201
195
if (u != v)
202
196
put (parent, u, v);
@@ -208,7 +202,7 @@ namespace boost
208
202
}
209
203
210
204
template <class Element >
211
- inline std::pair<Element, Element> split (Element x)
205
+ std::pair<Element, Element> split (Element x)
212
206
{
213
207
splay (x);
214
208
Element x_left = get (left, x);
@@ -242,33 +236,33 @@ namespace boost
242
236
id_to_vertex (inverse_id) {}
243
237
244
238
template <class Vertex >
245
- inline void make_tree (Vertex x)
239
+ void make_tree (Vertex x)
246
240
{
247
241
const Index x_id = get (id, x);
248
242
LCT::make_tree (x_id);
249
243
id_to_vertex[x_id] = x;
250
244
}
251
245
252
246
template <class Vertex >
253
- inline Vertex find_root (Vertex x)
247
+ Vertex find_root (Vertex x)
254
248
{
255
249
return id_to_vertex[LCT::find_root (get (id, x))];
256
250
}
257
251
258
252
template <class Vertex >
259
- inline void link (Vertex x, Vertex y)
253
+ void link (Vertex x, Vertex y)
260
254
{
261
255
LCT::link (get (id, x), get (id, y));
262
256
}
263
257
264
258
template <class Vertex >
265
- inline void cut (Vertex x)
259
+ void cut (Vertex x)
266
260
{
267
261
LCT::cut (get (id, x));
268
262
}
269
263
270
264
template <class Vertex >
271
- inline Vertex lowest_common_ancestor (Vertex x, Vertex y)
265
+ Vertex lowest_common_ancestor (Vertex x, Vertex y)
272
266
{
273
267
return id_to_vertex[LCT::lowest_common_ancestor (get (id, x), get (id, y))];
274
268
}
0 commit comments