Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50688 - in sandbox/itl: boost/itl boost/itl_xt libs/itl/test libs/itl/test/test_itl_interval libs/itl_xt/test/meta_functors
From: afojgo_at_[hidden]
Date: 2009-01-20 14:39:35


Author: jofaber
Date: 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
New Revision: 50688
URL: http://svn.boost.org/trac/boost/changeset/50688

Log:
Refactored. Reduced interval functions by interval::is, ::is_left/right, ::as. Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/interval.hpp | 314 +++++++++++++++++----------------------
   sandbox/itl/boost/itl/interval_base_map.hpp | 25 --
   sandbox/itl/boost/itl/interval_base_set.hpp | 6
   sandbox/itl/boost/itl/operators.hpp | 3
   sandbox/itl/boost/itl_xt/itvgentor.hpp | 4
   sandbox/itl/boost/itl_xt/numbergentor.hpp | 4
   sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp | 59 +++---
   sandbox/itl/libs/itl/test/test_value_maker.hpp | 4
   sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp | 7
   9 files changed, 188 insertions(+), 238 deletions(-)

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -295,16 +295,16 @@
 /// Constants for intervalbounds
 enum BoundTypes {
     /// Both open: <tt>(x,y)</tt>
- open = 0,
+ open_bounded = 0,
     /// Left open right closed: <tt>(x,y]</tt>
     left_open = 1,
     /// Left closed right open: <tt>[x,y)</tt>
     right_open = 2,
     /// Both closed: <tt>[x,y]</tt>
- closed = 3,
+ closed_bounded = 3,
 } ;
 
-typedef unsigned char bount_types;
+typedef unsigned char bound_type;
 
 /// A class template for intervals
 /** Bounds of the interval may be closed or open.
@@ -340,51 +340,35 @@
     /// The size type of an interval which is mostly std::size_t
     typedef typename itl::size<DomainT>::type size_type;
 
- /// Interval bounds as bitset
- typedef unsigned char bound_types;
-
- /// Constants for intervalbounds
- enum BoundTypes {
- /// Both open: <tt>(x,y)</tt>
- OPEN = 0x0,
- /// Left open right closed: <tt>(x,y]</tt>
- LEFT_OPEN = 0x1,
- /// Left closed right open: <tt>[x,y)</tt>
- RIGHT_OPEN = 0x2,
- /// Both closed: <tt>[x,y]</tt>
- CLOSED = 0x3,
- } ;
-
-
     /** Default constructor; yields an empty interval <tt>[1,0]</tt> */
     interval() : _lwb(unon<DomainT>::value()), _upb(neutron<DomainT>::value()),
- _boundtypes(CLOSED) {}
+ _boundtype(itl::closed_bounded) {}
 
     //NOTE: Compiler generated copy constructor is used
 
     /** Constructor for a closed singleton interval <tt>[val,val]</tt> */
     explicit interval(const DomainT& val) :
- _lwb(val), _upb(val), _boundtypes(CLOSED) {}
+ _lwb(val), _upb(val), _boundtype(itl::closed_bounded) {}
 
- /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bt</tt> */
- interval(const DomainT& low, const DomainT& up, bound_types bt = CLOSED) :
- _lwb(low), _upb(up), _boundtypes(bt) {}
+ /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
+ interval(const DomainT& low, const DomainT& up, itl::bound_type bounds = itl::closed_bounded) :
+ _lwb(low), _upb(up), _boundtype(bounds) {}
 
         /** Closed interval <tt>[low,up]</tt> */
         static interval closed(const DomainT& low, const DomainT& up)
- { return interval(low, up, CLOSED); }
+ { return interval(low, up, itl::closed_bounded); }
 
         /** Rightopen interval <tt>[low,up)</tt> */
         static interval rightopen(const DomainT& low, const DomainT& up)
- { return interval(low, up, RIGHT_OPEN); }
+ { return interval(low, up, right_open); }
 
         /** Leftopen interval <tt>(low,up]</tt> */
         static interval leftopen(const DomainT& low, const DomainT& up)
- { return interval(low, up, LEFT_OPEN); }
+ { return interval(low, up, left_open); }
 
         /** Open interval <tt>(low,up)</tt> */
         static interval open(const DomainT& low, const DomainT& up)
- { return interval(low, up, OPEN); }
+ { return interval(low, up, itl::open_bounded); }
 
     //NOTE: Compiler generated assignment operator = used
 
@@ -393,30 +377,47 @@
     /** Upper bound of the interval */
     DomainT upper()const { return _upb; }
     /** Typ of interval bounds */
- bound_types boundtypes()const { return _boundtypes; }
+ bound_type boundtype()const { return _boundtype; }
 
     /** Is the interval empty? */
     bool empty()const;
     /** Does the interval contain <tt>x</tt>? */
     bool contains(const DomainT& x)const;
 
