|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65377 - in sandbox/itl: boost/itl libs/itl/test libs/validate/example/labat_single_
From: afojgo_at_[hidden]
Date: 2010-09-10 18:28:26
Author: jofaber
Date: 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
New Revision: 65377
URL: http://svn.boost.org/trac/boost/changeset/65377
Log:
Refactoring: Extraction of flip member functions from interval_base_map. Stable{msvc-9.0, gcc-3.4.4}
Text files modified:
sandbox/itl/boost/itl/functions.hpp | 518 +++++++++++++++++++++++++--------------
sandbox/itl/boost/itl/interval_base_map.hpp | 165 -----------
sandbox/itl/boost/itl/interval_base_set.hpp | 8
sandbox/itl/libs/itl/test/test_interval_map_mixed.hpp | 8
sandbox/itl/libs/itl/test/test_interval_map_shared.hpp | 28 +-
sandbox/itl/libs/itl/test/test_interval_quantifier_shared.hpp | 4
sandbox/itl/libs/itl/test/test_interval_set_mixed.hpp | 22
sandbox/itl/libs/itl/test/test_interval_set_shared.hpp | 4
sandbox/itl/libs/itl/test/test_laws.hpp | 4
sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp | 3
10 files changed, 379 insertions(+), 385 deletions(-)
Modified: sandbox/itl/boost/itl/functions.hpp
==============================================================================
--- sandbox/itl/boost/itl/functions.hpp (original)
+++ sandbox/itl/boost/itl/functions.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -250,11 +250,7 @@
{
typename Type::iterator prior_ = object.end();
ITL_const_FORALL(typename OperandT, elem_, operand)
- prior_ = object.add(prior_, *elem_);
- //JODO prior_ = itl::add(object, prior_, *elem_);
- //JODO Problems with missing combining style of interval_baseobject.
- //JODO Prior to this, we have to implement the Trait class for
- //JODO combining styles for interval_base_maps.
+ prior_ = itl::add(object, prior_, *elem_);
return object;
}
@@ -285,7 +281,7 @@
operator += (Type& object, const OperandT& operand)
{
//JODO return itl::add(object, operand);
- return object.add(operand);
+ return itl::add(object, operand);
}
@@ -388,158 +384,6 @@
return object += operand;
}
-
-//==============================================================================
-//= Subtraction
-//==============================================================================
-//------------------------------------------------------------------------------
-//- Subtraction<Interval_Set> fragment_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-subtract(Type& object, const typename Type::element_type& operand)
-{
- Interval_Set::subtract(object, typename Type::segment_type(operand));
- return object;
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-subtract(Type& object, const typename Type::segment_type& operand)
-{
- Interval_Set::subtract(object, operand);
- return object;
-}
-
-//------------------------------------------------------------------------------
-//- Subtraction<Interval_Map> fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if
- <mpl::and_< is_interval_map<Type>
- , mpl::and_< is_total<Type>
- , has_inverse<typename Type::codomain_type> >
- >,
- Type>::type&
-subtract(Type& object, const typename Type::segment_type& operand)
-{
- typedef typename Type::inverse_codomain_combine inverse_codomain_combine;
- Interval_Map::add<Type,inverse_codomain_combine>(object, operand);
- return object;
-}
-
-template<class Type>
-typename enable_if
- <mpl::and_< is_interval_map<Type>
- , mpl::not_<mpl::and_< is_total<Type>
- , has_inverse<typename Type::codomain_type> > >
- >,
- Type>::type&
-subtract(Type& object, const typename Type::segment_type& operand)
-{
- typedef typename Type::inverse_codomain_combine inverse_codomain_combine;
- Interval_Map::subtract<Type,inverse_codomain_combine>(object, operand);
- return object;
-}
-
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::element_type& operand)
-{
- itl::subtract(object, make_segment<Type>(operand));
- return object;
-}
-
-//------------------------------------------------------------------------------
-//- Subtraction<Interval_Map> key_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::domain_type& operand)
-{
- typedef typename Type::interval_type interval_type;
- Interval_Map::erase(object, interval_type(operand));
- return object;
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::interval_type& operand)
-{
- Interval_Map::erase(object, operand);
- return object;
-}
-
-
-//------------------------------------------------------------------------------
-//- Subtraction -=, -
-//------------------------------------------------------------------------------
-
-/** \par \b Requires: Types \c Type and \c OperandT are subtractable.
- \par \b Effects: \c operand is subtracted from \c object.
- \par \b Returns: A reference to \c object.
- \b Complexity:
-\code
- \ OperandT: interval
- \ element segment container
-Type:
- interval container O(log n) O(n) O(m log(n+m))
-
- amortized
- interval_sets O(log n)
-
-n = object.interval_count()
-m = operand.interval_count()
-\endcode
-
-For the subtraction of \em elements, \b segments and \b interval \b containers
-complexity is \b logarithmic, \b linear and \b loglinear respectively.
-For interval sets subtraction of segments
-is \b amortized \b logarithmic.
-*/
-template<class Type, class OperandT>
-typename enable_if<has_same_concept<is_interval_map, Type, OperandT>,
- Type>::type&
-operator -=(Type& object, const OperandT& operand)
-{
- ITL_const_FORALL(typename OperandT, elem_, operand)
- object.subtract(*elem_); //JODO
-
- return object;
-}
-
-template<class Type, class OperandT>
-typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
-operator -= (Type& object, const OperandT& operand)
-{
- //JODO return itl::subtract(object, operand);
- return object.subtract(operand);
-}
-
-template<class Type, class OperandT>
-typename enable_if<is_cross_derivative<Type, OperandT>, Type>::type&
-operator -= (Type& object, const OperandT& operand)
-{
- return object.erase(operand);
-}
-
-template<class Type, class IntervalSetT>
-typename enable_if<combines_right_to_interval_set<Type, IntervalSetT>,
- Type>::type&
-operator -= (Type& object, const IntervalSetT& operand)
-{
- return erase(object, operand);
-}
-
-
-template<class Type, class OperandT>
-typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
-operator - (Type object, const OperandT& operand)
-{
- return object -= operand;
-}
-
//==============================================================================
//= Insertion
//==============================================================================
@@ -599,7 +443,6 @@
return object;
}
-
//==============================================================================
//= Erasure
//==============================================================================
@@ -610,14 +453,14 @@
typename enable_if<is_interval_set<Type>, Type>::type&
erase(Type& object, const typename Type::segment_type& minuend)
{
- return itl::subtract(object, minuend);
+ return itl::subtract(object, minuend);
}
template<class Type>
typename enable_if<is_interval_set<Type>, Type>::type&
erase(Type& object, const typename Type::element_type& minuend)
{
- return itl::subtract(object, minuend);
+ return itl::subtract(object, minuend);
}
//------------------------------------------------------------------------------
@@ -638,9 +481,9 @@
if(exterior.first == exterior.second)
return object;
- iterator first_ = exterior.first,
- end_ = exterior.second,
- last_ = prior(end_);
+ iterator first_ = exterior.first,
+ end_ = exterior.second,
+ last_ = prior(end_);
interval_type left_resid = right_subtract(first_->first, minuend);
interval_type right_resid = left_subtract(last_ ->first, minuend);
@@ -650,7 +493,7 @@
{
const_cast<interval_type&>(first_->first) = left_resid;
if(!itl::is_empty(right_resid))
- object.insert(first_, value_type(right_resid, first_->second));
+ itl::insert(object, first_, value_type(right_resid, first_->second));
}
else if(!itl::is_empty(right_resid))
const_cast<interval_type&>(first_->first) = left_subtract(first_->first, minuend);
@@ -679,7 +522,7 @@
erase(Type& object, const typename Type::domain_type& minuend)
{
typedef typename Type::interval_type interval_type;
- return itl::erase(object, interval_type(minuend));
+ return itl::erase(object, interval_type(minuend));
}
//------------------------------------------------------------------------------
@@ -689,15 +532,15 @@
typename enable_if<is_interval_map<Type>, Type>::type&
erase(Type& object, const typename Type::segment_type& minuend)
{
- Interval_Map::erase(object, minuend);
- return object;
+ Interval_Map::erase(object, minuend);
+ return object;
}
template<class Type>
typename enable_if<is_interval_map<Type>, Type>::type&
erase(Type& object, const typename Type::element_type& minuend)
{
- return itl::erase(object, make_segment<Type>(minuend));
+ return itl::erase(object, make_segment<Type>(minuend));
}
//------------------------------------------------------------------------------
@@ -706,7 +549,7 @@
Type>::type&
erase(Type& object, const OperandT& operand)
{
- typedef typename OperandT::const_iterator const_iterator;
+ typedef typename OperandT::const_iterator const_iterator;
if(itl::is_empty(operand))
return object;
@@ -717,11 +560,162 @@
const_iterator it_ = common_lwb;
while(it_ != common_upb)
- itl::erase(object, *it_++);
+ itl::erase(object, *it_++);
+
+ return object;
+}
+
+//==============================================================================
+//= Subtraction
+//==============================================================================
+//------------------------------------------------------------------------------
+//- Subtraction<Interval_Set> fragment_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+subtract(Type& object, const typename Type::element_type& operand)
+{
+ Interval_Set::subtract(object, typename Type::segment_type(operand));
+ return object;
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+subtract(Type& object, const typename Type::segment_type& operand)
+{
+ Interval_Set::subtract(object, operand);
+ return object;
+}
+
+//------------------------------------------------------------------------------
+//- Subtraction<Interval_Map> fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if
+ <mpl::and_< is_interval_map<Type>
+ , mpl::and_< is_total<Type>
+ , has_inverse<typename Type::codomain_type> >
+ >,
+ Type>::type&
+subtract(Type& object, const typename Type::segment_type& operand)
+{
+ typedef typename Type::inverse_codomain_combine inverse_codomain_combine;
+ Interval_Map::add<Type,inverse_codomain_combine>(object, operand);
+ return object;
+}
+
+template<class Type>
+typename enable_if
+ <mpl::and_< is_interval_map<Type>
+ , mpl::not_<mpl::and_< is_total<Type>
+ , has_inverse<typename Type::codomain_type> > >
+ >,
+ Type>::type&
+subtract(Type& object, const typename Type::segment_type& operand)
+{
+ typedef typename Type::inverse_codomain_combine inverse_codomain_combine;
+ Interval_Map::subtract<Type,inverse_codomain_combine>(object, operand);
+ return object;
+}
+
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::element_type& operand)
+{
+ itl::subtract(object, make_segment<Type>(operand));
+ return object;
+}
+
+//------------------------------------------------------------------------------
+//- Subtraction<Interval_Map> key_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::domain_type& operand)
+{
+ typedef typename Type::interval_type interval_type;
+ Interval_Map::erase(object, interval_type(operand));
+ return object;
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::interval_type& operand)
+{
+ Interval_Map::erase(object, operand);
+ return object;
+}
+
+
+//------------------------------------------------------------------------------
+//- Subtraction -=, -
+//------------------------------------------------------------------------------
+
+/** \par \b Requires: Types \c Type and \c OperandT are subtractable.
+ \par \b Effects: \c operand is subtracted from \c object.
+ \par \b Returns: A reference to \c object.
+ \b Complexity:
+\code
+ \ OperandT: interval
+ \ element segment container
+Type:
+ interval container O(log n) O(n) O(m log(n+m))
+
+ amortized
+ interval_sets O(log n)
+
+n = object.interval_count()
+m = operand.interval_count()
+\endcode
+
+For the subtraction of \em elements, \b segments and \b interval \b containers
+complexity is \b logarithmic, \b linear and \b loglinear respectively.
+For interval sets subtraction of segments
+is \b amortized \b logarithmic.
+*/
+template<class Type, class OperandT>
+typename enable_if<has_same_concept<is_interval_map, Type, OperandT>,
+ Type>::type&
+operator -=(Type& object, const OperandT& operand)
+{
+ ITL_const_FORALL(typename OperandT, elem_, operand)
+ itl::subtract(object, *elem_);
return object;
}
+template<class Type, class OperandT>
+typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
+operator -= (Type& object, const OperandT& operand)
+{
+ return itl::subtract(object, operand);
+}
+
+template<class Type, class OperandT>
+typename enable_if<is_cross_derivative<Type, OperandT>, Type>::type&
+operator -= (Type& object, const OperandT& operand)
+{
+ return itl::erase(object, operand);
+}
+
+template<class Type, class IntervalSetT>
+typename enable_if<combines_right_to_interval_set<Type, IntervalSetT>,
+ Type>::type&
+operator -= (Type& object, const IntervalSetT& operand)
+{
+ return erase(object, operand);
+}
+
+
+template<class Type, class OperandT>
+typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
+operator - (Type object, const OperandT& operand)
+{
+ return object -= operand;
+}
+
+
//------------------------------------------------------------------------------
//- set (selective update)
//------------------------------------------------------------------------------
@@ -1107,16 +1101,15 @@
bool>::type
intersects(const Type& left, const AssociateT& right)
{
- return left.intersects(right);
+ return itl::intersects(left, right);
}
/** \b Returns true, if \c left and \c right have no common elements.
Intervals are interpreted as sequence of elements.
\b Complexity: loglinear, if \c left and \c right are interval containers. */
template<class LeftT, class RightT>
-typename enable_if<is_inter_combinable<LeftT, RightT>,
- bool>::type
-is_disjoint(const LeftT& left, const RightT& right)
+typename enable_if<is_inter_combinable<LeftT, RightT>, bool>::type
+disjoint(const LeftT& left, const RightT& right)
{
return !intersects(left, right);
}
@@ -1126,9 +1119,8 @@
\b Complexity: logarithmic, if \c AssociateT is an element type \c Type::element_type.
linear, if \c AssociateT is a segment type \c Type::segment_type. */
template<class Type, class AssociateT>
-typename enable_if<is_inter_derivative<Type, AssociateT>,
- bool>::type
-is_disjoint(const Type& left, const AssociateT& right)
+typename enable_if<is_inter_derivative<Type, AssociateT>, bool>::type
+disjoint(const Type& left, const AssociateT& right)
{
return !left.intersects(right);
}
@@ -1138,12 +1130,11 @@
//= Symmetric difference
//==============================================================================
//------------------------------------------------------------------------------
-//- Symmetric difference flip
+//- Symmetric difference flip<Interval_Set> fragment_types
//------------------------------------------------------------------------------
-
template<class Type>
typename enable_if<is_interval_set<Type>, Type>::type&
-flip(Type& object, const typename Type::domain_type& operand)
+flip(Type& object, const typename Type::element_type& operand)
{
if(itl::contains(object, operand))
return object -= operand;
@@ -1151,13 +1142,6 @@
return object += operand;
}
-//JODO MEMO: This did not compile, no idea why.
-//template<class Type, class OperandT>
-//typename enable_if<mpl::and_< is_interval_set<Type>
-// , is_same<segment_type_of<Type>, OperandT> >,
-// Type>::type&
-//flip(Type& object, const OperandT& segment)
-
template<class Type>
typename enable_if<is_interval_set<Type>, Type>::type&
flip(Type& object, const typename Type::segment_type& segment)
@@ -1199,8 +1183,8 @@
template<class Type, class OperandT>
-typename enable_if<has_same_concept<is_interval_set, Type, OperandT>, Type>::type&
-JODO_flip(Type& object, const OperandT& operand)
+typename enable_if<is_concept_compatible<is_interval_set, Type, OperandT>, Type>::type&
+flip(Type& object, const OperandT& operand)
{
typedef typename OperandT::const_iterator const_iterator;
@@ -1227,6 +1211,156 @@
return object;
}
+//------------------------------------------------------------------------------
+//- Symmetric difference flip<Interval_Map> fragment_types
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if< mpl::and_< is_interval_map_right_intra_combinable<Type, OperandT> //JODO =^= fragment_type_of
+ , is_total<Type>
+ , absorbs_neutrons<Type> >
+ , Type >::type&
+flip(Type& object, const OperandT&)
+{
+ itl::clear(object);
+ return object;
+}
+
+
+template<class Type, class OperandT>
+typename enable_if< mpl::and_< is_interval_map_right_intra_combinable<Type, OperandT>
+ , is_total<Type>
+ , mpl::not_<absorbs_neutrons<Type> > >
+ , Type >::type&
+flip(Type& object, const OperandT& operand)
+{
+ typedef typename Type::codomain_type codomain_type;
+ object += operand;
+ ITL_FORALL(typename Type, it_, object) //JODO: neutralisierendes add.
+ it_->second = neutron<codomain_type>::value();
+
+ if(mpl::not_<is_interval_splitter<Type> >::value) //JODO
+ object.join();
+
+ return object;
+}
+
+
+template<class Type>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , mpl::not_<is_total<Type> > >, Type>::type&
+flip(Type& object, const typename Type::segment_type& interval_value_pair)
+{
+ typedef typename Type::set_type set_type;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::codomain_type codomain_type;
+ typedef typename Type::inverse_codomain_intersect inverse_codomain_intersect;
+ // That which is common shall be subtracted
+ // That which is not shall be added
+ // So x has to be 'complementary added' or flipped
+
+ interval_type span = interval_value_pair.first;
+ std::pair<const_iterator, const_iterator> exterior
+ = object.equal_range(span);
+
+ const_iterator first_ = exterior.first;
+ const_iterator end_ = exterior.second;
+
+ interval_type covered, left_over, common_interval;
+ const codomain_type& x_value = interval_value_pair.second;
+ const_iterator it_ = first_;
+
+ set_type eraser;
+ Type intersection;
+
+ while(it_ != end_ )
+ {
+ const codomain_type& co_value = it_->second;
+ covered = (*it_++).first;
+ //[a ... : span
+ // [b ... : covered
+ //[a b) : left_over
+ left_over = right_subtract(span, covered);
+
+ //That which is common ...
+ common_interval = span & covered;
+ if(!itl::is_empty(common_interval))
+ {
+ // ... shall be subtracted
+ itl::add(eraser, common_interval);
+
+ if(has_set_semantics<codomain_type>::value) //JODO
+ {
+ codomain_type common_value = x_value;
+ inverse_codomain_intersect()(common_value, co_value);
+ itl::add(intersection, value_type(common_interval, common_value));
+ }
+ else
+ itl::add(intersection, value_type(common_interval, neutron<codomain_type>::value()));
+ }
+
+ itl::add(object, value_type(left_over, x_value)); //That which is not shall be added
+ // Because this is a collision free addition I don't have to distinguish codomain_types.
+
+ //... d) : span
+ //... c) : covered
+ // [c d) : span'
+ span = left_subtract(span, covered);
+ }
+
+ //If span is not empty here, it is not in the set so it shall be added
+ itl::add(object, value_type(span, x_value));
+
+ //finally rewrite the common segments
+ itl::erase(object, eraser);
+ object += intersection;
+
+ return object;
+}
+
+template<class Type>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , mpl::not_<is_total<Type> > >, Type>::type&
+flip(Type& object, const typename Type::element_type& key_value_pair)
+{
+ return itl::flip(object, make_segment<Type>(key_value_pair));
+}
+
+
+
+template<class Type, class OperandT>
+typename enable_if< mpl::and_< mpl::not_<is_total<Type> >
+ , is_concept_compatible<is_interval_map,
+ Type, OperandT >
+ >
+ , Type>::type&
+flip(Type& object, const OperandT& operand)
+{
+ typedef typename OperandT::const_iterator const_iterator;
+ typedef typename Type::codomain_type codomain_type;
+
+ const_iterator common_lwb, common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return object += operand;
+
+ const_iterator it_ = operand.begin();
+
+ // All elements of operand left of the common range are added
+ while(it_ != common_lwb)
+ itl::add(object, *it_++);
+ // All elements of operand in the common range are symmetrically subtracted
+ while(it_ != common_upb)
+ itl::flip(object, *it_++);
+ // All elements of operand right of the common range are added
+ while(it_ != operand.end())
+ itl::add(object, *it_++);
+
+ return object;
+}
+
+
//------------------------------------------------------------------------------
//- Symmetric difference ^=, ^
@@ -1236,7 +1370,7 @@
Type>::type&
operator ^= (Type& object, const OperandT& operand)
{
- return object.flip(operand);
+ return itl::flip(object, operand);
}
template<class Type, class OperandT>
@@ -1244,7 +1378,7 @@
Type>::type&
operator ^= (Type& object, const OperandT& operand)
{
- return object.flip(operand);
+ return itl::flip(object, operand);
}
template<class Type, class OperandT>
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 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -489,15 +489,24 @@
/** If \c *this map contains \c key_value_pair it is erased, otherwise it is added. */
SubType& flip(const element_type& key_value_pair)
- { return flip(value_type(interval_type(key_value_pair.key), key_value_pair.data)); }
+ {
+ return itl::flip(*that(), key_value_pair);
+ }
/** If \c *this map contains \c interval_value_pair it is erased, otherwise it is added. */
- SubType& flip(const segment_type& interval_value_pair);
+ SubType& flip(const segment_type& interval_value_pair)
+ {
+ return itl::flip(*that(), interval_value_pair);
+ }
/** The intersection of \c *this and \c operand is erased from \c *this.
The complemenary value pairs are added to \c *this. */
template<class SubType2>
- SubType& flip(const interval_base_map<SubType2,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand);
+ SubType& flip(const interval_base_map<SubType2,DomainT,CodomainT,Traits,
+ Compare,Combine,Section,Interval,Alloc>& operand)
+ {
+ return itl::flip(*that(), operand);
+ }
//==========================================================================
@@ -701,156 +710,6 @@
} ;
-
-//==============================================================================
-//= Symmetric difference
-//==============================================================================
-
-template
-<
- class SubType,
- class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc
->
-SubType& interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
- ::flip(const segment_type& interval_value_pair)
-{
- // That which is common shall be subtracted
- // That which is not shall be added
- // So x has to be 'complementary added' or flipped
-
- if(Traits::is_total && Traits::absorbs_neutrons)
- {
- clear();
- return *that();
- }
- if(Traits::is_total && !Traits::absorbs_neutrons)
- {
- (*that()) += interval_value_pair;
- ITL_FORALL(typename ImplMapT, it_, _map)
- it_->second = neutron<codomain_type>::value();
-
- if(mpl::not_<is_interval_splitter<SubType> >::value)
- join();
-
- return *that();
- }
-
- interval_type span = interval_value_pair.first;
-
- typename ImplMapT::const_iterator first_ = _map.lower_bound(span);
- typename ImplMapT::const_iterator end_ = _map.upper_bound(span);
-
- interval_type covered, left_over, common_interval;
- const codomain_type& x_value = interval_value_pair.second;
- typename ImplMapT::const_iterator it_ = first_;
-
- interval_set<DomainT,Compare,Interval,Alloc> eraser;
- interval_base_map intersection;
-
- while(it_ != end_ )
- {
- const codomain_type& co_value = it_->second;
- covered = (*it_++).first;
- //[a ... : span
- // [b ... : covered
- //[a b) : left_over
- left_over = right_subtract(span, covered);
-
- //That which is common ...
- common_interval = span & covered;
- if(!itl::is_empty(common_interval))
- {
- // ... shall be subtracted
- eraser.add(common_interval);
-
- if(has_set_semantics<codomain_type>::value)
- {
- codomain_type common_value = x_value;
- inverse_codomain_intersect()(common_value, co_value);
- intersection.add(value_type(common_interval, common_value));
- }
- else
- intersection.add(value_type(common_interval, neutron<codomain_type>::value()));
- }
-
- add(value_type(left_over, x_value)); //That which is not shall be added
- // Because this is a collision free addition I don't have to distinguish codomain_types.
-
- //... d) : span
- //... c) : covered
- // [c d) : span'
- span = left_subtract(span, covered);
- }
-
- //If span is not empty here, it is not in the set so it shall be added
- add(value_type(span, x_value));
-
- //finally rewrite the common segments
- erase(eraser);
- (*this) += intersection;
-
- return *that();
-}
-
-
-
-template
-<
- class SubType,
- class DomainT, class CodomainT, class Traits,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
- ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc
->
- template<class SubType2>
-SubType& interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
- ::flip(const interval_base_map<SubType2,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand)
-{
- typedef interval_base_map<SubType2,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
-
- if(Traits::is_total && Traits::absorbs_neutrons)
- {
- clear();
- return *that();
- }
- if(Traits::is_total && !Traits::absorbs_neutrons)
- {
- (*that()) += operand;
- ITL_FORALL(typename ImplMapT, it_, _map)
- it_->second = neutron<codomain_type>::value();
-
- if(mpl::not_<is_interval_splitter<SubType> >::value)
- join();
-
- return *that();
- }
-
- typename operand_type::const_iterator common_lwb;
- typename operand_type::const_iterator common_upb;
-
- if(!Set::common_range(common_lwb, common_upb, operand, *this))
- return *that() += operand;
-
- typename operand_type::const_iterator it_ = operand.begin();
-
- // All elements of operand left of the common range are added
- while(it_ != common_lwb)
- add(*it_++);
- // All elements of operand in the common range are symmetrically subtracted
- while(it_ != common_upb)
- flip(*it_++);
- // All elements of operand right of the common range are added
- while(it_ != operand.end())
- add(*it_++);
-
- if(Traits::is_total && !Traits::absorbs_neutrons)
- ITL_FORALL(typename ImplMapT, it_, _map)
- it_->second = neutron<codomain_type>::value();
-
- return *that();
-}
-
-
-
template
<
class SubType,
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 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -97,15 +97,15 @@
//------------------------------------------------------------------------------
template<class Type>
typename enable_if<is_interval_set<Type>, Type>::type&
-flip(Type&, const typename Type::domain_type&);
+flip(Type&, const typename Type::element_type&);
template<class Type>
typename enable_if<is_interval_set<Type>, Type>::type&
flip(Type&, const typename Type::segment_type&);
template<class Type, class OperandT>
-typename enable_if<has_same_concept<is_interval_set, Type, OperandT>, Type>::type&
-JODO_flip(Type&, const OperandT&);
+typename enable_if<is_concept_compatible<is_interval_set, Type, OperandT>, Type>::type&
+flip(Type&, const OperandT&);
//------------------------------------------------------------------------------
template<class Type>
@@ -496,7 +496,7 @@
template<class SubType2>
SubType& flip(const interval_base_set<SubType2,DomainT,Compare,Interval,Alloc>& operand)
{
- return itl::JODO_flip(*that(), operand); //JODO remove this
+ return itl::flip(*that(), operand); //JODO remove this
}
//==========================================================================
Modified: sandbox/itl/libs/itl/test/test_interval_map_mixed.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map_mixed.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map_mixed.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -1435,11 +1435,11 @@
IntervalMapT join_A(split_A), join_B(split_B);
- BOOST_CHECK_EQUAL( is_disjoint(split_A, split_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(split_A, join_B), true );
+ BOOST_CHECK_EQUAL( disjoint(split_A, split_B), true );
+ BOOST_CHECK_EQUAL( disjoint(split_A, join_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(join_A, split_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(join_A, join_B), true );
+ BOOST_CHECK_EQUAL( disjoint(join_A, split_B), true );
+ BOOST_CHECK_EQUAL( disjoint(join_A, join_B), true );
}
template<class Type>
Modified: sandbox/itl/libs/itl/test/test_interval_map_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map_shared.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -530,7 +530,7 @@
IntervalMapT left, left2, right, all, section, complement;
left.add(I0_1I_u1).add(I3_5I_u1);
(right += I3_5I_u1) += I7_8I_u1;
- BOOST_CHECK_EQUAL( is_disjoint(left, right), false );
+ BOOST_CHECK_EQUAL( disjoint(left, right), false );
BOOST_CHECK_EQUAL( intersects(left, right), true );
(all += left) += right;
@@ -539,7 +539,7 @@
complement += all;
//complement.erase(I3_5I);
complement.erase(section);
- BOOST_CHECK_EQUAL( is_disjoint(section, complement), true );
+ BOOST_CHECK_EQUAL( disjoint(section, complement), true );
BOOST_CHECK_EQUAL( intersects(section, complement), false );
}
@@ -820,17 +820,17 @@
map_A.add(I1_3D_1).add(I6_8D_1);
map_B.add(I0_1D_1).add(I3_6D_1).add(I8_9D_1);
- BOOST_CHECK_EQUAL( is_disjoint(map_A, map_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(map_B, map_A), true );
+ BOOST_CHECK_EQUAL( disjoint(map_A, map_B), true );
+ BOOST_CHECK_EQUAL( disjoint(map_B, map_A), true );
BOOST_CHECK_EQUAL( intersects(map_A, map_B), false );
BOOST_CHECK_EQUAL( intersects(map_B, map_A), false );
map_A.domain(set_A);
map_B.domain(set_B);
- BOOST_CHECK_EQUAL( is_disjoint(map_A, set_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(set_B, map_A), true );
- BOOST_CHECK_EQUAL( is_disjoint(set_A, map_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(map_B, set_A), true );
+ BOOST_CHECK_EQUAL( disjoint(map_A, set_B), true );
+ BOOST_CHECK_EQUAL( disjoint(set_B, map_A), true );
+ BOOST_CHECK_EQUAL( disjoint(set_A, map_B), true );
+ BOOST_CHECK_EQUAL( disjoint(map_B, set_A), true );
BOOST_CHECK_EQUAL( intersects(map_A, set_B), false );
BOOST_CHECK_EQUAL( intersects(set_B, map_A), false );
BOOST_CHECK_EQUAL( intersects(set_A, map_B), false );
@@ -838,17 +838,17 @@
map_A += I5_7D_1;
- BOOST_CHECK_EQUAL( is_disjoint(map_A, map_B), false );
- BOOST_CHECK_EQUAL( is_disjoint(map_B, map_A), false );
+ BOOST_CHECK_EQUAL( disjoint(map_A, map_B), false );
+ BOOST_CHECK_EQUAL( disjoint(map_B, map_A), false );
BOOST_CHECK_EQUAL( intersects(map_A, map_B), true );
BOOST_CHECK_EQUAL( intersects(map_B, map_A), true );
map_A.domain(set_A);
map_B.domain(set_B);
- BOOST_CHECK_EQUAL( is_disjoint(map_A, set_B), false );
- BOOST_CHECK_EQUAL( is_disjoint(set_B, map_A), false );
- BOOST_CHECK_EQUAL( is_disjoint(set_A, map_B), false );
- BOOST_CHECK_EQUAL( is_disjoint(map_B, set_A), false );
+ BOOST_CHECK_EQUAL( disjoint(map_A, set_B), false );
+ BOOST_CHECK_EQUAL( disjoint(set_B, map_A), false );
+ BOOST_CHECK_EQUAL( disjoint(set_A, map_B), false );
+ BOOST_CHECK_EQUAL( disjoint(map_B, set_A), false );
BOOST_CHECK_EQUAL( intersects(map_A, set_B), true );
BOOST_CHECK_EQUAL( intersects(set_B, map_A), true );
BOOST_CHECK_EQUAL( intersects(set_A, map_B), true );
Modified: sandbox/itl/libs/itl/test/test_interval_quantifier_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_quantifier_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_quantifier_shared.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -82,7 +82,7 @@
make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
CHECK_MONOID_INSTANCE_WRT(et) (map_a, map_b, map_c, val_pair, map_pair);
- CHECK_MONOID_INSTANCE_WRT(caret)(map_a, map_b, map_c, val_pair, map_pair);
+ //JODO so. CHECK_MONOID_INSTANCE_WRT(caret)(map_a, map_b, map_c, val_pair, map_pair);
}
//------------------------------------------------------------------------------
@@ -131,7 +131,7 @@
make_3_itv_maps_and_derivatives_1(map_a, map_b, map_c, val_pair, map_pair);
CHECK_ABELIAN_MONOID_INSTANCE_WRT(et) (map_a, map_b, map_c, val_pair, map_pair);
- CHECK_ABELIAN_MONOID_INSTANCE_WRT(caret)(map_a, map_b, map_c, val_pair, map_pair);
+ //JODO CHECK_ABELIAN_MONOID_INSTANCE_WRT(caret)(map_a, map_b, map_c, val_pair, map_pair); //valid 4 set codom only
}
Modified: sandbox/itl/libs/itl/test/test_interval_set_mixed.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_set_mixed.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_set_mixed.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -765,17 +765,17 @@
separate_interval_set<T> sep_A(split_A), sep_B(split_B);
interval_set<T> join_A(split_A), join_B(split_B);
- BOOST_CHECK_EQUAL( is_disjoint(split_A, split_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(split_A, sep_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(split_A, join_B), true );
-
- BOOST_CHECK_EQUAL( is_disjoint(sep_A, split_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(sep_A, sep_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(sep_A, join_B), true );
-
- BOOST_CHECK_EQUAL( is_disjoint(join_A, split_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(join_A, sep_B), true );
- BOOST_CHECK_EQUAL( is_disjoint(join_A, join_B), true );
+ BOOST_CHECK_EQUAL( disjoint(split_A, split_B), true );
+ BOOST_CHECK_EQUAL( disjoint(split_A, sep_B), true );
+ BOOST_CHECK_EQUAL( disjoint(split_A, join_B), true );
+
+ BOOST_CHECK_EQUAL( disjoint(sep_A, split_B), true );
+ BOOST_CHECK_EQUAL( disjoint(sep_A, sep_B), true );
+ BOOST_CHECK_EQUAL( disjoint(sep_A, join_B), true );
+
+ BOOST_CHECK_EQUAL( disjoint(join_A, split_B), true );
+ BOOST_CHECK_EQUAL( disjoint(join_A, sep_B), true );
+ BOOST_CHECK_EQUAL( disjoint(join_A, join_B), true );
}
template <class T>
Modified: sandbox/itl/libs/itl/test/test_interval_set_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_set_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_set_shared.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -465,14 +465,14 @@
left.add(IntervalT::closed(v0,v1)).add(IntervalT::closed(v3,v5));
(right += IntervalT::closed(v3,v5)) += IntervalT::closed(v7,v8);
- BOOST_CHECK_EQUAL( is_disjoint(left, right), false );
+ BOOST_CHECK_EQUAL( disjoint(left, right), false );
(all += left) += right;
(section += left) &= right;
(complement += all) -= section;
(all2 += section) += complement;
- BOOST_CHECK_EQUAL( is_disjoint(section, complement), true );
+ BOOST_CHECK_EQUAL( disjoint(section, complement), true );
BOOST_CHECK_EQUAL( all, all2 );
BOOST_CHECK_EQUAL( call::contains(all, left), true );
Modified: sandbox/itl/libs/itl/test/test_laws.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_laws.hpp (original)
+++ sandbox/itl/libs/itl/test/test_laws.hpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -62,8 +62,8 @@
DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(pipe, | );
DEFINE_ASSOCIATIVITY_CHECK_WRT (et, & );
DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(et, & );
-DEFINE_ASSOCIATIVITY_CHECK_WRT (caret, ^ );
-DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(caret, ^ );
+DEFINE_ASSOCIATIVITY_CHECK_WRT (caret, ^ ); //JODO only, if codomain_type has set semantics
+DEFINE_ASSOCIATIVITY_CHECK_WRT_EQUAL(caret, ^ ); //JODO
//------------------------------------------------------------------------------
Modified: sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp
==============================================================================
--- sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp (original)
+++ sandbox/itl/libs/validate/example/labat_single_/labat_single.cpp 2010-09-10 18:28:18 EDT (Fri, 10 Sep 2010)
@@ -83,8 +83,9 @@
//>
//TestLawT;
+ //typedef Antisymmetry<itl::map<int,int>, itl::sub_super_set, itl::element_equal> TestLawT;
- typedef Antisymmetry<itl::map<int,int>, itl::sub_super_set, itl::element_equal> TestLawT;
+ typedef InplaceAssociativity<itl::interval_map<int,itl::set<int> >, itl::inplace_caret, itl::element_equal> TestLawT;
LawValidater<TestLawT> test_law;
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