Skip to content

Commit 95ee00c

Browse files
yi-jiyiji
authored andcommitted
Parameterize the index map type, some code style & doc fixes
1 parent 3aa8cd3 commit 95ee00c

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

doc/link_cut_trees.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h3>Example</h3>
5252

5353
<pre>
5454
...
55-
link_cut_trees&lt;ElementParentMap, ElementChildMap&gt; lct(p, l, r);
55+
link_cut_trees&lt;ElementParentMap, ElementChildMap&gt; lct(parent_map, left_child_map, right_child_map);
5656

5757
for (ui = vertices(G).first; ui != vertices(G).second; ++ui)
5858
lct.make_tree(*ui);
@@ -88,7 +88,7 @@ <h3>Members</h3>
8888
</tr>
8989

9090
<tr>
91-
<td><tt>link_cut_trees(const disjoint_sets&amp; c)</tt></td>
91+
<td><tt>link_cut_trees(const link_cut_trees&amp; c)</tt></td>
9292

9393
<td>Copy constructor.</td>
9494
</tr>
@@ -188,8 +188,8 @@ <h3>Members</h3>
188188
height="31" width="88"></a></p>
189189

190190
<p>Revised
191-
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->07
192-
October, 2019<!--webbot bot="Timestamp" endspan i-checksum="38508" --></p>
191+
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->
192+
June, 2020<!--webbot bot="Timestamp" endspan i-checksum="38508" --></p>
193193

194194
<table summary="">
195195
<tr valign="top">

include/boost/graph/link_cut_trees.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace boost
2222
public:
2323
inline link_cut_trees(ElementParentMap p, ElementChildMap l, ElementChildMap r) : parent(p), left(l), right(r) {}
2424

25-
inline link_cut_trees(const link_cut_trees<ElementParentMap, ElementChildMap> &c)
25+
inline link_cut_trees(const link_cut_trees &c)
2626
: parent(c.parent), left(c.left), right(c.right) {}
2727

2828
template <class Element>
@@ -222,14 +222,15 @@ namespace boost
222222
};
223223

224224

225-
template <class ID = identity_property_map, class InverseID = boost::unordered_map<typename property_traits<ID>::value_type, typename property_traits<ID>::key_type> >
225+
template <class ID = identity_property_map,
226+
class InverseID = boost::unordered_map<typename property_traits<ID>::value_type, typename property_traits<ID>::key_type>,
227+
class IndexMapContainer = boost::unordered_map<typename property_traits<ID>::value_type, typename property_traits<ID>::value_type> >
226228
class link_cut_trees_with_storage :
227-
public link_cut_trees<associative_property_map<boost::unordered_map<typename property_traits<ID>::value_type, typename property_traits<ID>::value_type> > >
229+
public link_cut_trees<associative_property_map<IndexMapContainer> >
228230
{
229231
public:
230232
typedef typename property_traits<ID>::key_type Vertex;
231233
typedef typename property_traits<ID>::value_type Index;
232-
typedef boost::unordered_map<Index, Index> IndexMapContainer;
233234
typedef associative_property_map<IndexMapContainer> IndexMap;
234235
typedef link_cut_trees<IndexMap> LCT;
235236

test/link_cut_trees_test.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,26 @@ BOOST_AUTO_TEST_CASE(link_cut_trees_test5)
188188
}
189189
link_cut_trees_t lct(id, inverse_id);
190190
test_link_cut_trees<link_cut_trees_t, std::string>(lct, elements);
191+
}
192+
193+
BOOST_AUTO_TEST_CASE(link_cut_trees_test6)
194+
{
195+
typedef associative_property_map< std::map<std::string, int> > id_map_t;
196+
typedef vector_property_map<std::string> inverse_id_map_t;
197+
typedef link_cut_trees_with_storage<id_map_t, inverse_id_map_t, typename std::map<int, int> > link_cut_trees_t;
198+
std::vector<std::string> elements;
199+
std::vector<int> numbers(100);
200+
std::map<std::string, int> id_map;
201+
id_map_t id(id_map);
202+
inverse_id_map_t inverse_id;
203+
boost::range::iota(numbers, -49);
204+
BOOST_FOREACH(int i, numbers)
205+
{
206+
std::string i_str = lexical_cast<std::string, int>(i);
207+
elements.push_back(i_str);
208+
put(id, i_str, i+49);
209+
put(inverse_id, i+49, i_str);
210+
}
211+
link_cut_trees_t lct(id, inverse_id);
212+
test_link_cut_trees<link_cut_trees_t, std::string>(lct, elements);
191213
}

0 commit comments

Comments
 (0)