- /** Both closed: <tt>[x,y]</tt> ? */
- bool is_closed()const { return _boundtypes == CLOSED; }
- /** Left open right closed: <tt>(x,y]</tt> ? */
- bool is_leftopen()const { return _boundtypes == LEFT_OPEN; }
- /** Left closed right open: <tt>[x,y)</tt> ? */
- bool is_rightopen()const { return _boundtypes == RIGHT_OPEN; }
- /** Both open: <tt>(x,y)</tt> ? */
- bool is_open()const { return _boundtypes == OPEN; }
-
- /** Left bound is open right unknown <tt>(x,y|</tt> ? */
- bool leftbound_open()const { return !leftbound_closed(); }
- /** Right bound is open left unknown <tt>|x,y)</tt> ? */
- bool rightbound_open()const { return !rightbound_closed(); }
- /** Left closed right unknown <tt>[x,y|</tt> ? */
- bool leftbound_closed()const { return 0 != (_boundtypes & RIGHT_OPEN); }
- /** Right closed left unknown <tt>|x,y]</tt> */
- bool rightbound_closed()const { return 0 != (_boundtypes & LEFT_OPEN); }
+ /** What type is the interval?
+\code
+interval.is(closed_bounded); //[x, y] a closed interval
+interval.is(right_open); //[x, y) a right-open interval (also left-closed interval)
+interval.is(left_open); //(x, y] a left-open interval (also right-closed interval)
+interval.is(open_bounded); //(x, y) an open interval
+\endcode
+ */
+ bool is(bound_type bounded)const { return _boundtype == bounded; }
+
+ /** What bound type is the left interval border?
+\code
+interval.is_left(closed_bounded); //[x, y] or [x, y)
+interval.is_left(open_bounded); //(x, y] or (x, y)
+\endcode
+ */
+ bool is_left(bound_type bounded)const
+ {
+ BOOST_ASSERT(bounded == itl::open_bounded || bounded == itl::closed_bounded);
+ return ((_boundtype & right_open)>>1) == (bounded>>1);
+ }
+
+ /** What bound type is the right interval border?
+\code
+interval.is_right(closed_bounded); //[x, y] or (x, y]
+interval.is_right(open_bounded); //[x, y) or (x, y)
+\endcode
+ */
+ bool is_right(bound_type bounded)const
+ {
+ BOOST_ASSERT(bounded == itl::open_bounded || bounded == itl::closed_bounded);
+ return ((_boundtype & left_open) == (bounded>>1));
+ }
+
 
     /** <tt>*this</tt> is subset of <tt>super</tt> */
     bool contained_in(const interval& super)const ;
@@ -434,11 +435,11 @@
 
     /** Set the interval empty */
     void clear()
- { set_lwb(unon<DomainT>::value()); set_upb(neutron<DomainT>::value()); _boundtypes=CLOSED; }
+ { set_lwb(unon<DomainT>::value()); set_upb(neutron<DomainT>::value()); _boundtype=itl::closed_bounded; }
 
- /** Set \c *this interval to from \c low to \c up with boundtypes \c bt */
- interval& set(const DomainT& low, const DomainT& up, bound_types bt)
- { _lwb=low; _upb=up; _boundtypes=bt; return *this; }
+ /** Set \c *this interval to from \c low to \c up with boundtype \c bounds */
+ interval& set(const DomainT& low, const DomainT& up, bound_type bounds)
+ { _lwb=low; _upb=up; _boundtype=bounds; return *this; }
 
     /** Extend <tt>*this</tt> to <tt>x2</tt> yielding an interval from the minimum of lower bounds
         to the maximum of upper bounds */
@@ -496,7 +497,7 @@
         if(empty()) return rhs;
         else if(rhs.empty()) return *this;
         else return
- interval(_lwb, rhs._upb, span(boundtypes(), rhs.boundtypes()));
+ interval(_lwb, rhs._upb, span(boundtype(), rhs.boundtype()));
     }
 
         
@@ -519,22 +520,16 @@
     /** Size of the interval */
     size_type size()const { return cardinality(); }
 
- /** <tt>*this</tt> interval as closed <tt>[x,y]</tt> interval. Requires Integral<domain_type>. */
- interval as_closed_interval()const;
-
- /** <tt>*this</tt> interval as open <tt>[x,y]</tt> interval. Requires Integral<domain_type>. */
- interval as_rightopen_interval()const;
-
- /** Transforms the interval to the bound-type <tt>bound_types bt</tt> without
- changing it's content. Requires Integral<domain_type>. */
- void transform_bounds(bound_types bt);
-
- /** Sets left border closed. Requires Integral<domain_type>.*/
- //CL void close_left_bound();
-
- /** Sets right border open. Requires Integral<domain_type>. */
- //CL void open_right_bound();
-
+ /** Transforms the interval to the bound-type <tt>bounded</tt> without
+ changing it's content. Requires Integral<domain_type>.
+\code
+interval.as(closed_bounded).is(closed_bounded) &&
+interval.as(right_open).is(right_open) &&
+interval.as(left_open).is(left_open) &&
+interval.as(open_bounded).is(open_bounded)
+\endcode
+ */
+ interval& as(bound_type bounded);
 
         /** An interval that covers the complete range of it's domain_type */
     static interval whole()
@@ -571,22 +566,22 @@
         {return !domain_compare()(left, right) && !domain_compare()(right, left);}
 
 private:
- typedef std::pair<DomainT, bound_types> BoundT;
+ typedef std::pair<DomainT, bound_type> BoundT;
 
 private:
     void set_lwb(DomainT lw) { _lwb=lw; }
     void set_upb(DomainT up) { _upb=up; }
 
- void set_lwb_type(bound_types bt)
- { _boundtypes = (unsigned char)((LEFT_OPEN & _boundtypes) | (RIGHT_OPEN & bt)); }
+ void set_lwb_type(bound_type bounds)
+ { _boundtype = (unsigned char)((left_open & _boundtype) | (right_open & bounds)); }
 
