|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75410 - in trunk: boost/icl/concept libs/icl/doc libs/icl/doc/html/boost_icl libs/icl/test/test_casual_
From: afojgo_at_[hidden]
Date: 2011-11-08 13:08:27
Author: jofaber
Date: 2011-11-08 13:08:26 EST (Tue, 08 Nov 2011)
New Revision: 75410
URL: http://svn.boost.org/trac/boost/changeset/75410
Log:
Polished ticket #6095 filed by Marvin Sielenkemper. https://svn.boost.org/trac/boost/ticket/6095. Improved implementation of is_empty for open intervals as suggested by Marvin.
Text files modified:
trunk/boost/icl/concept/interval.hpp | 8 +++---
trunk/libs/icl/doc/acknowledgments.qbk | 3 ++
trunk/libs/icl/doc/html/boost_icl/acknowledgments.html | 4 +++
trunk/libs/icl/test/test_casual_/test_casual.cpp | 51 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+), 4 deletions(-)
Modified: trunk/boost/icl/concept/interval.hpp
==============================================================================
--- trunk/boost/icl/concept/interval.hpp (original)
+++ trunk/boost/icl/concept/interval.hpp 2011-11-08 13:08:26 EST (Tue, 08 Nov 2011)
@@ -547,8 +547,8 @@
typename boost::enable_if<is_static_open<Type>, bool>::type
is_empty(const Type& object)
{
- return domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)))
- || !domain_less<Type>(lower(object), domain_next<Type>(lower(object)));
+ return domain_less_equal<Type>(upper(object), lower(object) )
+ || domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)));
}
template<class Type>
@@ -558,8 +558,8 @@
if(object.bounds() == interval_bounds::closed())
return domain_less<Type>(upper(object), lower(object));
else if(object.bounds() == interval_bounds::open())
- return domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)))
- || !domain_less<Type>(lower(object), domain_next<Type>(lower(object)));
+ return domain_less_equal<Type>(upper(object), lower(object) )
+ || domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)));
else
return domain_less_equal<Type>(upper(object), lower(object));
}
Modified: trunk/libs/icl/doc/acknowledgments.qbk
==============================================================================
--- trunk/libs/icl/doc/acknowledgments.qbk (original)
+++ trunk/libs/icl/doc/acknowledgments.qbk 2011-11-08 13:08:26 EST (Tue, 08 Nov 2011)
@@ -38,5 +38,8 @@
Jerry Jeremiah, John Reid, Steven Watanabe, Brian Wood, Markus Werle
and Michael Caisse.
+For sending in bug reports, code patches and suggestions for improvements
+after the review thanks to Denis and Marvin Sielenkemper.
+
[endsect]
Modified: trunk/libs/icl/doc/html/boost_icl/acknowledgments.html
==============================================================================
--- trunk/libs/icl/doc/html/boost_icl/acknowledgments.html (original)
+++ trunk/libs/icl/doc/html/boost_icl/acknowledgments.html 2011-11-08 13:08:26 EST (Tue, 08 Nov 2011)
@@ -53,6 +53,10 @@
Jeremiah, John Reid, Steven Watanabe, Brian Wood, Markus Werle and Michael
Caisse.
</p>
+<p>
+ For sending in bug reports, code patches and suggestions for improvements
+ after the review thanks to Denis and Marvin Sielenkemper.
+ </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Modified: trunk/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- trunk/libs/icl/test/test_casual_/test_casual.cpp (original)
+++ trunk/libs/icl/test/test_casual_/test_casual.cpp 2011-11-08 13:08:26 EST (Tue, 08 Nov 2011)
@@ -32,11 +32,24 @@
#include <boost/icl/interval_set.hpp>
#include <boost/icl/interval.hpp>
+#include <boost/scoped_ptr.hpp>
+
using namespace std;
using namespace boost;
using namespace unit_test;
using namespace boost::icl;
+void pass_it(shared_ptr<int> pi)
+{
+ *pi = 41;
+ cout << "uses: " << pi.use_count() << " cont: " << *pi << endl;
+}
+
+void pass_it_ref(shared_ptr<int>& pi)
+{
+ *pi = 43;
+ cout << "uses: " << pi.use_count() << " cont: " << *pi << endl;
+}
BOOST_AUTO_TEST_CASE(casual)
{
@@ -46,7 +59,45 @@
typedef interval_set<T> IntervalSetT;
typedef IntervalMapT::interval_type IntervalT;
+ shared_ptr<int> pi(new int(42));
+ cout << "uses: " << pi.use_count() << " cont: " << *pi << endl;
+ pass_it(pi);
+ pass_it_ref(pi);
+
BOOST_CHECK_EQUAL(true, true);
}
+/*
+BOOST_AUTO_TEST_CASE(isEmptyTest)
+{
+ typedef int Value;
+ typedef boost::icl::interval<Value> Interval;
+ typedef std::numeric_limits<Value> Limits;
+
+ Value const max(Limits::max());
+
+ Interval::interval_type piff = Interval::open(max, max);
+
+ BOOST_CHECK(!icl::is_empty(Interval::open(max - 2, max)));
+ BOOST_CHECK( icl::is_empty(Interval::open(max - 1, max)));
+ BOOST_CHECK( icl::is_empty(Interval::open(max, max)));
+}
+*/
+
+BOOST_AUTO_TEST_CASE(totalRangeTest)
+{
+ typedef int Value;
+ typedef boost::icl::interval<Value> Interval;
+ typedef std::numeric_limits<Value> Limits;
+ typedef boost::icl::interval_map<Value, int, boost::icl::total_enricher> Container;
+ Value const min(Limits::min());
+ Value const max(Limits::max());
+
+ boost::icl::interval_map<Value, int, boost::icl::total_enricher> intervals;
+
+ intervals += std::make_pair(Interval::closed(min, max), 0);
+ intervals += std::make_pair(Interval::right_open(0, 10), 3);
+
+ BOOST_CHECK_EQUAL(intervals.iterative_size(), 3);
+}
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