forked from boostorg/intrusive
Document root()/croot() functions in tree-based containers, and add a test case for them.
This commit is contained in:
@@ -838,6 +838,27 @@ class bstree_impl
|
||||
//! <b>Throws</b>: Nothing.
|
||||
const_reverse_iterator crend() const;
|
||||
|
||||
//! <b>Effects</b>: Returns a iterator pointing to the root node of the container or end() if not present.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
iterator root();
|
||||
|
||||
//! <b>Effects</b>: Returns a const_iterator pointing to the root node of the container or cend() if not present.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
const_iterator root() const;
|
||||
|
||||
//! <b>Effects</b>: Returns a const_iterator pointing to the root node of the container or cend() if not present.
|
||||
//!
|
||||
//! <b>Complexity</b>: Constant.
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
const_iterator croot() const;
|
||||
|
||||
#endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
||||
|
||||
//! <b>Precondition</b>: end_iterator must be a valid end iterator
|
||||
|
@@ -38,6 +38,7 @@ struct test_generic_assoc
|
||||
typedef typename ContainerDefiner::value_cont_type value_cont_type;
|
||||
|
||||
static void test_all(value_cont_type&);
|
||||
static void test_root(value_cont_type&);
|
||||
static void test_clone(value_cont_type&);
|
||||
static void test_insert_erase_burst();
|
||||
static void test_container_from_end(value_cont_type&, detail::true_type);
|
||||
@@ -135,6 +136,7 @@ void test_generic_assoc<ContainerDefiner>::test_all(value_cont_type& values)
|
||||
{
|
||||
typedef typename ContainerDefiner::template container
|
||||
<>::type assoc_type;
|
||||
test_root(values);
|
||||
test_clone(values);
|
||||
test_container_from_end(values, detail::bool_< assoc_type::has_container_from_iterator >());
|
||||
test_splay_up(values, detail::bool_< has_splay< assoc_type >::value >());
|
||||
@@ -146,8 +148,37 @@ void test_generic_assoc<ContainerDefiner>::test_all(value_cont_type& values)
|
||||
}
|
||||
|
||||
template<class ContainerDefiner>
|
||||
void test_generic_assoc<ContainerDefiner>
|
||||
::test_clone(value_cont_type& values)
|
||||
void test_generic_assoc<ContainerDefiner>::test_root(value_cont_type& values)
|
||||
{
|
||||
typedef typename ContainerDefiner::template container<>::type assoc_type;
|
||||
typedef typename assoc_type::iterator iterator;
|
||||
typedef typename assoc_type::const_iterator const_iterator;
|
||||
|
||||
assoc_type testset1;
|
||||
const assoc_type &ctestset1 = testset1;;
|
||||
|
||||
BOOST_TEST( testset1.root() == testset1.end());
|
||||
BOOST_TEST(ctestset1.root() == ctestset1.cend());
|
||||
BOOST_TEST( testset1.croot() == ctestset1.cend());
|
||||
|
||||
|
||||
testset1.insert(values.begin(), values.begin() + values.size());
|
||||
|
||||
iterator i = testset1.root();
|
||||
iterator i2(i);
|
||||
BOOST_TEST( i.go_parent().go_parent() == i2);
|
||||
|
||||
const_iterator ci = ctestset1.root();
|
||||
const_iterator ci2(ci);
|
||||
BOOST_TEST( ci.go_parent().go_parent() == ci2);
|
||||
|
||||
ci = testset1.croot();
|
||||
ci2 = ci;
|
||||
BOOST_TEST( ci.go_parent().go_parent() == ci2);
|
||||
}
|
||||
|
||||
template<class ContainerDefiner>
|
||||
void test_generic_assoc<ContainerDefiner>::test_clone(value_cont_type& values)
|
||||
{
|
||||
{
|
||||
typedef typename ContainerDefiner::template container
|
||||
|
Reference in New Issue
Block a user