- void set_upb_type(bound_types bt)
- { _boundtypes = (unsigned char)((RIGHT_OPEN & _boundtypes) | (LEFT_OPEN & bt)); }
+ void set_upb_type(bound_type bounds)
+ { _boundtype = (unsigned char)((right_open & _boundtype) | (left_open & bounds)); }
 
- static bound_types span(bound_types left, bound_types right)
- { return (unsigned char)((LEFT_OPEN | left) & (RIGHT_OPEN | right)) ; }
+ static bound_type span(bound_type left, bound_type right)
+ { return (unsigned char)((left_open | left) & (right_open | right)) ; }
 
- bound_types succession_bounds()const;
+ bound_type succession_bounds()const;
 
     void set_lwb(const BoundT& lw) { _lwb=lw.BOUND_VAL; set_lwb_type(lw.BOUND_TYPES); }
     void set_upb(const BoundT& up) { _upb=up.BOUND_VAL; set_upb_type(up.BOUND_TYPES); }
@@ -602,17 +597,17 @@
 private:
     DomainT _lwb;
     DomainT _upb;
- bound_types _boundtypes;
+ bound_type _boundtype;
 } ;
 
 
 template <class DomainT, ITL_COMPARE Compare>
-typename interval<DomainT,Compare>::bound_types interval<DomainT,Compare>::succession_bounds()const
+bound_type interval<DomainT,Compare>::succession_bounds()const
 {
- if(_boundtypes==RIGHT_OPEN) return RIGHT_OPEN;
- if(_boundtypes==LEFT_OPEN) return LEFT_OPEN;
- if(_boundtypes==CLOSED) return OPEN;
- return CLOSED;
+ if(_boundtype==itl::right_open) return itl::right_open;
+ if(_boundtype==itl::left_open) return itl::left_open;
+ if(_boundtype==itl::closed_bounded) return itl::open_bounded;
+ return itl::closed_bounded;
 }
 
 
