From e38cfc8536fa41f65624a0bb7ab58d344073d5dd Mon Sep 17 00:00:00 2001
From: yi-ji
Date: Sat, 20 Jun 2020 16:33:48 +0900
Subject: [PATCH] Parameterize the index map type, some code style & doc fixes
---
doc/link_cut_trees.html | 8 ++++----
include/boost/graph/link_cut_trees.hpp | 9 +++++----
test/link_cut_trees_test.cpp | 22 ++++++++++++++++++++++
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/doc/link_cut_trees.html b/doc/link_cut_trees.html
index 9d13c232b..0c9564301 100644
--- a/doc/link_cut_trees.html
+++ b/doc/link_cut_trees.html
@@ -52,7 +52,7 @@ Example
...
- link_cut_trees<ElementParentMap, ElementChildMap> lct(p, l, r);
+ link_cut_trees<ElementParentMap, ElementChildMap> lct(parent_map, left_child_map, right_child_map);
for (ui = vertices(G).first; ui != vertices(G).second; ++ui)
lct.make_tree(*ui);
@@ -88,7 +88,7 @@ Members
- link_cut_trees(const disjoint_sets& c) |
+ link_cut_trees(const link_cut_trees& c) |
Copy constructor. |
@@ -188,8 +188,8 @@ Members
height="31" width="88">
Revised
- 07
- October, 2019
+
+ June, 2020
diff --git a/include/boost/graph/link_cut_trees.hpp b/include/boost/graph/link_cut_trees.hpp
index 00da5c2c7..217d3ec6e 100644
--- a/include/boost/graph/link_cut_trees.hpp
+++ b/include/boost/graph/link_cut_trees.hpp
@@ -22,7 +22,7 @@ namespace boost
public:
inline link_cut_trees(ElementParentMap p, ElementChildMap l, ElementChildMap r) : parent(p), left(l), right(r) {}
- inline link_cut_trees(const link_cut_trees &c)
+ inline link_cut_trees(const link_cut_trees &c)
: parent(c.parent), left(c.left), right(c.right) {}
template
@@ -222,14 +222,15 @@ namespace boost
};
- template ::value_type, typename property_traits::key_type> >
+ template ::value_type, typename property_traits::key_type>,
+ class IndexMapContainer = boost::unordered_map::value_type, typename property_traits::value_type> >
class link_cut_trees_with_storage :
- public link_cut_trees::value_type, typename property_traits::value_type> > >
+ public link_cut_trees >
{
public:
typedef typename property_traits::key_type Vertex;
typedef typename property_traits::value_type Index;
- typedef boost::unordered_map IndexMapContainer;
typedef associative_property_map IndexMap;
typedef link_cut_trees LCT;
diff --git a/test/link_cut_trees_test.cpp b/test/link_cut_trees_test.cpp
index 855207483..9c4abed70 100644
--- a/test/link_cut_trees_test.cpp
+++ b/test/link_cut_trees_test.cpp
@@ -188,4 +188,26 @@ BOOST_AUTO_TEST_CASE(link_cut_trees_test5)
}
link_cut_trees_t lct(id, inverse_id);
test_link_cut_trees(lct, elements);
+}
+
+BOOST_AUTO_TEST_CASE(link_cut_trees_test6)
+{
+ typedef associative_property_map< std::map > id_map_t;
+ typedef vector_property_map inverse_id_map_t;
+ typedef link_cut_trees_with_storage > link_cut_trees_t;
+ std::vector elements;
+ std::vector numbers(100);
+ std::map id_map;
+ id_map_t id(id_map);
+ inverse_id_map_t inverse_id;
+ boost::range::iota(numbers, -49);
+ BOOST_FOREACH(int i, numbers)
+ {
+ std::string i_str = lexical_cast(i);
+ elements.push_back(i_str);
+ put(id, i_str, i+49);
+ put(inverse_id, i+49, i_str);
+ }
+ link_cut_trees_t lct(id, inverse_id);
+ test_link_cut_trees(lct, elements);
}
\ No newline at end of file