Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50570 - in sandbox/itl: boost/itl libs/itl/test/test_itl_interval
From: afojgo_at_[hidden]
Date: 2009-01-13 16:22:20


Author: jofaber
Date: 2009-01-13 16:22:19 EST (Tue, 13 Jan 2009)
New Revision: 50570
URL: http://svn.boost.org/trac/boost/changeset/50570

Log:
Refactored. Added left_subtract(1). Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/interval.hpp | 14 ++++++++++++--
   sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp | 27 +++++++++++++++++++++++----
   2 files changed, 35 insertions(+), 6 deletions(-)

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2009-01-13 16:22:19 EST (Tue, 13 Jan 2009)
@@ -461,6 +461,8 @@
 
         interval& left_subtract(const interval& x2);
 
+ interval& right_subtract(const interval& x2);
+
     /** Interval spanning from lower bound of *this interval to the upper bound of rhs.
         Bordertypes according to the lower bound of *this and the upper bound of rhs. */
     interval span(const interval& rhs)const
@@ -948,11 +950,19 @@
 template <class DomainT, ITL_COMPARE Compare>
 inline interval<DomainT,Compare>& interval<DomainT,Compare>::left_subtract(const interval& x2)
 {
- if(!exclusive_less(x2))
+ if(!x2.exclusive_less(*this))
                 set_lwb( BoundT(x2._upb, x2.succession_bounds()) );
     return *this;
 }
 
+template <class DomainT, ITL_COMPARE Compare>
+inline interval<DomainT,Compare>& interval<DomainT,Compare>::right_subtract(const interval& x2)
+{
+ if(!exclusive_less(x2))
+ set_upb( BoundT(x2._lwb, x2.succession_bounds()) );
+ return *this;
+}
+
 
 template <class DomainT, ITL_COMPARE Compare>
 void interval<DomainT,Compare>::intersect(interval<DomainT,Compare>& isec, const interval<DomainT,Compare>& x2)const
@@ -979,7 +989,7 @@
 void interval<DomainT,Compare>::right_surplus(interval<DomainT,Compare>& rsur, const interval<DomainT,Compare>& x2)const
 {
     if(x2.upper_less(*this)) {
- if(exclusive_less(x2))
+ if(x2.exclusive_less(*this))
             rsur.set_lwb( BoundT(_lwb,boundtypes()) );
                 else
             rsur.set_lwb(lwb_rightOf(x2));

Modified: sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp (original)
+++ sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp 2009-01-13 16:22:19 EST (Tue, 13 Jan 2009)
@@ -332,15 +332,34 @@
     interval<T> I0_3D = interval<T>::rightopen(v0,v3);
     interval<T> I2_6D = interval<T>::rightopen(v2,v6);
     interval<T> I4_7D = interval<T>::rightopen(v4,v7);
+ interval<T> I6_7D = interval<T>::rightopen(v6,v7);
     interval<T> I2_4D = interval<T>::rightopen(v2,v4);
+
         I2_6D.left_surplus(diff_1,I4_7D);
     BOOST_CHECK_EQUAL( diff_1, I2_4D );
- //diff_2 = I2_6D;
- //diff_2.left_subtract(I4_7D);
- //BOOST_CHECK_EQUAL( diff_2, I2_4D );
+
+ diff_2 = I2_6D;
+ diff_2.right_subtract(I4_7D);
+ BOOST_CHECK_EQUAL( diff_2, I2_4D );
 
         diff_1.clear();
- I0_3D.left_surplus(diff_1,I4_7D);
+ I0_3D.left_surplus(diff_1, I4_7D);
     BOOST_CHECK_EQUAL( diff_1, I0_3D );
         
+ // ---------------------------------
+ I4_7D.right_surplus(diff_1, I2_6D);
+ BOOST_CHECK_EQUAL( diff_1, I6_7D );
+
+ diff_2 = I4_7D;
+ diff_2.left_subtract(I2_6D);
+ BOOST_CHECK_EQUAL( diff_2, I6_7D );
+
+ diff_1.clear();
+ I4_7D.right_surplus(diff_1, I0_3D);
+ BOOST_CHECK_EQUAL( diff_1, I4_7D );
+
+ diff_2 = I4_7D;
+ diff_2.left_subtract(I0_3D);
+ BOOST_CHECK_EQUAL( diff_2, I4_7D );
+
 }


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