@@ -645,11 +640,11 @@
 {
     using namespace boost::mpl;
 
- if(rightbound_closed() && leftbound_closed()) return domain_less(_upb, _lwb); //_upb < _lwb;
- if(rightbound_open() && leftbound_closed()) return domain_less_equal(_upb, _lwb); //_upb <= _lwb;
- if(rightbound_closed() && leftbound_open()) return domain_less_equal(_upb, _lwb); //_upb <= _lwb;
+ if(is_right(closed_bounded) && is_left(closed_bounded)) return domain_less(_upb, _lwb); //_upb < _lwb;
+ if(is_right(open_bounded) && is_left(closed_bounded)) return domain_less_equal(_upb, _lwb); //_upb <= _lwb;
+ if(is_right(closed_bounded) && is_left(open_bounded)) return domain_less_equal(_upb, _lwb); //_upb <= _lwb;
 
- // OTHERWISE (rightbound_open() && leftbound_open())
+ // OTHERWISE (is_right(open_bounded) && is_left(open_bounded))
     return
         if_<
             bool_<is_continuous<DomainT>::value>,
@@ -667,7 +662,7 @@
                 typedef typename IntervalT::size_type SizeT;
                 if(x.empty())
                         return itl::neutron<SizeT>::value();
- else if(x.is_closed() && IntervalT::domain_equal(x.lower(), x.upper()))
+ else if(x.is(itl::closed_bounded) && IntervalT::domain_equal(x.lower(), x.upper()))
             return itl::unon<SizeT>::value();
         else
             return std::numeric_limits<SizeT>::infinity();
@@ -711,23 +706,23 @@
 
     static bool unaligned_lwb_equal(const IntervalT& x1, const IntervalT& x2)
     {
- if(x1.leftbound_open() && x2.leftbound_closed())
+ if(x1.is_left(open_bounded) && x2.is_left(closed_bounded))
                          return IntervalT::domain_equal(succ(x1.lower()), x2.lower() );
         else return IntervalT::domain_equal( x1.lower(), succ(x2.lower()));
     }
 
     static bool unaligned_upb_equal(const IntervalT& x1, const IntervalT& x2)
     {
- if(x1.rightbound_closed() && x2.rightbound_open())
+ if(x1.is_right(closed_bounded) && x2.is_right(open_bounded))
              return IntervalT::domain_equal(succ(x1.upper()), x2.upper() );
         else return IntervalT::domain_equal( x1.upper(), succ(x2.upper()));
     }
 
     static bool has_equal_border_touch(const IntervalT& x1, const IntervalT& x2)
     {
- if(x1.rightbound_closed() && x2.leftbound_closed())
+ if(x1.is_right(closed_bounded) && x2.is_left(closed_bounded))
             return IntervalT::domain_equal(succ(x1.upper()), x2.lower());
- if(x1.rightbound_open() && x2.leftbound_open() )
+ if(x1.is_right(open_bounded) && x2.is_left(open_bounded) )
                         return IntervalT::domain_equal(x1.upper(), succ(x2.lower()));
         return false;
     }
@@ -740,9 +735,9 @@
 bool interval<DomainT,Compare>::exclusive_less(const interval& x2)const
 {
     using namespace boost::mpl;
- if(rightbound_closed() && x2.leftbound_closed()) return domain_less(_upb, x2._lwb); //_upb < x2._lwb
- if(rightbound_open() && x2.leftbound_closed()) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
- if(rightbound_closed() && x2.leftbound_open() ) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
+ if(is_right(closed_bounded) && x2.is_left(closed_bounded)) return domain_less(_upb, x2._lwb); //_upb < x2._lwb
+ if(is_right(open_bounded) && x2.is_left(closed_bounded)) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
+ if(is_right(closed_bounded) && x2.is_left(open_bounded) ) return domain_less_equal(_upb, x2._lwb); //_upb <= x2._lwb;
 
     return
         if_<
@@ -758,11 +753,11 @@
 bool interval<DomainT,Compare>::lower_less(const interval& x2)const
 {
     using namespace boost::mpl;
- if(leftbound_closed() && x2.leftbound_closed()) return domain_less(_lwb, x2._lwb);
- if(leftbound_open() && x2.leftbound_open()) return domain_less(_lwb, x2._lwb);
- if(leftbound_closed() && x2.leftbound_open()) return domain_less_equal(_lwb, x2._lwb);//domain_less_equal(_lwb, x2._lwb);
+ if(is_left(closed_bounded) && x2.is_left(closed_bounded)) return domain_less(_lwb, x2._lwb);
+ if(is_left(open_bounded) && x2.is_left(open_bounded)) return domain_less(_lwb, x2._lwb);
+ if(is_left(closed_bounded) && x2.is_left(open_bounded)) return domain_less_equal(_lwb, x2._lwb);//domain_less_equal(_lwb, x2._lwb);
 
- // OTHERWISE (leftbound_open() && x2.leftbound_closed())
+ // OTHERWISE (is_left(open_bounded) && x2.is_left(closed_bounded))
     return
         if_<
             bool_<is_continuous<DomainT>::value>,
@@ -776,11 +771,11 @@
 bool interval<DomainT,Compare>::upper_less(const interval& x2)const
 {
     using namespace boost::mpl;
- if(rightbound_closed() && x2.rightbound_closed()) return domain_less(_upb, x2._upb);
- if(rightbound_open() && x2.rightbound_open()) return domain_less(_upb, x2._upb);
- if(rightbound_open() && x2.rightbound_closed()) return domain_less_equal(_upb, x2._upb);//domain_less_equal(_upb, x2._upb);
+ if(is_right(closed_bounded) && x2.is_right(closed_bounded)) return domain_less(_upb, x2._upb);
+ if(is_right(open_bounded) && x2.is_right(open_bounded)) return domain_less(_upb, x2._upb);
+ if(is_right(open_bounded) && x2.is_right(closed_bounded)) return domain_less_equal(_upb, x2._upb);//domain_less_equal(_upb, x2._upb);
 
- // OTHERWISE (rightbound_closed() && x2.rightbound_open())
+ // OTHERWISE (is_right(closed_bounded) && x2.is_right(open_bounded))
     return
         if_<
             bool_<is_continuous<DomainT>::value>,
@@ -795,11 +790,11 @@
 bool interval<DomainT,Compare>::lower_less_equal(const interval& x2)const
 {
     using namespace boost::mpl;
- if(leftbound_closed() && x2.leftbound_closed()) return domain_less_equal(_lwb, x2._lwb);
- if(leftbound_open() && x2.leftbound_open()) return domain_less_equal(_lwb, x2._lwb);
- if(leftbound_open() && x2.leftbound_closed()) return domain_less(_lwb, x2._lwb);
+ if(is_left(closed_bounded) && x2.is_left(closed_bounded)) return domain_less_equal(_lwb, x2._lwb);
+ if(is_left(open_bounded) && x2.is_left(open_bounded)) return domain_less_equal(_lwb, x2._lwb);
+ if(is_left(open_bounded) && x2.is_left(closed_bounded)) return domain_less(_lwb, x2._lwb);
 
- // OTHERWISE (leftbound_closed() && x2.leftbound_open())
+ // OTHERWISE (is_left(closed_bounded) && x2.is_left(open_bounded))
     return
         if_<
             bool_<is_continuous<DomainT>::value>,
@@ -814,11 +809,11 @@
 bool interval<DomainT,Compare>::upper_less_equal(const interval& x2)const
 {
     using namespace boost::mpl;
- if(rightbound_closed() && x2.rightbound_closed()) return domain_less_equal(_upb, x2._upb);
- if(rightbound_open() && x2.rightbound_open()) return domain_less_equal(_upb, x2._upb);
- if(rightbound_closed() && x2.rightbound_open()) return domain_less(_upb, x2._upb);
+ if(is_right(closed_bounded) && x2.is_right(closed_bounded)) return domain_less_equal(_upb, x2._upb);
+ if(is_right(open_bounded) && x2.is_right(open_bounded)) return domain_less_equal(_upb, x2._upb);
+ if(is_right(closed_bounded) && x2.is_right(open_bounded)) return domain_less(_upb, x2._upb);
 
- // OTHERWISE (rightbound_open() && x2.rightbound_closed())
+ // OTHERWISE (is_right(open_bounded) && x2.is_right(closed_bounded))
     return
         if_<
             bool_<is_continuous<DomainT>::value>,
@@ -835,8 +830,8 @@
 bool interval<DomainT,Compare>::lower_equal(const interval& x2)const
 {
     using namespace boost::mpl;
- if(leftbound_closed() && x2.leftbound_closed()) return domain_equal(_lwb, x2._lwb);
- if(leftbound_open() && x2.leftbound_open() ) return domain_equal(_lwb, x2._lwb);
+ if(is_left(closed_bounded) && x2.is_left(closed_bounded)) return domain_equal(_lwb, x2._lwb);
+ if(is_left(open_bounded) && x2.is_left(open_bounded) ) return domain_equal(_lwb, x2._lwb);
 
     return
         if_<
@@ -853,8 +848,8 @@
 bool interval<DomainT,Compare>::upper_equal(const interval& x2)const
 {
     using namespace boost::mpl;
- if(rightbound_closed() && x2.rightbound_closed()) return domain_equal(_upb, x2._upb);
- if(rightbound_open() && x2.rightbound_open() ) return domain_equal(_upb, x2._upb);
+ if(is_right(closed_bounded) && x2.is_right(closed_bounded)) return domain_equal(_upb, x2._upb);
+ if(is_right(open_bounded) && x2.is_right(open_bounded) ) return domain_equal(_upb, x2._upb);
 
     return
         if_<
@@ -871,18 +866,18 @@
 typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::lwb_min(const interval& x2)const
 {
     if( x2.lower_less(*this) )
- return BoundT(x2._lwb, x2.boundtypes());
+ return BoundT(x2._lwb, x2.boundtype());
     else
- return BoundT(_lwb, boundtypes());
+ return BoundT(_lwb, boundtype());
 }
 
 template <class DomainT, ITL_COMPARE Compare>
 typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::upb_max(const interval& x2)const
 {
     if( upper_less(x2) )
- return BoundT(x2._upb, x2.boundtypes());
+ return BoundT(x2._upb, x2.boundtype());
     else
- return BoundT(_upb, boundtypes());
+ return BoundT(_upb, boundtype());
 }
 
 
@@ -891,18 +886,18 @@
 typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::lwb_max(const interval& x2)const
 {
     if( lower_less(x2) )
- return BoundT(x2._lwb, x2.boundtypes());
+ return BoundT(x2._lwb, x2.boundtype());
     else
- return BoundT(_lwb, boundtypes());
+ return BoundT(_lwb, boundtype());
 }
 
 template <class DomainT, ITL_COMPARE Compare>
 typename interval<DomainT,Compare>::BoundT interval<DomainT,Compare>::upb_min(const interval& x2)const
 {
     if( x2.upper_less(*this) )
- return BoundT(x2._upb, x2.boundtypes());
+ return BoundT(x2._upb, x2.boundtype());
     else
- return BoundT(_upb, boundtypes());
+ return BoundT(_upb, boundtype());
 }
 
 
@@ -924,8 +919,8 @@
 bool interval<DomainT,Compare>::touches(const interval& x2)const
 {
     using namespace boost::mpl;
- if(rightbound_open() && x2.leftbound_closed()) return domain_equal(_upb, x2._lwb);
- if(rightbound_closed() && x2.leftbound_open()) return domain_equal(_upb, x2._lwb);
+ if(is_right(open_bounded) && x2.is_left(closed_bounded)) return domain_equal(_upb, x2._lwb);
+ if(is_right(closed_bounded) && x2.is_left(open_bounded)) return domain_equal(_upb, x2._lwb);
 
     return
         if_<
@@ -939,9 +934,9 @@
 template <class DomainT, ITL_COMPARE Compare>
 bool interval<DomainT,Compare>::contains(const DomainT& x)const
 {
- if(rightbound_closed() && leftbound_closed()) return domain_less_equal(_lwb, x) && domain_less_equal(x, _upb);
- if(rightbound_closed() && leftbound_open() ) return domain_less(_lwb, x) && domain_less_equal(x, _upb);
- if(rightbound_open() && leftbound_closed()) return domain_less_equal(_lwb, x) && domain_less(x, _upb);
+ if(is_right(closed_bounded) && is_left(closed_bounded)) return domain_less_equal(_lwb, x) && domain_less_equal(x, _upb);
+ if(is_right(closed_bounded) && is_left(open_bounded) ) return domain_less(_lwb, x) && domain_less_equal(x, _upb);
+ if(is_right(open_bounded) && is_left(closed_bounded)) return domain_less_equal(_lwb, x) && domain_less(x, _upb);
                                                   return domain_less(_lwb, x) && domain_less(x, _upb);
 }
 
@@ -1001,9 +996,9 @@
 void interval<DomainT,Compare>::right_subtract(interval<DomainT,Compare>& lsur, const interval<DomainT,Compare>& x2)const
 {
     if(lower_less(x2)) {
- lsur.set_lwb( BoundT(_lwb,boundtypes()) );
+ lsur.set_lwb( BoundT(_lwb,boundtype()) );
                 if(exclusive_less(x2))
- lsur.set_upb( BoundT(_upb,boundtypes()) );
+ lsur.set_upb( BoundT(_upb,boundtype()) );
                 else
             lsur.set_upb( upb_leftOf(x2) );
     }
@@ -1015,10 +1010,10 @@
 {
     if(x2.upper_less(*this)) {
                 if(x2.exclusive_less(*this))
- rsur.set_lwb( BoundT(_lwb,boundtypes()) );
+ rsur.set_lwb( BoundT(_lwb,boundtype()) );
                 else
             rsur.set_lwb(lwb_rightOf(x2));
- rsur.set_upb( BoundT(_upb,boundtypes()) );
+ rsur.set_upb( BoundT(_upb,boundtype()) );
     }
     else rsur.clear();
 }
@@ -1030,11 +1025,11 @@
     std::string itvRep("");
     std::string lwbRep, ubpRep;
 
- itvRep += leftbound_open() ? "(" : "[" ;
+ itvRep += is_left(open_bounded) ? "(" : "[" ;
     itvRep += itl::to_string<DomainT>::apply(_lwb);
     itvRep += ",";
     itvRep += itl::to_string<DomainT>::apply(_upb);
- itvRep += rightbound_open() ? ")" : "]" ;
+ itvRep += is_right(open_bounded) ? ")" : "]" ;
 
     return itvRep;
 }
@@ -1051,14 +1046,14 @@
 {
     //JODO BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value)); //complains incorrectly sometimes
     BOOST_ASSERT((!itl::is_continuous<DomainT>::value));
- return leftbound_closed() ? _lwb : succ(_lwb);
+ return is_left(closed_bounded) ? _lwb : succ(_lwb);
 }
 
 template <class DomainT, ITL_COMPARE Compare>
 DomainT interval<DomainT,Compare>::last()const
 {
     BOOST_ASSERT((!itl::is_continuous<DomainT>::value));
- return rightbound_closed() ? _upb : pred(_upb);
+ return is_right(closed_bounded) ? _upb : pred(_upb);
 }
 
 template <class DomainT, ITL_COMPARE Compare>
@@ -1085,52 +1080,19 @@
               ::type::length(*this);
 }
 
-
-template <class DomainT, ITL_COMPARE Compare>
-interval<DomainT,Compare> interval<DomainT,Compare>::as_closed_interval()const
-{
- return interval(first(), last(), CLOSED);
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-interval<DomainT,Compare> interval<DomainT,Compare>::as_rightopen_interval()const
-{
- return interval(first(), pred(last()), RIGHT_OPEN);
-}
-
 template <class DomainT, ITL_COMPARE Compare>
-void interval<DomainT,Compare>::transform_bounds(bound_types bt)
+interval<DomainT,Compare>& interval<DomainT,Compare>::as(bound_type bounded)
 {
- switch(bt)
+ switch(bounded)
     {
- case CLOSED: set(first(), last(), bt); break;
- case RIGHT_OPEN:set(first(), succ(last()), bt); break;
- case LEFT_OPEN: set(pred(first()), last(), bt); break;
- case OPEN: set(pred(first()), succ(last()), bt); break;
+ case itl::closed_bounded: set(first(), last(), bounded); break;
+ case itl::right_open : set(first(), succ(last()), bounded); break;
+ case itl::left_open : set(pred(first()), last(), bounded); break;
+ case itl::open_bounded : set(pred(first()), succ(last()), bounded); break;
     }
+ return *this;
 }
 
-/*CL
-template <class DomainT, ITL_COMPARE Compare>
-void interval<DomainT,Compare>::close_left_bound()
-{
- if(leftbound_open())
- {
- _boundtypes |= RIGHT_OPEN;
- _lwb++;
- }
-}
-
-template <class DomainT, ITL_COMPARE Compare>
-void interval<DomainT,Compare>::open_right_bound()
-{
- if(rightbound_closed())
- {
- _boundtypes &= RIGHT_OPEN;
- _upb++;
- }
-}
-*/
 
 /** Equality on intervals */
 template <class DomainT, ITL_COMPARE Compare>
@@ -1214,9 +1176,9 @@
         return stream << "[]";
     else
     {
- return stream << std::string(x.leftbound_open() ? "(" : "[")
+ return stream << std::string(x.is_left(open_bounded) ? "(" : "[")
                       << x.lower() << "," << x.upper()
- << std::string(x.rightbound_open()? ")" : "]");
+ << std::string(x.is_right(open_bounded)? ")" : "]");
     }
 }
 

Modified: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -826,16 +826,15 @@
         <b>Nicht getestet</b> */
     CodomainT sum()const;
 
- /** Set interval bounds to the type <tt>bt</tt> for intervals in the map.
+ /** Set all intervals in the map to be of type <tt>bounded</tt>.
+ Requires Integral<domain_type>.
 
         Interval bounds of different types are created by opeations on
         interval maps. This function allows to reset them uniformly without,
         of course, changing their value. This is only possible for discrete
         domain datatypes.
     */
- void uniformBounds( typename interval<DomainT>::bound_types bt);
-
- void closeLeftBounds();
+ void uniform_bounds(itl::bound_type bounded);
 
     template<typename IteratorT>
     static const key_type& key_value(IteratorT& value_){ return (*value_).first; }
@@ -1119,11 +1118,11 @@
     class SubType,
     class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc
>
-void interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>::uniformBounds( typename interval<DomainT>::bound_types bt)
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>::uniform_bounds(itl::bound_type bounded)
 {
     // I can do this only, because I am shure that the contents and the
     // ordering < on interval is invariant wrt. this transformation on bounds
- FOR_IMPLMAP(it) const_cast<interval_type&>((*it).KEY_VALUE).transformBounds(bt);
+ FOR_IMPLMAP(it) const_cast<interval_type&>((*it).KEY_VALUE).as(bounded);
 }
 
 template
@@ -1131,20 +1130,6 @@
     class SubType,
     class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc
>
-void interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>::closeLeftBounds()
-{
- // I can do this only, because I am shure that the contents and the
- // ordering < on interval is invariant wrt. this transformation on bounds
- FOR_IMPLMAP(it) const_cast<interval_type&>((*it).KEY_VALUE).closeLeftBound();
-}
-
-
-
-template
-<
- class SubType,
- class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc
->
 SubType& interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::erase(const interval_type& x_itv)
 {

Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -411,7 +411,7 @@
         of course, changing their value. This is only possible for discrete
         domain datatypes.
     */
- void uniform_bounds(typename interval<DomainT>::bound_types bt);
+ void uniform_bounds(itl::bound_type bounded);
 
 //@}
 
@@ -578,11 +578,11 @@
 
 template<class SubType,
          class DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
-void interval_base_set<SubType,DomainT,Compare,Interval,Alloc>::uniform_bounds(typename interval<DomainT>::bound_types bt)
+void interval_base_set<SubType,DomainT,Compare,Interval,Alloc>::uniform_bounds(itl::bound_type bounded)
 {
     // I can do this only, because I am shure that the contents and the
     // ordering < on interval is invariant wrt. this transformation on bounds
- FOR_IMPL(it) const_cast<interval_type&>(*it).transform_bounds(bt);
+ FOR_IMPL(it) const_cast<interval_type&>(*it).as(bounded);
 }
 
 

Modified: sandbox/itl/boost/itl/operators.hpp
==============================================================================
--- sandbox/itl/boost/itl/operators.hpp (original)
+++ sandbox/itl/boost/itl/operators.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -46,10 +46,9 @@
 { return ObjectT(object) &= operand; }
 
 template<class ObjectT>
-ObjectT operator & (const ObjectT& object, const ObjectT& operand)
+ObjectT operator & (const typename ObjectT::type& object, const ObjectT& operand)//JODO: inhibit false overloads!
 { return ObjectT(object) &= operand; }
 
-
 }} // namespace itl boost
 
 #endif

Modified: sandbox/itl/boost/itl_xt/itvgentor.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/itvgentor.hpp (original)
+++ sandbox/itl/boost/itl_xt/itvgentor.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -46,7 +46,7 @@
     virtual void some(ItvTV& x);
 
     void setValueRange(ItvDomTV low, ItvDomTV up)
- { m_valueRange.set(low,up, ItvTV::RIGHT_OPEN); }
+ { m_valueRange.set(low,up, itl::right_open); }
 
     void setMaxIntervalLength(ItvDomTV len) { m_maxIntervalLength=len; }
     void setProbDerivation();
@@ -65,7 +65,7 @@
 {
     NumberGentorT<unsigned> NATGentor;
     ItvDomTV x1 = m_ItvDomTVGentor(m_valueRange);
- ITV_BOUNDTYPES bndTypes = NATGentor(4);
+ itl::bound_type bndTypes = NATGentor(4);
     unsigned upOrDown = NATGentor(1);
     unsigned decideEmpty = NATGentor(2);
 

Modified: sandbox/itl/boost/itl_xt/numbergentor.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/numbergentor.hpp (original)
+++ sandbox/itl/boost/itl_xt/numbergentor.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -85,14 +85,14 @@
 {
 public:
     NumberGentorT():
- m_valueRange( NumTV(), unon<NumTV>::value(), interval<NumTV>::RIGHT_OPEN ) {}
+ m_valueRange( NumTV(), unon<NumTV>::value(), right_open ) {}
 
     NumTV operator() (NumTV upb) { return rnd_0_to_excl<NumTV>(upb); }
     NumTV operator() (NumTV lwb, NumTV upb) { return rnd_within_exUpb<NumTV>(lwb,upb); }
     NumTV operator() (interval<NumTV> rng)
     {
         BOOST_ASSERT(rng.is_rightopen() || rng.is_closed());
- if(rng.is_rightopen())
+ if(rng.is(right_open))
             return rnd_within_exUpb<NumTV>(rng.lower(), rng.upper());
         else
             return rnd_within<NumTV>(rng.lower(), rng.upper());

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-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -37,7 +37,7 @@
 
     BOOST_CHECK_EQUAL(interval<T>(), interval<T>());
     BOOST_CHECK_EQUAL(interval<T>(), interval<T>(itl::unon<T>::value(), itl::neutron<T>::value()));
- BOOST_CHECK_EQUAL(interval<T>(), interval<T>(itl::unon<T>::value(), itl::neutron<T>::value(), interval<T>::CLOSED));
+ BOOST_CHECK_EQUAL(interval<T>(), interval<T>(itl::unon<T>::value(), itl::neutron<T>::value(), closed_bounded));
 
 }
 
@@ -50,14 +50,14 @@
 
     T v4 = make<T>(4);
     itl::interval<T> I4_4I(v4);
- BOOST_CHECK_EQUAL( I4_4I.is_closed(), true );
- BOOST_CHECK_EQUAL( I4_4I.is_leftopen(), false );
- BOOST_CHECK_EQUAL( I4_4I.is_rightopen(), false );
- BOOST_CHECK_EQUAL( I4_4I.is_open(), false );
- BOOST_CHECK_EQUAL( I4_4I.leftbound_closed(), true );
- BOOST_CHECK_EQUAL( I4_4I.rightbound_closed(), true );
- BOOST_CHECK_EQUAL( I4_4I.leftbound_open(), false );
- BOOST_CHECK_EQUAL( I4_4I.rightbound_open(), false );
+ BOOST_CHECK_EQUAL( I4_4I.is(closed_bounded), true );
+ BOOST_CHECK_EQUAL( I4_4I.is(left_open), false );
+ BOOST_CHECK_EQUAL( I4_4I.is(right_open), false );
+ BOOST_CHECK_EQUAL( I4_4I.is(open_bounded), false );
+ BOOST_CHECK_EQUAL( I4_4I.is_left(closed_bounded), true );
+ BOOST_CHECK_EQUAL( I4_4I.is_right(closed_bounded), true );
+ BOOST_CHECK_EQUAL( I4_4I.is_left(open_bounded), false );
+ BOOST_CHECK_EQUAL( I4_4I.is_right(open_bounded), false );
 
     BOOST_CHECK_EQUAL( I4_4I.lower(), v4 );
     BOOST_CHECK_EQUAL( I4_4I.upper(), v4 );
@@ -79,38 +79,38 @@
 
     T v2 = make<T>(2);
     BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4), interval<T>(v2, v4) );
- BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4), interval<T>(v2, v4, interval<T>::CLOSED) );
- BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4), interval<T>(v2, v4, interval<T>::RIGHT_OPEN) );
- BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4), interval<T>(v2, v4, interval<T>::LEFT_OPEN) );
- BOOST_CHECK_EQUAL( interval<T>::open(v2, v4), interval<T>(v2, v4, interval<T>::OPEN) );
+ BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4), interval<T>(v2, v4, closed_bounded) );
+ BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4), interval<T>(v2, v4, right_open) );
+ BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4), interval<T>(v2, v4, left_open) );
+ BOOST_CHECK_EQUAL( interval<T>::open(v2, v4), interval<T>(v2, v4, open_bounded) );
 
     BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).lower(), v2 );
     BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).upper(), v4 );
- BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).boundtypes(), interval<T>::CLOSED );
- BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).is_closed(), true );
- BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).leftbound_closed(), true );
- BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).rightbound_closed(), true );
+ BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).boundtype(), closed_bounded );
+ BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).is(closed_bounded), true );
+ BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).is_left(closed_bounded), true );
+ BOOST_CHECK_EQUAL( interval<T>::closed(v2, v4).is_right(closed_bounded), true );
 
     BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).lower(), v2 );
     BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).upper(), v4 );
- BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).boundtypes(), interval<T>::RIGHT_OPEN );
- BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).is_rightopen(), true );
- BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).leftbound_closed(), true );
- BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).rightbound_open(), true );
+ BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).boundtype(), right_open );
+ BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).is(right_open), true );
+ BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).is_left(closed_bounded), true );
+ BOOST_CHECK_EQUAL( interval<T>::rightopen(v2, v4).is_right(open_bounded), true );
 
     BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).lower(), v2 );
     BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).upper(), v4 );
- BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).boundtypes(), interval<T>::LEFT_OPEN );
- BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).is_leftopen(), true );
- BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).leftbound_open(), true );
- BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).rightbound_closed(), true );
+ BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).boundtype(), left_open );
+ BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).is(left_open), true );
+ BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).is_left(open_bounded), true );
+ BOOST_CHECK_EQUAL( interval<T>::leftopen(v2, v4).is_right(closed_bounded), true );
 
     BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).lower(), v2 );
     BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).upper(), v4 );
- BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).boundtypes(), interval<T>::OPEN );
- BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).is_open(), true );
- BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).leftbound_open(), true );
- BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).rightbound_open(), true );
+ BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).boundtype(), open_bounded );
+ BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).is(open_bounded), true );
+ BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).is_left(open_bounded), true );
+ BOOST_CHECK_EQUAL( interval<T>::open(v2, v4).is_right(open_bounded), true );
 }
 
 BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_ctor_4_integral_types, T, integral_types)
@@ -411,5 +411,4 @@
         diff_2 = I4_7D;
         diff_2.left_subtract(I0_3D);
     BOOST_CHECK_EQUAL( diff_2, I4_7D );
-
 }

Modified: sandbox/itl/libs/itl/test/test_value_maker.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_value_maker.hpp (original)
+++ sandbox/itl/libs/itl/test/test_value_maker.hpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -101,10 +101,10 @@
         }
 };
 
-#define IIv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, closed)
+#define IIv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, closed_bounded)
 #define IDv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, right_open)
 #define CIv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, left_open)
-#define CDv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, open)
+#define CDv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, open_bounded)
 #define K_v(key,val) map_val<IntervalMapT>::map_pair(key,val)
 
 }} // namespace boost itl

Modified: sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp
==============================================================================
--- sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp (original)
+++ sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp 2009-01-20 14:39:34 EST (Tue, 20 Jan 2009)
@@ -256,7 +256,12 @@
         //double fst = doubItv.first();
         interval<int> intItv = interval<int>::closed(0, 2);
         int fst = intItv.first();
- cout << intItv << endl;
+ cout << " c: "<< itl::closed_bounded << endl;
+ cout << "c&o: "<< (itl::closed_bounded & itl::open_bounded)<< endl;
+ cout << " !c: "<< !(itl::closed_bounded)<< endl;
+ cout << " !o: "<< !(itl::open_bounded)<< endl;
+ cout << "2>>1: "<< (2 >> 1) << endl;
+ cout << "0>>1: "<< (0 >> 1) << endl;
 }
 
 int main()


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