|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79499 - in trunk/libs/intrusive: doc proj/vc7ide test
From: igaztanaga_at_[hidden]
Date: 2012-07-14 09:29:59
Author: igaztanaga
Date: 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
New Revision: 79499
URL: http://svn.boost.org/trac/boost/changeset/79499
Log:
Added `bounded_range` function to trees
Text files modified:
trunk/libs/intrusive/doc/intrusive.qbk | 12 +++++++
trunk/libs/intrusive/proj/vc7ide/to-do.txt | 1
trunk/libs/intrusive/test/generic_assoc_test.hpp | 30 +++++++++++++++++++
trunk/libs/intrusive/test/generic_multiset_test.hpp | 58 +++++++++++++++++++++++++++++++++++++
trunk/libs/intrusive/test/generic_set_test.hpp | 61 ++++++++++++++++++++++++++++++++++++++-
trunk/libs/intrusive/test/splay_multiset_test.cpp | 17 +++++++++++
trunk/libs/intrusive/test/splay_set_test.cpp | 16 ++++++++++
7 files changed, 192 insertions(+), 3 deletions(-)
Modified: trunk/libs/intrusive/doc/intrusive.qbk
==============================================================================
--- trunk/libs/intrusive/doc/intrusive.qbk (original)
+++ trunk/libs/intrusive/doc/intrusive.qbk 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -3829,6 +3829,18 @@
[section:release_notes Release Notes]
+[section:release_notes_boost_1_51_00 Boost 1.51 Release]
+
+* Fixed bugs
+ [@https://svn.boost.org/trac/boost/ticket/6841 #6841],
+ [@https://svn.boost.org/trac/boost/ticket/6907 #6907],
+ [@https://svn.boost.org/trac/boost/ticket/6922 #6922],
+ [@https://svn.boost.org/trac/boost/ticket/7033 #7033],
+
+* Added `bounded_range` function to trees.
+
+[endsect]
+
[section:release_notes_boost_1_49_00 Boost 1.49 Release]
* Fixed bugs
Modified: trunk/libs/intrusive/proj/vc7ide/to-do.txt
==============================================================================
--- trunk/libs/intrusive/proj/vc7ide/to-do.txt (original)
+++ trunk/libs/intrusive/proj/vc7ide/to-do.txt 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -33,3 +33,4 @@
Now, intrusive containers don't allocate memory at all, so incremental rehashing must be trigered by the user using
"incremental_rehash(bool)" (use an additional bucket, that is, incremental rehash) and "incremental_rehash(bucket_traits)" (to update the new bucket array with an array that should be twice/half the size of the previous one). I admit that this is not explained at all with an example, so I will note this issue in my to do list.
+Review throwing conditions in trees. Searches say nothrow, but if comparison throws the function will throw.
\ No newline at end of file
Modified: trunk/libs/intrusive/test/generic_assoc_test.hpp
==============================================================================
--- trunk/libs/intrusive/test/generic_assoc_test.hpp (original)
+++ trunk/libs/intrusive/test/generic_assoc_test.hpp 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -41,6 +41,36 @@
static const bool value = false;
};
+template<class T>
+struct has_const_searches
+{
+ static const bool value = true;
+};
+
+template<class T, bool = has_const_searches<T>::value>
+struct search_const_iterator
+{
+ typedef typename T::const_iterator type;
+};
+
+template<class T>
+struct search_const_iterator<T, false>
+{
+ typedef typename T::iterator type;
+};
+
+template<class T, bool = has_const_searches<T>::value>
+struct search_const_container
+{
+ typedef const T type;
+};
+
+template<class T>
+struct search_const_container<T, false>
+{
+ typedef T type;
+};
+
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
struct test_generic_assoc
{
Modified: trunk/libs/intrusive/test/generic_multiset_test.hpp
==============================================================================
--- trunk/libs/intrusive/test/generic_multiset_test.hpp (original)
+++ trunk/libs/intrusive/test/generic_multiset_test.hpp 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -205,7 +205,8 @@
, constant_time_size<value_type::constant_time_size>
>::type multiset_type;
multiset_type testset (values.begin(), values.end());
- typedef typename multiset_type::iterator iterator;
+ typedef typename multiset_type::iterator iterator;
+ typedef typename multiset_type::const_iterator const_iterator;
{
value_type cmp_val;
@@ -222,6 +223,61 @@
cmp_val.value_ = 7;
BOOST_TEST (testset.find (cmp_val) == testset.end());
}
+ { //1, 2, 2, 3, 4, 5
+ typename search_const_container<multiset_type>::type &const_testset = testset;
+ std::pair<iterator,iterator> range;
+ std::pair<typename search_const_iterator<multiset_type>::type
+ ,typename search_const_iterator<multiset_type>::type> const_range;
+ value_type cmp_val_lower, cmp_val_upper;
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ //left-closed, right-closed
+ std::pair<iterator,iterator> range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, true);
+ BOOST_TEST (range.first->value_ == 1);
+ BOOST_TEST (range.second->value_ == 3);
+ BOOST_TEST (std::distance (range.first, range.second) == 3);
+ }
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
+ BOOST_TEST (const_range.first->value_ == 1);
+ BOOST_TEST (const_range.second->value_ == 2);
+ BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
+
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 3;
+ range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
+ BOOST_TEST (range.first->value_ == 1);
+ BOOST_TEST (range.second->value_ == 3);
+ BOOST_TEST (std::distance (range.first, range.second) == 3);
+ }
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, false, true);
+ BOOST_TEST (const_range.first->value_ == 2);
+ BOOST_TEST (const_range.second->value_ == 3);
+ BOOST_TEST (std::distance (const_range.first, const_range.second) == 2);
+ }
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ range = testset.bounded_range (cmp_val_lower, cmp_val_upper, false, false);
+ BOOST_TEST (range.first->value_ == 2);
+ BOOST_TEST (range.second->value_ == 2);
+ BOOST_TEST (std::distance (range.first, range.second) == 0);
+ }
+ {
+ cmp_val_lower.value_ = 5;
+ cmp_val_upper.value_ = 6;
+ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
+ BOOST_TEST (const_range.first->value_ == 5);
+ BOOST_TEST (const_range.second == const_testset.end());
+ BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
+ }
+ }
}
}}} //namespace boost::intrusive::test
Modified: trunk/libs/intrusive/test/generic_set_test.hpp
==============================================================================
--- trunk/libs/intrusive/test/generic_set_test.hpp (original)
+++ trunk/libs/intrusive/test/generic_set_test.hpp 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -265,7 +265,7 @@
BOOST_TEST (&*testset1.begin() == &values[3]);
}
-//test: find, equal_range (lower_bound, upper_bound):
+//test: find, equal_range (lower_bound, upper_bound), bounded_range:
template<class ValueTraits, template <class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none, class = ::boost::intrusive::none> class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_find(std::vector<typename ValueTraits::value_type>& values)
{
@@ -276,7 +276,8 @@
, constant_time_size<value_type::constant_time_size>
>::type set_type;
set_type testset (values.begin(), values.end());
- typedef typename set_type::iterator iterator;
+ typedef typename set_type::iterator iterator;
+ typedef typename set_type::const_iterator const_iterator;
{
value_type cmp_val;
@@ -293,6 +294,62 @@
cmp_val.value_ = 7;
BOOST_TEST (testset.find (cmp_val) == testset.end());
}
+
+ {
+ typename search_const_container<set_type>::type &const_testset = testset;
+ std::pair<iterator,iterator> range;
+ std::pair<typename search_const_iterator<set_type>::type
+ ,typename search_const_iterator<set_type>::type> const_range;
+ value_type cmp_val_lower, cmp_val_upper;
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ //left-closed, right-closed
+ std::pair<iterator,iterator> range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, true);
+ BOOST_TEST (range.first->value_ == 1);
+ BOOST_TEST (range.second->value_ == 3);
+ BOOST_TEST (std::distance (range.first, range.second) == 2);
+ }
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
+ BOOST_TEST (const_range.first->value_ == 1);
+ BOOST_TEST (const_range.second->value_ == 2);
+ BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
+
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 3;
+ range = testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
+ BOOST_TEST (range.first->value_ == 1);
+ BOOST_TEST (range.second->value_ == 3);
+ BOOST_TEST (std::distance (range.first, range.second) == 2);
+ }
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, false, true);
+ BOOST_TEST (const_range.first->value_ == 2);
+ BOOST_TEST (const_range.second->value_ == 3);
+ BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
+ }
+ {
+ cmp_val_lower.value_ = 1;
+ cmp_val_upper.value_ = 2;
+ range = testset.bounded_range (cmp_val_lower, cmp_val_upper, false, false);
+ BOOST_TEST (range.first->value_ == 2);
+ BOOST_TEST (range.second->value_ == 2);
+ BOOST_TEST (std::distance (range.first, range.second) == 0);
+ }
+ {
+ cmp_val_lower.value_ = 5;
+ cmp_val_upper.value_ = 6;
+ const_range = const_testset.bounded_range (cmp_val_lower, cmp_val_upper, true, false);
+ BOOST_TEST (const_range.first->value_ == 5);
+ BOOST_TEST (const_range.second == const_testset.end());
+ BOOST_TEST (std::distance (const_range.first, const_range.second) == 1);
+ }
+ }
}
}}} //namespace boost::intrusive::test
Modified: trunk/libs/intrusive/test/splay_multiset_test.cpp
==============================================================================
--- trunk/libs/intrusive/test/splay_multiset_test.cpp (original)
+++ trunk/libs/intrusive/test/splay_multiset_test.cpp 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -68,6 +68,23 @@
static const bool value = true;
};
+#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class O1, class O2, class O3, class O4>
+#else
+template<class T, class ...Options>
+#endif
+struct has_const_searches<boost::intrusive::splay_multiset<T,
+ #if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+> >
+{
+ static const bool value = false;
+};
+
+
}}}
using namespace boost::intrusive;
Modified: trunk/libs/intrusive/test/splay_set_test.cpp
==============================================================================
--- trunk/libs/intrusive/test/splay_set_test.cpp (original)
+++ trunk/libs/intrusive/test/splay_set_test.cpp 2012-07-14 09:29:57 EDT (Sat, 14 Jul 2012)
@@ -65,6 +65,22 @@
static const bool value = true;
};
+#if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class O1, class O2, class O3, class O4>
+#else
+template<class T, class ...Options>
+#endif
+struct has_const_searches<boost::intrusive::splay_set<T,
+ #if !defined (BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+> >
+{
+ static const bool value = false;
+};
+
}}}
using namespace boost::intrusive;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk