Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65164 - in sandbox/itl: boost/itl boost/itl/detail boost/itl/functions boost/itl/type_traits libs/itl/test/test_casual_
From: afojgo_at_[hidden]
Date: 2010-09-01 05:01:51


Author: jofaber
Date: 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
New Revision: 65164
URL: http://svn.boost.org/trac/boost/changeset/65164

Log:
Refactoring. Unifying interval_sets. Extracted joining, separating and splitting addition as namespace global functions. Stable{msvc-9.0, gcc-3.4.4}
Added:
   sandbox/itl/boost/itl/functions/
   sandbox/itl/boost/itl/functions/associative_container.hpp (contents, props changed)
   sandbox/itl/boost/itl/functions/associative_element_container.hpp (contents, props changed)
   sandbox/itl/boost/itl/functions/container.hpp (contents, props changed)
   sandbox/itl/boost/itl/functions/icl_container.hpp (contents, props changed)
   sandbox/itl/boost/itl/set_functions.hpp (contents, props changed)
   sandbox/itl/boost/itl/type_traits/is_assoc_element_container.hpp (contents, props changed)
   sandbox/itl/boost/itl/type_traits/is_associative_element_container.hpp (contents, props changed)
   sandbox/itl/boost/itl/type_traits/is_icl_container.hpp (contents, props changed)
Text files modified:
   sandbox/itl/boost/itl/detail/associated_value.hpp | 22
   sandbox/itl/boost/itl/detail/interval_set_algo.hpp | 388 ++++++++++++++++++++++++
   sandbox/itl/boost/itl/detail/map_functors.hpp | 37 +
   sandbox/itl/boost/itl/functions.hpp | 22 -
   sandbox/itl/boost/itl/interval_base_map.hpp | 1
   sandbox/itl/boost/itl/interval_base_set.hpp | 10
   sandbox/itl/boost/itl/interval_set.hpp | 153 ---------
   sandbox/itl/boost/itl/map.hpp | 11
   sandbox/itl/boost/itl/map_functions.hpp | 256 ---------------
   sandbox/itl/boost/itl/separate_interval_set.hpp | 70 ----
   sandbox/itl/boost/itl/set.hpp | 625 ++-------------------------------------
   sandbox/itl/boost/itl/split_interval_set.hpp | 171 ----------
   sandbox/itl/boost/itl/type_traits/is_element_container.hpp | 25 +
   sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp | 2
   14 files changed, 520 insertions(+), 1273 deletions(-)

Modified: sandbox/itl/boost/itl/detail/associated_value.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/associated_value.hpp (original)
+++ sandbox/itl/boost/itl/detail/associated_value.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -16,22 +16,22 @@
 namespace boost{namespace itl
 {
 
-template<class ObjectT, class CoObjectT> //JODO Only maps of equal iterability shall match!
-typename enable_if< mpl::and_< is_domain_compare_equal<ObjectT,CoObjectT>
- , mpl::and_<is_map<ObjectT>, is_map<CoObjectT> > >,
+template<class Type, class CoType> //JODO Only maps of equal iterability shall match!
+typename enable_if< mpl::and_< is_domain_compare_equal<Type,CoType>
+ , mpl::and_<is_map<Type>, is_map<CoType> > >,
                     bool>::type
-co_equal(typename ObjectT::const_iterator left_, typename CoObjectT::const_iterator right_,
- const ObjectT& left, const CoObjectT& right)
+co_equal(typename Type::const_iterator left_, typename CoType::const_iterator right_,
+ const Type&, const CoType&)
 {
- return ObjectT::co_value(left_) == CoObjectT::co_value(right_);
+ return Type::co_value(left_) == CoType::co_value(right_);
 }
 
-template<class ObjectT, class CoObjectT>
-typename enable_if< mpl::and_< is_domain_compare_equal<ObjectT,CoObjectT>
- , mpl::not_<mpl::and_<is_map<ObjectT>, is_map<CoObjectT> > > >,
+template<class Type, class CoType>
+typename enable_if< mpl::and_< is_domain_compare_equal<Type,CoType>
+ , mpl::not_<mpl::and_<is_map<Type>, is_map<CoType> > > >,
                   bool>::type
-co_equal(typename ObjectT::const_iterator, typename CoObjectT::const_iterator,
- const ObjectT&, const CoObjectT&)
+co_equal(typename Type::const_iterator, typename CoType::const_iterator,
+ const Type&, const CoType&)
 {
         return true;
 }

Modified: sandbox/itl/boost/itl/detail/interval_set_algo.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/interval_set_algo.hpp (original)
+++ sandbox/itl/boost/itl/detail/interval_set_algo.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -290,7 +290,395 @@
 }
 
 } // namespace Interval_Set
+
+namespace detail
+{
+
+template<class Type>
+typename Type::iterator
+ join_on_left(Type& object, typename Type::iterator& left_,
+ typename Type::iterator& right_)
+{
+ typedef typename Type::value_type value_type;
+ typedef typename Type::interval_type interval_type;
+ // both left and right are in the set and they are neighbours
+ BOOST_ASSERT(exclusive_less(Type::key_value(left_), Type::key_value(right_)));
+ BOOST_ASSERT(touches(Type::key_value(left_), Type::key_value(right_)));
+
+ interval_type right_itv = Type::key_value(right_);
+ object.erase(right_);
+ const_cast<value_type&>(Type::key_value(left_))
+ = hull(Type::key_value(left_), right_itv);
+
+ return left_;
+}
+
+template<class Type>
+typename Type::iterator
+ join_neighbours(Type& object, typename Type::iterator it_)
+{
+ using namespace detail;
+ typedef typename Type::iterator iterator;
+
+ if(it_ == object.begin())
+ {
+ iterator it_nxt=it_; it_nxt++;
+ if(it_nxt!=object.end() && touches(Type::key_value(it_),
+ Type::key_value(it_nxt)))
+ return join_on_left(object, it_, it_nxt);
+ }
+ else
+ {
+ // there is a predecessor
+ iterator pred_ = it_; pred_-- ;
+
+ if(touches(Type::key_value(pred_), Type::key_value(it_)))
+ {
+ iterator it_extended = join_on_left(object, pred_, it_);
+
+ iterator succ_=it_extended; succ_++;
+ if(succ_!=object.end())
+ {
+ // it's a non border element that might have two touching neighbours
+ if(touches(Type::key_value(it_extended), Type::key_value(succ_)))
+ return join_on_left(object, it_extended, succ_);
+ else
+ return it_extended;
+ }
+ else
+ return it_extended;
+ }
+ else
+ {
+ iterator succ_=it_; succ_++;
+ if(succ_!=object.end())
+ {
+ // it's a non border element that might have a right touching neighbour
+ if(touches(Type::key_value(it_), Type::key_value(succ_)))
+ return join_on_left(object, it_, succ_);
+ }
+ }
+ }
+
+ return it_;
+}
+
+
+template<class Type>
+typename Type::iterator
+ join_under(Type& object, const typename Type::value_type& addend)
+{
+ //ASSERT: There is at least one interval in object that overlaps with addend
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+
+ std::pair<iterator,iterator> overlap = object.equal_range(addend);
+ iterator first_ = overlap.first,
+ end_ = overlap.second,
+ last_ = end_; --last_;
+
+ iterator second_= first_; ++second_;
+
+ interval_type left_resid = right_subtract(Type::key_value(first_), addend);
+ interval_type right_resid = left_subtract(Type::key_value(last_) , addend);
+
+ object.erase(second_, end_);
+
+ const_cast<value_type&>(Type::key_value(first_))
+ = hull(hull(left_resid, addend), right_resid);
+ return first_;
+}
+
+//==============================================================================
+//= Addition joining
+//==============================================================================
+template<class Type>
+typename Type::iterator
+ joining_add(Type& object, const typename Type::value_type& addend)
+{
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+
+ if(itl::is_empty(addend))
+ return object.end();
+
+ std::pair<iterator,bool> insertion = object._insert(addend);
+
+ if(insertion.second)
+ return join_neighbours(object, insertion.first);
+ else
+ return join_neighbours(object, join_under(object, addend));
+}
+
+template<class Type>
+typename Type::iterator
+ joining_add(Type& object, typename Type::iterator prior_,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+
+ if(itl::is_empty(addend))
+ return prior_;
+
+ iterator insertion = object._insert(prior_, addend);
+
+ if(*insertion == addend)
+ return join_neighbours(object, insertion);
+ else
+ return join_neighbours(object, join_under(object, addend));
+}
+
+
+//==============================================================================
+//= Addition separating
+//==============================================================================
+template<class Type>
+typename Type::iterator
+ separating_add(Type& object, const typename Type::value_type& addend)
+{
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+
+ if(itl::is_empty(addend))
+ return object.end();
+
+ std::pair<iterator,bool> insertion = object._insert(addend);
+
+ if(insertion.second)
+ return insertion.first;
+ else
+ return join_under(object, addend);
+}
+
+template<class Type>
+typename Type::iterator
+ separating_add(Type& object, typename Type::iterator prior_,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+
+ if(itl::is_empty(addend))
+ return prior_;
+
+ iterator insertion = object._insert(prior_, addend);
+
+ if(*insertion == addend)
+ return insertion;
+ else
+ return join_under(object, addend);
+}
+
+
+//==============================================================================
+//= Addition splitting
+//==============================================================================
+
+template<class Type>
+void add_front(Type& object, const typename Type::interval_type& inter_val,
+ typename Type::iterator& first_)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::iterator iterator;
+ // If the collision sequence has a left residual 'left_resid' it will
+ // be split, to provide a standardized start of algorithms:
+ // The addend interval 'inter_val' covers the beginning of the collision sequence.
+
+ // only for the first there can be a left_resid: a part of *first_ left of inter_val
+ interval_type left_resid = right_subtract(*first_, inter_val);
+
+ if(!itl::is_empty(left_resid))
+ { // [------------ . . .
+ // [left_resid---first_ --- . . .
+ iterator prior_ = object.prior(first_);
+ const_cast<interval_type&>(*first_) = left_subtract(*first_, left_resid);
+ //NOTE: Only splitting
+ iterator insertion_ = object._insert(prior_, left_resid);
+ }
+
+ //POST:
+ // [----- inter_val ---- . . .
+ // ...[-- first_ --...
+}
+
+
+template<class Type>
+void add_segment(Type& object, const typename Type::interval_type& inter_val,
+ typename Type::iterator& it_ )
+{
+ typedef typename Type::interval_type interval_type;
+ interval_type lead_gap = right_subtract(inter_val, *it_);
+ if(!itl::is_empty(lead_gap))
+ // [lead_gap--- . . .
+ // [prior_) [-- it_ ...
+ object._insert(prior(it_), lead_gap);
+
+ // . . . --------- . . . addend interval
+ // [-- it_ --) has a common part with the first overval
+ ++it_;
+}
+
+
+template<class Type>
+void add_main(Type& object, typename Type::interval_type& rest_interval,
+ typename Type::iterator& it_,
+ const typename Type::iterator& last_)
+{
+ typedef typename Type::interval_type interval_type;
+ interval_type cur_interval;
+ while(it_ != last_)
+ {
+ cur_interval = *it_ ;
+ add_segment(object, rest_interval, it_);
+ // shrink interval
+ rest_interval = left_subtract(rest_interval, cur_interval);
+ }
+}
+
+
+template<class Type>
+void add_rear(Type& object, const typename Type::interval_type& inter_val,
+ typename Type::iterator& it_ )
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::iterator iterator;
+
+ iterator prior_ = object.prior(it_);
+ interval_type cur_itv = *it_;
+
+ interval_type lead_gap = right_subtract(inter_val, cur_itv);
+ if(!itl::is_empty(lead_gap))
+ // [lead_gap--- . . .
+ // [prior_) [-- it_ ...
+ object._insert(prior_, lead_gap);
     
+ interval_type end_gap = left_subtract(inter_val, cur_itv);
+ if(!itl::is_empty(end_gap))
+ // [---------------end_gap)
+ // [-- it_ --)
+ it_ = object._insert(it_, end_gap);
+ else
+ {
+ // only for the last there can be a right_resid: a part of *it_ right of addend
+ interval_type right_resid = left_subtract(cur_itv, inter_val);
+
+ if(!itl::is_empty(right_resid))
+ {
+ // [--------------)
+ // [-- it_ --right_resid)
+ const_cast<interval_type&>(*it_) = right_subtract(*it_, right_resid);
+ it_ = object._insert(it_, right_resid);
+ }
+ }
+}
+
+
+template<class Type>
+typename Type::iterator
+ splitting_add(Type& object, const typename Type::value_type& addend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::iterator iterator;
+
+ if(itl::is_empty(addend))
+ return object.end();
+
+ std::pair<iterator,bool> insertion = object._insert(addend);
+
+ if(insertion.second)
+ return insertion.first;
+ {
+ iterator first_ = object.lower_bound(addend),
+ last_ = insertion.first;
+ //BOOST_ASSERT(next(last_) == this->_set.upper_bound(inter_val));
+
+ iterator it_ = first_;
+ interval_type rest_interval = addend;
+
+ add_front(object, rest_interval, it_);
+ add_main (object, rest_interval, it_, last_);
+ add_rear (object, rest_interval, it_);
+ return it_;
+ }
+}
+
+
+template<class Type>
+typename Type::iterator
+ splitting_add(Type& object, typename Type::iterator prior_,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::iterator iterator;
+
+ if(itl::is_empty(addend))
+ return prior_;
+
+ iterator insertion = object._insert(prior_, addend);
+
+ if(*insertion == addend)
+ return insertion;
+ {
+ std::pair<iterator,iterator> overlap = object.equal_range(addend);
+ iterator first_ = overlap.first,
+ end_ = overlap.second,
+ last_ = end_; --last_;
+
+ iterator it_ = first_;
+ interval_type rest_interval = addend;
+
+ add_front(object, rest_interval, it_);
+ add_main (object, rest_interval, it_, last_);
+ add_rear (object, rest_interval, it_);
+
+ return it_;
+ }
+}
+
+
+//==============================================================================
+//= Subtraction
+//==============================================================================
+template<class Type>
+void subtract(Type& object, const typename Type::value_type& minuend)
+{
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+
+ if(itl::is_empty(minuend)) return;
+
+ std::pair<iterator, iterator> exterior = object.equal_range(minuend);
+ if(exterior.first == exterior.second) return;
+
+ iterator first_ = exterior.first;
+ iterator end_ = exterior.second;
+ iterator last_ = end_; --last_;
+
+ interval_type leftResid = right_subtract(*first_, minuend);
+ interval_type rightResid;
+ if(first_ != end_ )
+ rightResid = left_subtract(*last_ , minuend);
+
+ object.erase(first_, end_);
+
+ if(!itl::is_empty(leftResid))
+ object._insert(leftResid);
+
+ if(!itl::is_empty(rightResid))
+ object._insert(rightResid);
+}
+
+
+
+} // namespace detail
+
 }} // namespace itl boost
 
 #endif

Modified: sandbox/itl/boost/itl/detail/map_functors.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/map_functors.hpp (original)
+++ sandbox/itl/boost/itl/detail/map_functors.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -10,18 +10,34 @@
 
 #include <boost/itl/detail/design_config.hpp>
 #include <boost/itl/detail/associated_value.hpp>
+#include <boost/itl/type_traits/is_container.hpp>
 #include <boost/itl/type_traits/adds_inversely.hpp>
+#include <boost/itl/type_traits/absorbs_neutrons.hpp>
 #include <boost/itl/functors.hpp>
-#include <boost/itl/map_functions.hpp>
+//CL #include <boost/itl/map_functions.hpp>
 
 namespace boost{namespace itl
 {
 
+//------------------------------------------------------------------------------
+//JODO The forward declarations are needed by gcc-3.4.4 here
+template<class Type>
+typename enable_if<is_container<Type>, void>::type
+clear(Type&);
+
+template <class MapT>
+typename enable_if<is_element_map<MapT>, MapT>::type&
+add(MapT&, const typename MapT::value_type&);
+
+template<class MapT>
+typename enable_if<is_element_map<MapT>,
+ std::pair<typename MapT::iterator,bool> >::type
+insert(MapT&, const typename MapT::element_type&);
+
 template<class MapT, class Predicate>
-inline typename enable_if<is_element_map<MapT>, MapT>::type&
-erase_if(const Predicate& pred, MapT& object);//JODO gcc-3.4.4 does not recognize some functions from map_functions.hpp
- //JODO e.g. erase_if and subtract. Forward decl should not be necessary
- //JODO but may be it is better to use forward decls only instead of inlclues here.
+typename enable_if<is_element_map<MapT>, MapT>::type&
+erase_if(const Predicate&, MapT&);
+//------------------------------------------------------------------------------
 
 template<class MapT, class Combiner, bool creates_inverse>
 struct element_version
@@ -643,27 +659,24 @@
 template<class MapT, bool absorbs_neutrons>
 struct map_absorb_neutrons
 {
- typedef MapT map_type;
- static void apply(map_type&);
+ static MapT& apply(MapT&);
 };
 
 template<class MapT>
 struct map_absorb_neutrons<MapT, false>
 { // !absorbs_neutrons
- typedef MapT map_type;
- static void absorb_neutrons(map_type&){}
+ static MapT& apply(MapT& object){ return object; }
 };
 
 
 template<class MapT>
 struct map_absorb_neutrons<MapT, true>
 { // absorbs_neutrons
- typedef MapT map_type;
         typedef typename MapT::element_type element_type;
 
- static void absorb_neutrons(map_type& object)
+ static MapT& apply(MapT& object)
     {
- itl::erase_if(content_is_neutron<element_type>(), object);
+ return itl::erase_if(content_is_neutron<element_type>(), object);
     }
 };
 

Modified: sandbox/itl/boost/itl/functions.hpp
==============================================================================
--- sandbox/itl/boost/itl/functions.hpp (original)
+++ sandbox/itl/boost/itl/functions.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -17,6 +17,8 @@
 #include <boost/itl/detail/interval_map_functors.hpp>
 #include <boost/itl/detail/interval_map_algo.hpp>
 
+#include <boost/itl/functions/container.hpp>
+
 namespace boost{namespace itl
 {
 
@@ -24,24 +26,6 @@
 //= Containedness
 //==========================================================================
 
-/** All content of the container is dropped.
- Complexity: linear. */
-template<class ObjectT>
-typename enable_if<is_interval_container<ObjectT>, void>::type
-clear(ObjectT& object) //JODO test
-{
- object.erase(object.begin(), object.end());
-}
-
-/** Tests if the container is empty.
- Complexity: constant. */
-template<class ObjectT>
-typename enable_if<is_interval_container<ObjectT>, bool>::type
-is_empty(const ObjectT& object)
-{
- return object.begin() == object.end();
-}
-
 
 //------------------------------------------------------------------------------
 //- contains
@@ -110,7 +94,7 @@
 typename enable_if<is_interval_container<SuperT>, bool>::type
 within(const SubT& sub, const SuperT& super)
 {
- return contains(super, sub);
+ return itl::contains(super, sub);
 }
 
 

Added: sandbox/itl/boost/itl/functions/associative_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/functions/associative_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,45 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_FUNCTIONS_ASSOCIATIVE_CONTAINER_HPP_JOFA_100830
+#define BOOST_ITL_FUNCTIONS_ASSOCIATIVE_CONTAINER_HPP_JOFA_100830
+
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_container.hpp>
+
+namespace boost{namespace itl
+{
+
+//==============================================================================
+//= Emptieness
+//==============================================================================
+
+/** Tests if the container is empty.
+ Complexity: constant. */
+template<class Type>
+typename enable_if<is_container<Type>, bool>::type
+is_empty(const Type& object)
+{
+ return object.begin()==object.end();
+}
+
+
+/** All content of the container is dropped.
+ Complexity: linear. */
+template<class Type>
+typename enable_if<is_container<Type>, void>::type
+clear(Type& object)
+{
+ object.erase(object.begin(), object.end());
+}
+
+}} // namespace itl boost
+
+
+#endif
+
+

Added: sandbox/itl/boost/itl/functions/associative_element_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/functions/associative_element_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,214 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_FUNCTIONS_ASSOCIATIVE_ELEMENT_CONTAINER_HPP_JOFA_100831
+#define BOOST_ITL_FUNCTIONS_ASSOCIATIVE_ELEMENT_CONTAINER_HPP_JOFA_100831
+
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_key_container_of.hpp>
+#include <boost/itl/type_traits/is_concept_equivalent.hpp>
+#include <boost/itl/type_traits/is_container.hpp>
+#include <boost/itl/type_traits/is_associative_element_container.hpp>
+
+namespace boost{namespace itl
+{
+
+//JODO Declaration forwarding for gcc-3.4.4
+template <class SetT>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+add(SetT& object, const typename SetT::element_type& operand);
+
+
+//==============================================================================
+//= Containedness
+//==============================================================================
+
+//------------------------------------------------------------------------------
+// within
+//------------------------------------------------------------------------------
+/** Checks if a key is in the associative container */
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, bool>::type
+within(const typename Type::domain_type& key, const Type& super)
+{
+ return !(super.find(key) == super.end());
+}
+
+template<class SubT, class SuperT>
+typename enable_if<mpl::and_< is_associative_element_container<SuperT>
+ , is_key_container_of<SubT, SuperT> >,
+ bool>::type
+within(const SubT& sub, const SuperT& super)
+{
+ if(itl::is_empty(sub)) return true;
+ if(itl::is_empty(super)) return false;
+ if(itl::size(super) < itl::size(sub)) return false;
+
+ typename SubT::const_iterator common_lwb_;
+ typename SubT::const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, sub, super))
+ return false;
+
+ typename SubT::const_iterator sub_ = sub.begin();
+ typename SuperT::const_iterator super_;
+ while(sub_ != sub.end())
+ {
+ super_ = super.find(SubT::key_value(sub_));
+ if(super_ == super.end())
+ return false;
+ else if(!co_equal(sub_, super_, sub, super))
+ return false;
+
+ ++sub_;
+ }
+ return true;
+}
+
+
+//------------------------------------------------------------------------------
+// contains
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, bool>::type
+contains(const Type& super, const typename Type::domain_type& key)
+{
+ return itl::within(key, super);
+}
+
+template<class SubT, class SuperT>
+typename enable_if<mpl::and_< is_associative_element_container<SuperT>
+ , is_key_container_of<SubT, SuperT> >,
+ bool>::type
+contains(const SuperT& super, const SubT& sub)
+{
+ return itl::within(sub, super);
+}
+
+
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4996) //'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
+#endif // I do guarantee here that I am using the parameters correctly :)
+
+/** Standard equality, which is lexicographical equality of the sets
+ as sequences, that are given by their Compare order. */
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+operator == (const Type& left, const Type& right)
+{
+ return left.size() == right.size()
+ && std::equal(left.begin(), left.end(), right.begin());
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+is_element_equal(const Type& left, const Type& right)
+{ return left == right; }
+
+
+/* Strict weak less ordering which is given by the Compare order */
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+operator < (const Type& left, const Type& right)
+{
+ return std::lexicographical_compare(
+ left.begin(), left.end(), right.begin(), right.end(),
+ typename Type::element_compare()
+ );
+}
+
+
+//==============================================================================
+//= Addition
+//==============================================================================
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator += (Type& object, const typename Type::element_type& operand)
+{
+ return itl::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator + (Type object, const typename Type::element_type& operand)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator + (const typename Type::element_type& operand, Type object)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator += (Type& object, const Type& operand)
+{
+ return Set::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator + (Type object, const Type& operand)
+{
+ return object += operand;
+}
+
+//==============================================================================
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator |= (Type& object, const typename Type::element_type& operand)
+{
+ return itl::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator | (Type object, const typename Type::element_type& operand)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator | (const typename Type::element_type& operand, Type object)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator |= (Type& object, const Type& operand)
+{
+ return Set::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator | (Type object, const Type& operand)
+{
+ return object += operand;
+}
+
+
+
+}} // namespace itl boost
+
+
+#endif
+
+

Added: sandbox/itl/boost/itl/functions/container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/functions/container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,72 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_FUNCTIONS_CONTAINER_HPP_JOFA_100828
+#define BOOST_ITL_FUNCTIONS_CONTAINER_HPP_JOFA_100828
+
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_container.hpp>
+
+namespace boost{namespace itl
+{
+
+//==============================================================================
+//= Emptieness
+//==============================================================================
+
+/** Tests if the container is empty.
+ Complexity: constant. */
+template<class Type>
+typename enable_if<is_container<Type>, bool>::type
+is_empty(const Type& object)
+{
+ return object.begin()==object.end();
+}
+
+
+/** All content of the container is dropped.
+ Complexity: linear. */
+template<class Type>
+typename enable_if<is_container<Type>, void>::type
+clear(Type& object)
+{
+ object.erase(object.begin(), object.end());
+}
+
+//==============================================================================
+//= Size
+//==============================================================================
+template<class Type>
+typename enable_if<is_container<Type>, typename Type::size_type>::type
+size(const Type& object)
+{
+ return object.size();
+}
+
+template<class Type>
+typename enable_if<is_container<Type>, typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ return object.size();
+}
+
+template<class Type>
+typename enable_if<is_container<Type>, typename Type::size_type>::type
+iterative_size(const Type& object)
+{
+ return object.size();
+}
+
+
+
+
+}} // namespace itl boost
+
+
+#endif
+
+

Added: sandbox/itl/boost/itl/functions/icl_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/functions/icl_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,48 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_FUNCTIONS_ICL_CONTAINER_HPP_JOFA_100831
+#define BOOST_ITL_FUNCTIONS_ICL_CONTAINER_HPP_JOFA_100831
+
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_icl_container.hpp>
+
+namespace boost{namespace itl
+{
+
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+
+template<class Type>
+inline typename enable_if<is_icl_container<Type>, bool>::type
+operator != (const Type& left, const Type& right)
+{ return !(left == right); }
+
+template<class Type>
+inline typename enable_if<is_icl_container<Type>, bool>::type
+operator > (const Type& left, const Type& right)
+{ return right < left; }
+
+/** Partial ordering which is induced by Compare */
+template<class Type>
+inline typename enable_if<is_icl_container<Type>, bool>::type
+operator <= (const Type& left, const Type& right)
+{ return !(left > right); }
+
+template<class Type>
+inline typename enable_if<is_icl_container<Type>, bool>::type
+operator >= (const Type& left, const Type& right)
+{ return !(left < right); }
+
+
+}} // namespace itl boost
+
+
+#endif
+
+

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-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -17,6 +17,7 @@
 
 #include <boost/itl/detail/notate.hpp>
 #include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_interval_splitter.hpp>
 #include <boost/itl/map.hpp>
 #include <boost/itl/interval_base_set.hpp>
 #include <boost/itl/detail/interval_map_algo.hpp>

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-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -164,13 +164,11 @@
     //= Containedness
     //==========================================================================
 
-ITL_BEGIN_COMMON_MEMBER_FUNCTIONS:
     /** sets the container empty */
     void clear() { _set.clear(); }
     /** is the container empty? */
     bool empty()const { return _set.empty(); }
 
-ITL_END_COMMON_MEMBER_FUNCTIONS:
     /** Does the container contain the element \c key ? */
     bool contains(const element_type& key)const
     { return that()->contains(interval_type(key)); }
@@ -305,6 +303,10 @@
     //= Insertion, erasure
     //==========================================================================
 
+ std::pair<iterator,bool> _insert(const value_type& value){ return this->_set.insert(value); }
+ iterator _insert(iterator prior, const value_type& value){ return this->_set.insert(prior, value); }
+
+
     /** Insert an element \c key into the set */
     SubType& insert(const element_type& key)
     { return add(interval_type(key)); }
@@ -475,10 +477,12 @@
 public:
     sub_type& self() { return *that(); }
 
-protected:
+public:
     iterator prior(iterator it_)
     { return it_ == this->_set.begin() ? this->_set.end() : --it_; }
 
+protected:
+
     const_iterator prior(const_iterator it_)const
     { return it_ == this->_set.begin() ? this->_set.end() : --it_; }
 

Modified: sandbox/itl/boost/itl/interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_set.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -136,6 +136,9 @@
             prior_ = this->add(prior_, *it_);
     }
 
+ //std::pair<iterator,bool> _insert(const value_type& value){ return this->_set.insert(value); }
+ //iterator _insert(iterator prior, const value_type& value){ return this->_set.insert(prior, value); }
+
 private:
     friend class
         interval_base_set<interval_set<DomainT,Compare,Interval,Alloc>,
@@ -152,173 +155,33 @@
     /// Removal of an interval <tt>minuend</tt>
     void subtract_(const value_type& minuend);
 
-private:
- /// Treatment of adjoint intervals on insertion
- iterator handle_neighbours(iterator it_);
-
- iterator join_on_left(iterator& left_, const iterator& right_);
 } ;
 
 
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline typename interval_set<DomainT,Compare,Interval,Alloc>::iterator
- interval_set<DomainT,Compare,Interval,Alloc>::handle_neighbours(iterator it_)
-{
- if(it_ == this->_set.begin())
- {
- iterator it_nxt=it_; it_nxt++;
- if(it_nxt!=this->_set.end() && touches(*it_, *it_nxt))
- return join_on_left(it_, it_nxt);
- }
- else
- {
- // there is a predecessor
- iterator pred_ = it_; pred_-- ;
-
- if(touches(*pred_, *it_))
- {
- iterator it_extended = join_on_left(pred_, it_);
-
- iterator succ_=it_extended; succ_++;
- if(succ_!=this->_set.end())
- {
- // it's a non border element that might have two touching neighbours
- if(touches(*it_extended, *succ_))
- return join_on_left(it_extended, succ_);
- else
- return it_extended;
- }
- else
- return it_extended;
- }
- else
- {
- iterator succ_=it_; succ_++;
- if(succ_!=this->_set.end())
- {
- // it's a non border element that might have a right touching neighbour
- if(touches(*it_, *succ_))
- return join_on_left(it_, succ_);
- }
- }
- }
-
- return it_;
-}
-
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline typename interval_set<DomainT,Compare,Interval,Alloc>::iterator
- interval_set<DomainT,Compare,Interval,Alloc>
- ::join_on_left(iterator& left_, const iterator& right_)
-{
- // both left and right are in the set and they are neighbours
- BOOST_ASSERT(exclusive_less(*left_, *right_));
- BOOST_ASSERT(touches(*left_, *right_));
-
- interval_type right_itv = (*right_);
- this->_set.erase(right_);
- const_cast<value_type&>(*left_) = hull(*left_, right_itv);
-
- return left_;
-}
-
-
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 void interval_set<DomainT,Compare,Interval,Alloc>::add_(const value_type& addend)
 {
- if(itl::is_empty(addend)) return;
-
- std::pair<iterator,bool> insertion = this->_set.insert(addend);
-
- if(insertion.second)
- handle_neighbours(insertion.first);
- else
- {
- iterator first_ = this->_set.lower_bound(addend),
- last_ = insertion.first,
- end_ = insertion.first; ++end_;
- //BOOST_ASSERT(end_ == this->_map.upper_bound(inter_val));
- iterator second_= first_; ++second_;
-
- interval_type left_resid = right_subtract(*first_, addend);
- interval_type right_resid = left_subtract(*last_ , addend);
-
- this->_set.erase(second_, end_ );
-
- const_cast<value_type&>(*first_) = hull(hull(left_resid, addend), right_resid);
- handle_neighbours(first_);
- }
+ detail::joining_add(*this, addend);
 }
 
+
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 typename interval_set<DomainT,Compare,Interval,Alloc>::iterator
     interval_set<DomainT,Compare,Interval,Alloc>::add_(iterator prior_, const value_type& addend)
 {
- if(boost::itl::is_empty(addend))
- return prior_;
-
- iterator insertion = this->_set.insert(prior_, addend);
-
- if(*insertion == addend)
- return handle_neighbours(insertion);
- else
- {
- std::pair<iterator,iterator> overlap = this->_set.equal_range(addend);
- iterator first_ = overlap.first,
- end_ = overlap.second,
- last_ = end_; --last_;
-
- iterator second_= first_; ++second_;
-
- //JODO code replication here: search hull(hull
- interval_type left_resid = right_subtract(*first_, addend);
- interval_type right_resid = left_subtract(*last_ , addend);
+ return detail::joining_add(*this, prior_, addend);
+}
 
- this->_set.erase(second_, end_);
 
- const_cast<value_type&>(*first_) = hull(hull(left_resid, addend), right_resid);
- return handle_neighbours(first_);
- }
-}
 
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 void interval_set<DomainT,Compare,Interval,Alloc>::subtract_(const value_type& minuend)
 {
- if(itl::is_empty(minuend)) return;
- iterator first_ = this->_set.lower_bound(minuend);
- if(first_==this->_set.end()) return;
- iterator end_ = this->_set.upper_bound(minuend);
- iterator last_ = end_; --last_;
-
- interval_type leftResid = right_subtract(*first_, minuend);
- interval_type rightResid;
- if(first_ != end_ )
- rightResid = left_subtract(*last_ , minuend);
-
- this->_set.erase(first_, end_ );
-
- if(!itl::is_empty(leftResid))
- this->_set.insert(leftResid);
-
- if(!itl::is_empty(rightResid))
- this->_set.insert(rightResid);
+ detail::subtract(*this, minuend);
 }
 
 
 //-----------------------------------------------------------------------------
-// equality of elements
-//-----------------------------------------------------------------------------
-template <class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline bool is_element_equal(const interval_set<DomainT,Compare,Interval,Alloc>& lhs,
- const interval_set<DomainT,Compare,Interval,Alloc>& rhs)
-{
- // Since both are joining interval sets we can use the simpler Set::lexicographical_equal
- return &lhs == &rhs || Set::lexicographical_equal(lhs, rhs);
-}
-
-//-----------------------------------------------------------------------------
 // type traits
 //-----------------------------------------------------------------------------
 template <class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -24,16 +24,21 @@
 #include <boost/itl/detail/design_config.hpp>
 #include <boost/itl/detail/concept_check.hpp>
 #include <boost/itl/type_traits/is_map.hpp>
+#include <boost/itl/type_traits/absorbs_neutrons.hpp>
+#include <boost/itl/type_traits/is_total.hpp>
 #include <boost/itl/type_traits/is_element_container.hpp>
 #include <boost/itl/type_traits/has_inverse.hpp>
 #include <boost/itl/type_traits/to_string.hpp>
-//CL #include <boost/itl/seqs.hpp>
 #include <boost/itl/functors.hpp>
 #include <boost/itl/predicates.hpp>
 #include <boost/itl/set.hpp>
-#include <boost/itl/map_functions.hpp>
+
+#include <boost/itl/functions/container.hpp>
+#include <boost/itl/functions/icl_container.hpp>
+#include <boost/itl/functions/associative_element_container.hpp>
 #include <boost/itl/detail/map_algo.hpp>
-#include <boost/itl/detail/map_functors.hpp>
+//CL #include <boost/itl/detail/map_functors.hpp>
+#include <boost/itl/map_functions.hpp>
 
 
 namespace boost{namespace itl

Modified: sandbox/itl/boost/itl/map_functions.hpp
==============================================================================
--- sandbox/itl/boost/itl/map_functions.hpp (original)
+++ sandbox/itl/boost/itl/map_functions.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -14,6 +14,9 @@
 #include <boost/itl/type_traits/is_element_container.hpp>
 #include <boost/itl/type_traits/is_key_container_of.hpp>
 
+#include <boost/itl/functions/container.hpp>
+#include <boost/itl/functions/associative_element_container.hpp>
+
 namespace boost{namespace itl
 {
 
@@ -21,162 +24,29 @@
 //= Containedness
 //==============================================================================
 
-/** All content of the container is dropped.
- Complexity: linear. */
-template<class MapT>
-typename enable_if<is_element_map<MapT>, void>::type
-clear(MapT& object)
-{
- object.clear();
-}
-
-/** Tests if the container is empty.
- Complexity: constant. */
-template<class MapT>
-typename enable_if<is_element_map<MapT>, bool>::type
-is_empty(const MapT& object)
-{
- return object.empty();
-}
-
-/** Checks if a key is in the map */
-template<class MapT>
-typename enable_if<is_element_map<MapT>, bool>::type
-contains(const MapT& object, const typename MapT::domain_type& key)
-{
- return !(object.find(key) == object.end());
-}
 
 /** Checks if a key-value pair is in the map */
 template<class MapT>
 typename enable_if<is_element_map<MapT>, bool>::type
-contains(const MapT& object, const typename MapT::element_type& key_value_pair)
+within(const typename MapT::element_type& value_pair, const MapT& super)
 {
     typedef typename MapT::const_iterator const_iterator;
- const_iterator found_ = object.find(key_value_pair.first);
- return found_ != object.end() && found_->second == key_value_pair.second;
+ const_iterator found_ = super.find(value_pair.first);
+ return found_ != super.end() && found_->second == value_pair.second;
 }
 
-/** Does <tt>super</tt> contain <tt>sub</tt>? */
 template<class MapT>
 typename enable_if<is_element_map<MapT>, bool>::type
-contains(const MapT& super, const MapT& sub)
-{ return itl::within(sub, super); }
-
-/** Does <tt>super</tt> contain <tt>sub</tt>? */
-template<class MapT>
-typename enable_if<is_element_map<MapT>, bool>::type
-contains(const MapT& super, const typename MapT::set_type& sub)
-{
- return itl::within(sub, super);
-}
-
-//- within ---------------------------------------------------------------------
-
-
-template<class SubT, class SuperT>
-typename enable_if<mpl::and_< is_element_map<SuperT>
- , is_key_container_of<SubT, SuperT> >,
- bool>::type
-within(const SubT& sub, const SuperT& super)
+contains(const MapT& super, const typename MapT::element_type& value_pair)
 {
- if(itl::is_empty(sub)) return true;
- if(itl::is_empty(super)) return false;
- if(itl::size(super) < itl::size(sub)) return false;
-
- typename SubT::const_iterator common_lwb_;
- typename SubT::const_iterator common_upb_;
- if(!Set::common_range(common_lwb_, common_upb_, sub, super))
- return false;
-
- typename SubT::const_iterator sub_ = sub.begin();
- typename SuperT::const_iterator super_;
- while(sub_ != sub.end())
- {
- super_ = super.find(SubT::key_value(sub_));
- if(super_ == super.end())
- return false;
- else if(!co_equal(sub_, super_, sub, super))
- return false;
-
- ++sub_;
- }
- return true;
+ return itl::within(value_pair, super);
 }
 
 
-
-/** Is <tt>sub</tt> contained within <tt>super</tt>? */
-template<class MapT>
-typename enable_if<is_element_map<MapT>, bool>::type
-within(const typename MapT::domain_type& sub, const MapT& super)
-{ return contains(super, sub); }
-
-/** Is <tt>sub</tt> contained within <tt>super</tt>? */
-template<class MapT>
-typename enable_if<is_element_map<MapT>, bool>::type
-within(const typename MapT::element_type& sub, const MapT& super)
-{ return contains(super, sub); }
-
-//==============================================================================
-//= Size
-//==============================================================================
-template<class MapT>
-typename enable_if<is_element_map<MapT>, typename MapT::size_type>::type
-size(const MapT& object)
-{
- return object.size();
-}
-
-template<class MapT>
-typename enable_if<is_element_map<MapT>, typename MapT::size_type>::type
-cardinality(const MapT& object)
-{
- return object.size();
-}
-
-template<class MapT>
-typename enable_if<is_element_map<MapT>, typename MapT::size_type>::type
-iterative_size(const MapT& object)
-{
- return object.size();
-}
-
-
-
 //==============================================================================
 //= Equivalences and Orderings
 //==============================================================================
 
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4996) //'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
-#endif // I do guarantee here that I am using the parameters correctly :)
-
-/** Standard equality, which is lexicographical equality of the sets
- as sequences, that are given by their Compare order. */
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-operator == (const MapT& lhs, const MapT& rhs)
-{
- return lhs.size() == rhs.size()
- && equal(lhs.begin(), lhs.end(), rhs.begin());
-}
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-operator != (const MapT& lhs, const MapT& rhs)
-{ return !(lhs == rhs); }
-
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-is_element_equal(const MapT& lhs, const MapT& rhs)
-{ return lhs == rhs; }
-
 /** Protonic equality is equality on all elements that do not carry a neutron as content. */
 template<class MapT>
 inline typename enable_if<is_element_map<MapT>, bool>::type
@@ -185,36 +55,6 @@
     return Map::lexicographical_protonic_equal(lhs, rhs);
 }
 
-/** Strict weak less ordering which is given by the Compare order */
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-operator < (const MapT& lhs, const MapT& rhs)
-{
- return std::lexicographical_compare(
- lhs.begin(), lhs.end(), rhs.begin(), rhs.end(),
- typename MapT::element_compare()
- //lhs.value_comp() //JODO why does this implementation violate antisymmetry?
- );
-}
-
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-operator > (const MapT& lhs, const MapT& rhs)
-{ return rhs < lhs; }
-
-/** Partial ordering which is induced by Compare */
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-operator <= (const MapT& lhs, const MapT& rhs)
-{ return !(lhs > rhs); }
-
-template<class MapT>
-inline typename enable_if<is_element_map<MapT>, bool>::type
-operator >= (const MapT& lhs, const MapT& rhs)
-{ return !(lhs < rhs); }
-
-//------------------------------------------------------------------------------
-
 
 //==============================================================================
 //= Addition
@@ -241,81 +81,6 @@
 }
 
 
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type&
-operator += (MapT& object, const typename MapT::element_type& value_pair)
-{
- return itl::add(object, value_pair);
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type
-operator + (MapT object, const typename MapT::element_type& value_pair)
-{
- return object += value_pair;
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type
-operator + (const typename MapT::element_type& value_pair, MapT object)
-{
- return object += value_pair;
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type&
-operator += (MapT& object, const MapT& addend)
-{
- return Set::add(object, addend);
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type
-operator + (MapT object, const MapT& addend)
-{
- return object += addend;
-}
-
-//==============================================================================
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type&
-operator |= (MapT& object, const typename MapT::element_type& value_pair)
-{
- return itl::add(object, value_pair);
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type
-operator | (MapT object, const typename MapT::element_type& value_pair)
-{
- return object += value_pair;
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type
-operator | (const typename MapT::element_type& value_pair, MapT object)
-{
- return object += value_pair;
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type&
-operator |= (MapT& object, const MapT& addend)
-{
- return Set::add(object, addend);
-}
-
-template <class MapT>
-inline typename enable_if<is_element_map<MapT>, MapT>::type
-operator | (MapT object, const MapT& addend)
-{
- return object += addend;
-}
-
-
-
-
 //==============================================================================
 //= Subtraction
 //==============================================================================
@@ -693,7 +458,7 @@
 //==============================================================================
 
 template<class MapT, class Predicate>
-inline typename enable_if<is_element_map<MapT>, MapT>::type&
+typename enable_if<is_element_map<MapT>, MapT>::type&
 erase_if(const Predicate& pred, MapT& object)
 {
     typename MapT::iterator it_ = object.begin();
@@ -733,7 +498,8 @@
 inline typename enable_if<is_element_map<MapT>, MapT>::type&
 absorb_neutrons(MapT& object)
 {
- return map_absorb_neutrons<MapT,absorbs_neutrons<MapT>::value>::apply(object);
+ BOOST_STATIC_CONSTANT(bool, absorbs = MapT::Traits::absorbs_neutrons);
+ return map_absorb_neutrons<MapT,absorbs>::apply(object);
 }
 
 

Modified: sandbox/itl/boost/itl/separate_interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/separate_interval_set.hpp (original)
+++ sandbox/itl/boost/itl/separate_interval_set.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -9,6 +9,7 @@
 #define BOOST_ITL_SEPARATE_INTERVAL_SET_HPP_JOFA_080608
 
 #include <boost/assert.hpp>
+#include <boost/itl/type_traits/is_interval_separator.hpp>
 #include <boost/itl/interval_base_set.hpp>
 #include <boost/itl/interval_set.hpp>
 
@@ -147,84 +148,21 @@
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 inline void separate_interval_set<DomainT,Compare,Interval,Alloc>::add_(const value_type& addend)
 {
- if(itl::is_empty(addend)) return;
-
- std::pair<iterator,bool> insertion = this->_set.insert(addend);
-
- if(insertion.second)
- handle_neighbours(insertion.first);
- else
- {
- iterator first_ = this->_set.lower_bound(addend),
- last_ = insertion.first,
- end_ = insertion.first; end_ ++;
- //BOOST_ASSERT(end_ == this->_map.upper_bound(inter_val));
- iterator second_= first_; ++second_;
-
- //JODO code replication here: search hull(hull
- interval_type left_resid = right_subtract(*first_, addend);
- interval_type right_resid = left_subtract(*last_ , addend);
-
- this->_set.erase(second_, end_);
-
- const_cast<value_type&>(*first_) = hull(hull(left_resid, addend), right_resid);
- }
+ detail::separating_add(*this, addend);
 }
 
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 typename separate_interval_set<DomainT,Compare,Interval,Alloc>::iterator
     separate_interval_set<DomainT,Compare,Interval,Alloc>::add_(iterator prior_, const value_type& addend)
 {
- if(itl::is_empty(addend))
- return prior_;
-
- iterator insertion = this->_set.insert(prior_, addend);
-
- if(*insertion == addend)
- return insertion;
- else
- {
- std::pair<iterator,iterator> overlap = this->_set.equal_range(addend);
- iterator first_ = overlap.first,
- end_ = overlap.second,
- last_ = end_; --last_;
-
- iterator second_= first_; ++second_;
-
- //JODO code replication here: search hull(hull
- interval_type left_resid = right_subtract(*first_, addend);
- interval_type right_resid = left_subtract(*last_ , addend);
-
- this->_set.erase(second_, end_);
-
- const_cast<value_type&>(*first_) = hull(hull(left_resid, addend), right_resid);
- return first_;
- }
+ return detail::separating_add(*this, prior_, addend);
 }
 
 
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 inline void separate_interval_set<DomainT,Compare,Interval,Alloc>::subtract_(const value_type& minuend)
 {
- if(itl::is_empty(minuend)) return;
- iterator first_ = this->_set.lower_bound(minuend);
- if(first_==this->_set.end()) return;
- iterator end_ = this->_set.upper_bound(minuend);
- iterator second_= first_; ++second_;
- iterator last_ = end_; --last_;
-
- interval_type leftResid = right_subtract(*first_, minuend);
- interval_type rightResid;
- if(first_ != end_ )
- rightResid = left_subtract(*last_ , minuend);
-
- this->_set.erase(first_, end_ );
-
- if(!itl::is_empty(leftResid))
- this->_set.insert(leftResid);
-
- if(!itl::is_empty(rightResid))
- this->_set.insert(rightResid);
+ detail::subtract(*this, minuend);
 }
 
 //-----------------------------------------------------------------------------

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -1,5 +1,5 @@
 /*-----------------------------------------------------------------------------+
-Copyright (c) 2007-2009: Joachim Faulhaber
+Copyright (c) 2007-2010: Joachim Faulhaber
 +------------------------------------------------------------------------------+
    Distributed under the Boost Software License, Version 1.0.
       (See accompanying file LICENCE.txt or copy at
@@ -19,31 +19,27 @@
 #endif
 
 #include <string>
+#include <boost/itl/detail/design_config.hpp>
 #include <boost/itl/detail/concept_check.hpp>
 #include <boost/itl/type_traits/to_string.hpp>
 #include <boost/itl/type_traits/is_set.hpp>
-#include <boost/itl/type_traits/has_set_semantics.hpp>
-#include <boost/itl/type_traits/is_interval_container.hpp>
-#include <boost/itl/type_traits/is_interval_splitter.hpp>
-#include <boost/itl/type_traits/is_interval_separator.hpp>
-#include <boost/itl/type_traits/absorbs_neutrons.hpp>
-#include <boost/itl/type_traits/is_total.hpp>
-#include <boost/itl/detail/notate.hpp>
-#include <boost/itl/detail/design_config.hpp>
 #include <boost/itl/detail/subset_comparer.hpp>
 #include <boost/itl/detail/set_algo.hpp>
 #include <boost/itl/predicates.hpp>
-
-#include <boost/utility/enable_if.hpp>
+#include <boost/itl/set_functions.hpp>
 #include <boost/mpl/or.hpp>
 #include <boost/mpl/not.hpp>
 #include <boost/type_traits/is_same.hpp>
 
+#include <boost/itl/functions/container.hpp>
+#include <boost/itl/functions/icl_container.hpp>
+#include <boost/itl/functions/associative_element_container.hpp>
+#include <boost/itl/set_functions.hpp>
 
 namespace boost{namespace itl
 {
 
-/** \brief Addable, subractable and intersectable sets. */
+/** \brief Addable, subtractable and intersectable sets. */
 template
 <
     typename DomainT,
@@ -55,7 +51,7 @@
 public:
     typedef typename itl::set<DomainT, Compare, Alloc> type;
     typedef typename ITL_IMPL_SPACE::set<DomainT, ITL_COMPARE_DOMAIN(Compare,DomainT), Alloc<DomainT> > base_type;
- typedef type key_object_type;
+ typedef type key_object_type;
 
 public:
     typedef DomainT domain_type;
@@ -65,6 +61,7 @@
     typedef DomainT value_type;
     typedef DomainT data_type;
     typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
+ typedef domain_compare element_compare;
     typedef ITL_COMPARE_DOMAIN(Compare,DomainT) key_compare;
     typedef ITL_COMPARE_DOMAIN(Compare,DomainT) value_compare;
     typedef Alloc<DomainT> allocator_type;
@@ -123,11 +120,9 @@
     set& assign_if(const set& src, const Predicate&);
 
     //==========================================================================
-ITL_BEGIN_COMMON_MEMBER_FUNCTIONS:
     using base_type::empty;
     using base_type::clear;
 
-ITL_END_COMMON_MEMBER_FUNCTIONS:
     using base_type::begin;
     using base_type::end;
     using base_type::rbegin;
@@ -155,17 +150,19 @@
 
     /// Checks if the element \c value is in the set
     bool contains(const element_type& value)const
- { return !(find(value) == end()); }
+ { return itl::contains(*this, value); }
+
+ /** Does <tt>*this</tt> contain <tt>sub</tt>? */
+ bool contains(const set& sub)const
+ { return itl::contains(*this, sub); }
 
     /** Is <tt>*this</tt> contained in <tt>super</tt>? */
     bool contained_in(const set& super)const
- { return Set::within(*this, super); }
-
- /** Does <tt>*this</tt> contain <tt>sub</tt>? */
- bool contains(const set& sub)const { return Set::within(sub, *this); }
+ { return itl::within(*this, super); }
 
     /** <tt>*this</tt> and <tt>x2</tt> are disjoint, if their intersection is empty */
- bool is_disjoint(const set& x2)const { return Set::is_disjoint(*this, x2); }
+ bool disjoint(const set& x2)const
+ { return itl::disjoint(*this, x2); }
 
     //==========================================================================
     //= Size
@@ -181,33 +178,35 @@
     //= Addition, subtraction
     //==========================================================================
     /** Add an \c element to the set. */
- set& add(const element_type& element) { insert(element); return *this; }
+ set& add(const element_type& element)
+ { return itl::insert(*this, element); }
 
     /** Add an element \c element after \c prior to the set. */
     iterator add(iterator prior, const element_type& element)
- { return insert(prior, element); }
+ { return itl::insert(*this, prior, element); }
 
     /** Subtract an \c element from the set. */
- set& subtract(const element_type& element);
+ set& subtract(const element_type& element)
+ { return itl::subtract(*this, element); }
 
     //==========================================================================
     //= Insertion, erasure
     //==========================================================================
- /** Erase the elements in *this set to which property \c hasProperty applies.
- Keep all the rest. */
- template<class Predicate>
- set& erase_if(const Predicate&);
+
+ //JODO
 
     //==========================================================================
     //= Intersection, symmetric difference
     //==========================================================================
 
     /** Add \c element to \c section, if \c element is in \c *this set */
- void add_intersection(set& section, const element_type& element)const;
+ void add_intersection(set& section, const element_type& element)const
+ { itl::add_intersection(section, *this, element); }
 
     /** The intersection of set \c sectant with \c *this set is added
         to \c section. */
- void add_intersection(set& section, const set& sectant)const;
+ void add_intersection(set& section, const set& sectant)const
+ { itl::add_intersection(section, *this, sectant); }
 
     /** Returns true, if there is an intersection of \c element and \c *this set.
         Functions \c intersects and \c contains are identical on arguments
@@ -215,14 +214,9 @@
     bool intersects(const element_type& element)const { return contains(element); }
 
     /** If \c *this set contains \c element it is erased, otherwise it is added. */
- set& flip(const element_type& element);
-
- //==========================================================================
- //= Representation
- //==========================================================================
+ set& flip(const element_type& element)
+ { return itl::flip(*this, element); }
 
- /** Represent this set as a string */
- std::string as_string(const char* sep = " ")const;
 
     //==========================================================================
     //= Algorithm unifiers
@@ -233,7 +227,7 @@
     template<typename IteratorT>
     static const key_type& key_value(IteratorT value_){ return (*value_); }
 
- /** \c co_value allows for a uniform access to \c data_values which is
+ /** \c codomain_value allows for a uniform access to \c data_values which is
         is used for common algorithms on sets and maps. */
     template<typename IteratorT>
     static const codomain_type& co_value(IteratorT value_){ return (*value_); }
@@ -253,534 +247,6 @@
 
 
 
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-set<DomainT,Compare,Alloc>&
- set<DomainT,Compare,Alloc>::subtract(const element_type& val)
-{
- iterator it_ = find(val);
- if(it_ != end())
- erase(it_);
-
- return *this;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-void set<DomainT,Compare,Alloc>
- ::add_intersection(set& section, const element_type&sectant)const
-{
- const_iterator it_ = find(sectant);
- if(it_ != end())
- section.add(*it_);
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-void set<DomainT,Compare,Alloc>
- ::add_intersection(set& section, const set& sectant)const
-{
- const_iterator common_lwb_;
- const_iterator common_upb_;
- if(!Set::common_range(common_lwb_, common_upb_, sectant, *this))
- return;
-
- const_iterator sec_ = common_lwb_;
- while(sec_ != common_upb_)
- add_intersection(section, *sec_++);
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-set<DomainT,Compare,Alloc>::flip(const element_type& operand)
-{
- std::pair<iterator,bool> insertion = insert(operand);
- if(!insertion.second)
- erase(insertion.first);
-
- return *this;
-}
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-std::string set<DomainT,Compare,Alloc>::as_string(const char* sep)const
-{
- const_iterator it_ = begin();
-
- if(it_ == end()) return std::string();
- else
- {
- std::string y = to_string<DomainT>::apply(*it_++);
- while(it_ != end()) { y += sep; y += to_string<DomainT>::apply(*it_++); }
- return y;
- }
-}
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- template <class Predicate>
-set<DomainT,Compare,Alloc>& set<DomainT,Compare,Alloc>
- ::erase_if(const Predicate& pred)
-{
- iterator it = begin();
- while(it != end())
- if(pred(*it))
- erase(it++);
- else ++it;
- return *this;
-
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- template <class Predicate>
-set<DomainT,Compare,Alloc>& set<DomainT,Compare,Alloc>
- ::assign_if(const set<DomainT,Compare,Alloc>& src, const Predicate& pred)
-{
- clear();
- const_iterator it = src.begin();
- while(it != src.end()) {
- if(pred(*it))
- add(*it++);
- }
- return *this;
-}
-
-//-----------------------------------------------------------------------------
-// non member functions
-//-----------------------------------------------------------------------------
-
-//==========================================================================
-//= Containedness
-//==========================================================================
-//JODO general container concept
-/** All content of the container is dropped.
- Complexity: linear. */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-void clear(itl::set<DomainT,Compare,Alloc>& object) //JODO test
-{
- //object.clear();
- object.erase(object.begin(), object.end());
-}
-
-/** Tests if the container is empty.
- Complexity: constant. */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-bool is_empty(const itl::set<DomainT,Compare,Alloc>& object)
-{
- //return object.empty();
- return object.begin() == object.end();
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool contains(const itl::set<DomainT,Compare,Alloc>& super,
- const DomainT& sub)
-{
- return !(super.find(sub) == super.end());
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool contains(const itl::set<DomainT,Compare,Alloc>& super,
- const itl::set<DomainT,Compare,Alloc>& sub)
-{
- return Set::within(sub, super); //JODO within
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool within(const itl::set<DomainT,Compare,Alloc>& sub,
- const itl::set<DomainT,Compare,Alloc>& super)
-{
- return Set::within(sub, super); //JODO within
-}
-
-
-//==============================================================================
-//= Equivalences and Orderings
-//==============================================================================
-
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4996) //'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
-#endif // I do guarantee here that I am using the parameters correctly :)
-
-/** Standard equality, which is lexicographical equality of the sets
- as sequences, that are given by their Compare order. */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool operator == (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{
- return lhs.size() == rhs.size()
- && equal(lhs.begin(), lhs.end(), rhs.begin());
-}
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool operator != (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{ return !(lhs == rhs); }
-
-/** Element equality. Two sets are equal if they contain the same elements */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool is_element_equal(const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{ return lhs == rhs; }
-
-/** Strict weak less ordering which is given by the Compare order */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool operator < (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{
- typedef ITL_IMPL_SPACE
- ::set<DomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
- return operator<((const base_type&)lhs, (const base_type&)rhs);
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool operator > (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{ return rhs < lhs; }
-
-/** Partial ordering which is induced by Compare */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool operator <= (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{ return !(lhs > rhs); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline bool operator >= (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
-{ return !(lhs < rhs); }
-
-//==============================================================================
-//= Size
-//==============================================================================
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-typename set<DomainT,Compare,Alloc>::size_type
-size(const itl::set<DomainT,Compare,Alloc>& object)
-{
- return object.size();
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-typename set<DomainT,Compare,Alloc>::size_type
-cardinality(const itl::set<DomainT,Compare,Alloc>& object)
-{
- return object.size();
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-typename set<DomainT,Compare,Alloc>::size_type
-iterative_size(const itl::set<DomainT,Compare,Alloc>& object)
-{
- return object.size();
-}
-
-
-
-//==============================================================================
-//= Addition
-//==============================================================================
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator += ( itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{ return object.add(operand); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator + ( itl::set<DomainT,Compare,Alloc> object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- return object += operand;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator + (const typename itl::set<DomainT,Compare,Alloc>::element_type& operand,
- itl::set<DomainT,Compare,Alloc> object)
-{
- return object += operand;
-}
-
-/// Add a set \c operand to set \c object.
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator += ( itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{ Set::add(object, operand); return object; }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-itl::set<DomainT,Compare,Alloc>
-operator + ( itl::set<DomainT,Compare,Alloc> object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- return object += operand;
-}
-
-//--------------------------------------------------------------------------
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator |= ( itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{ return object.add(operand); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-itl::set<DomainT,Compare,Alloc>
-operator | ( itl::set<DomainT,Compare,Alloc> object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- return object |= operand;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator | (const typename itl::set<DomainT,Compare,Alloc>::element_type& operand,
- itl::set<DomainT,Compare,Alloc> object)
-{
- return object |= operand;
-}
-
-/// Add a set \c operand to this set \object.
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator |= ( itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{ Set::add(object, operand); return object; }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator | ( itl::set<DomainT,Compare,Alloc> object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- return object |= operand;
-}
-
-//--------------------------------------------------------------------------
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator -= ( itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{ return object.subtract(operand); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator - ( itl::set<DomainT,Compare,Alloc> object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- return object -= operand;
-}
-
-/// Subtract a set \c x2 from this set.
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator -= ( itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{ Set::subtract(object, operand); return object; }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator - ( itl::set<DomainT,Compare,Alloc> object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- return object -= operand;
-}
-
-//--------------------------------------------------------------------------
-// itl::set::intersection operators &=, &
-//--------------------------------------------------------------------------
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator &= ( itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- itl::set<DomainT,Compare,Alloc> section;
- object.add_intersection(section, operand);
- object.swap(section);
- return object;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator & ( itl::set<DomainT,Compare,Alloc> object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- return object &= operand;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator & (const typename itl::set<DomainT,Compare,Alloc>::element_type& operand,
- itl::set<DomainT,Compare,Alloc> object)
-{
- return object &= operand;
-}
-
-
-
-/** Intersect set \c object with \c operand.
- So \c object becomes the intersection of \c object and \c operand */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator &= ( itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- itl::set<DomainT,Compare,Alloc> section;
- object.add_intersection(section, operand);
- object.swap(section);
- return object;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator & ( itl::set<DomainT,Compare,Alloc> object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- return object &= operand;
-}
-
-
-template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
-bool intersects(const itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& element)
-{
- return object.intersects(element);
-}
-
-template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
-bool intersects(
- const typename itl::set<DomainT,Compare,Alloc>::element_type& element,
- const itl::set<DomainT,Compare,Alloc>& object)
-{
- return object.intersects(element);
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-bool intersects(const itl::set<DomainT,Compare,Alloc>& left,
- const itl::set<DomainT,Compare,Alloc>& right)
-{
- if(left.iterative_size() < right.iterative_size())
- return Set::intersects(right, left);
- else
- return Set::intersects(left, right);
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc,
- class LeftT, class RightT>
-enable_if<mpl::or_<is_same< typename itl::set<DomainT,Compare,Alloc>, LeftT >,
- is_same< typename itl::set<DomainT,Compare,Alloc>, RightT>
- >, bool>
-is_disjoint(const LeftT& left, const RightT& right)
-{
- return !intersects(left,right);
-}
-
-
-
-//--------------------------------------------------------------------------
-// itl::set::symmetric_difference operators ^=, ^
-//--------------------------------------------------------------------------
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator ^= ( itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- return object.flip(operand);
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator ^ ( itl::set<DomainT,Compare,Alloc> object,
- const typename itl::set<DomainT,Compare,Alloc>::element_type& operand)
-{
- return object ^= operand;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>
-operator ^ (const typename itl::set<DomainT,Compare,Alloc>::element_type& operand,
- itl::set<DomainT,Compare,Alloc> object)
-{
- return object ^= operand;
-}
-
-
-/** Intersect set \c object with \c operand.
- So \c object becomes the intersection of \c object and \c operand */
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-inline itl::set<DomainT,Compare,Alloc>&
-operator ^= ( itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- Set::flip(object, operand); return object;
-}
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-itl::set<DomainT,Compare,Alloc>
-operator ^ ( itl::set<DomainT,Compare,Alloc> object,
- const itl::set<DomainT,Compare,Alloc>& operand)
-{
- return object ^= operand;
-}
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-std::pair<typename set<DomainT,Compare,Alloc>::iterator, bool>
- add( set<DomainT,Compare,Alloc>& object,
- const DomainT& operand)
-{ return object.insert(operand); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-typename set<DomainT,Compare,Alloc>::iterator
- add( set<DomainT,Compare,Alloc>& object,
- typename set<DomainT,Compare,Alloc>::iterator prior,
- const DomainT& operand)
-{ return object.insert(prior, operand); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-std::pair<typename set<DomainT,Compare,Alloc>::iterator, bool>
- insert( set<DomainT,Compare,Alloc>& object,
- const DomainT& operand)
-{ return object.insert(operand); }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-set<DomainT,Compare,Alloc>&
- insert( set<DomainT,Compare,Alloc>& object,
- const set<DomainT,Compare,Alloc>& operand)
-{ return object += operand; }
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-set<DomainT,Compare,Alloc>&
- erase( set<DomainT,Compare,Alloc>& object,
- const set<DomainT,Compare,Alloc>& operand)
-{ return object -= operand; }
-
-
-//==============================================================================
-//= Streaming
-//==============================================================================
-template<class CharType, class CharTraits,
- class DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
-std::basic_ostream<CharType, CharTraits>& operator <<
- (std::basic_ostream<CharType, CharTraits>& stream,
- const itl::set<DomainT,Compare,Alloc>& object)
-{
- typedef itl::set<DomainT,Compare,Alloc> ObjectT;
- stream << "{";
- typename ObjectT::const_iterator it = object.begin();
- if(it != object.end())
- stream << *it++;
- while(it != object.end())
- stream << " " << *it++;
-
- return stream << "}";
-}
-
-
-
 //-----------------------------------------------------------------------------
 // type traits
 //-----------------------------------------------------------------------------
@@ -791,33 +257,6 @@
     BOOST_STATIC_CONSTANT(bool, value = true);
 };
 
-template <class Type>
-struct is_interval_container<itl::set<Type> >
-{
- typedef is_interval_container<itl::set<Type> > type;
- BOOST_STATIC_CONSTANT(bool, value = false);
-};
-
-template <class Type>
-struct is_interval_splitter<itl::set<Type> >
-{
- typedef is_interval_splitter type;
- BOOST_STATIC_CONSTANT(bool, value = false);
-};
-
-template <class Type>
-struct absorbs_neutrons<itl::set<Type> >
-{
- typedef absorbs_neutrons type;
- BOOST_STATIC_CONSTANT(bool, value = false);
-};
-
-template <class Type>
-struct is_total<itl::set<Type> >
-{
- typedef is_total type;
- BOOST_STATIC_CONSTANT(bool, value = false);
-};
 
 template <class Type>
 struct type_to_string<itl::set<Type> >

Added: sandbox/itl/boost/itl/set_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/set_functions.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,448 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_SET_FUNCTIONS_HPP_JOFA_100827
+#define BOOST_ITL_SET_FUNCTIONS_HPP_JOFA_100827
+
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_element_container.hpp>
+#include <boost/itl/detail/map_algo.hpp>
+#include <boost/itl/detail/map_functors.hpp>
+
+#include <boost/itl/functions/container.hpp>
+#include <boost/itl/functions/associative_element_container.hpp>
+
+
+
+namespace boost{namespace itl
+{
+
+//------------------------------------------------------------------------------
+
+
+//==============================================================================
+//= Addition
+//==============================================================================
+/** \c add inserts \c operand into the map if it's key does
+ not exist in the map.
+ If \c operands's key value exists in the map, it's data
+ value is added to the data value already found in the map. */
+template <class SetT>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+add(SetT& object, const typename SetT::element_type& operand)
+{
+ object.insert(operand);
+ return object;
+}
+
+/** \c add add \c operand into the map using \c prior as a hint to
+ insert \c operand after the position \c prior is pointing to. */
+template <class SetT>
+typename enable_if<is_element_set<SetT>, typename SetT::iterator>::type
+add(SetT& object, typename SetT::iterator prior,
+ const typename SetT::element_type& operand)
+{
+ return object.insert(prior, operand);
+}
+
+
+//==============================================================================
+//= Subtraction
+//==============================================================================
+/** If the \c operand's key value is in the map, it's data value is
+ subtraced from the data value stored in the map. */
+template <class SetT>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+subtract(SetT& object, const typename SetT::element_type& operand)
+{
+ typedef typename SetT::iterator iterator;
+ iterator it_ = object.find(operand);
+ if(it_ != object.end())
+ object.erase(it_);
+
+ return object;
+}
+
+template <class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator -= (SetT& object, const typename SetT::element_type& operand)
+{
+ return itl::subtract(object, operand);
+}
+
+template <class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator - (SetT object, const typename SetT::element_type& operand)
+{
+ return object -= operand;
+}
+
+template <class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator -= (SetT& object, const SetT& subtrahend)
+{
+ ITL_const_FORALL(typename SetT, it_, subtrahend)
+ itl::subtract(object, *it_);
+
+ return object;
+}
+
+template <class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator - (SetT object, const SetT& subtrahend)
+{
+ return object -= subtrahend;
+}
+
+template <class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator -= (SetT& object, const typename SetT::set_type& subtrahend)
+{
+ return Set::erase(object, subtrahend);
+}
+
+template <class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator - (SetT object, const typename SetT::set_type& subtrahend)
+{
+ return object -= subtrahend;
+}
+
+
+
+//==============================================================================
+//= Insertion
+//==============================================================================
+
+template<class SetT>
+typename enable_if<is_element_set<SetT>,
+ std::pair<typename SetT::iterator,bool> >::type
+insert(SetT& object, const typename SetT::element_type& operand)
+{
+ return object.insert(operand);
+}
+
+template<class SetT>
+typename enable_if<is_element_set<SetT>,
+ typename SetT::iterator>::type
+insert(SetT& object, typename SetT::iterator prior, const typename SetT::element_type& operand)
+{
+ return object.insert(prior, operand);
+}
+
+template<class SetT>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+insert(SetT& object, const SetT& addend)
+{
+ typedef typename SetT::iterator iterator;
+
+ iterator prior_ = object.end();
+ ITL_const_FORALL(typename SetT, elem_, addend)
+ itl::insert(object, prior_, *elem_);
+
+ return object;
+}
+
+//==============================================================================
+//= Erasure
+//==============================================================================
+
+template<class SetT>
+typename enable_if<is_element_set<SetT>, typename SetT::size_type>::type
+erase(SetT& object, const typename SetT::domain_type& operand)
+{
+ typedef typename SetT::iterator iterator;
+ iterator it_ = object.find(operand);
+ if(it_ != object.end())
+ {
+ object.erase(it_);
+ return 1;
+ }
+
+ return 0;
+}
+
+template<class SetT>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+erase(SetT& object, const typename SetT::set_type& erasure)
+{
+ typedef typename SetT::set_type set_type;
+ ITL_const_FORALL(typename set_type, elem_, erasure)
+ itl::erase(object, *elem_);
+
+ return object;
+}
+
+template<class SetT>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+erase(SetT& object, const SetT& erasure)
+{
+ ITL_const_FORALL(typename SetT, elem_, erasure)
+ itl::erase(object, *elem_);
+
+ return object;
+}
+
+
+
+//==============================================================================
+//= Intersection
+//==============================================================================
+
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+add_intersection(SetT& section, const SetT& object, const typename SetT::domain_type& operand)
+{
+ typedef typename SetT::const_iterator const_iterator;
+ const_iterator it_ = object.find(operand);
+ if(it_ != object.end())
+ itl::add(section, *it_);
+
+ return section;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+add_intersection(SetT& section, const SetT& object, const SetT& operand)
+{
+ typedef typename SetT::const_iterator const_iterator;
+ const_iterator common_lwb_;
+ const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, operand, object))
+ return section;
+
+ const_iterator sec_ = common_lwb_;
+ while(sec_ != common_upb_)
+ add_intersection(section, object, *sec_++);
+
+ return section;
+}
+
+
+/** Intersect map \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator &= (SetT& object, const SetT& operand)
+{
+ SetT section;
+ itl::add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator & (SetT object, const SetT& operand)
+{
+ return object &= operand;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator &= (SetT& object, const typename SetT::element_type& operand) //JODO codereplica.
+{
+ SetT section;
+ itl::add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator & (SetT object, const typename SetT::element_type& operand)
+{
+ return object &= operand;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator & (const typename SetT::element_type& operand, SetT object)
+{
+ return object &= operand;
+}
+
+
+/** Intersect set \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator &= (SetT& object, const typename SetT::set_type& operand)
+{
+ SetT section;
+ add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator & (SetT object, const typename SetT::set_type& key_set)
+{
+ return object &= key_set; //JODO test a - (a & s) == a - s
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator & (const typename SetT::set_type& key_set, SetT object)
+{
+ return object &= key_set; //JODO test a - (s & a) == a - s
+}
+
+
+//------------------------------------------------------------------------------
+//- intersects
+//------------------------------------------------------------------------------
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, bool>::type
+intersects(const SetT& object, const typename SetT::domain_type& operand)
+{
+ return itl::contains(object, operand);
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, bool>::type
+intersects(const typename SetT::domain_type& operand, const SetT& object)
+{
+ return itl::contains(object, operand);
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, bool>::type
+intersects(const SetT& object, const SetT& operand)
+{
+ if(iterative_size(object) < iterative_size(operand))
+ return Set::intersects(object, operand);
+ else
+ return Set::intersects(operand, object);
+}
+
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, bool>::type
+disjoint(const SetT& left, const SetT& right)//JODO All variants via meta predicate.
+{
+ return !intersects(left, right);
+}
+
+
+
+//==============================================================================
+//= Symmetric difference
+//==============================================================================
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+flip(SetT& object, const typename SetT::element_type& operand)
+{
+ typedef typename SetT::iterator iterator;
+ std::pair<iterator,bool> insertion = object.insert(operand);
+ if(!insertion.second)
+ object.erase(insertion.first);
+
+ return object;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator ^= (SetT& object, const typename SetT::element_tpye& operand)
+{
+ return itl::flip(object, operand);
+}
+
+/** Symmetric subtract map \c x2 and \c *this.
+ So \c *this becomes the symmetric difference of \c *this and \c x2 */
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+operator ^= (SetT& object, const SetT& operand)
+{
+ typedef typename SetT::const_iterator const_iterator;
+ const_iterator it_ = operand.begin();
+ while(it_ != operand.end())
+ itl::flip(object, *it_++);
+
+ return object;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator ^ (SetT object, const SetT& operand)
+{
+ return object ^= operand;
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator ^ (SetT object, const typename SetT::element_type& operand)
+{
+ return itl::flip(object, operand);
+}
+
+template<class SetT>
+inline typename enable_if<is_element_set<SetT>, SetT>::type
+operator ^ (const typename SetT::element_type& operand, SetT object)
+{
+ return itl::flip(object, operand);
+}
+
+//==============================================================================
+//= Manipulation by predicates
+//==============================================================================
+
+template<class SetT, class Predicate>
+typename enable_if<is_element_set<SetT>, SetT>::type&
+erase_if(const Predicate& pred, SetT& object)
+{
+ typename SetT::iterator it_ = object.begin();
+ while(it_ != object.end())
+ if(pred(*it_))
+ itl::erase(object, it_++);
+ else ++it_;
+ return object;
+}
+
+
+template<class SetT, class Predicate>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+add_if(const Predicate& pred, SetT& object, const SetT& src)
+{
+ typename SetT::const_iterator it_ = src.begin();
+ while(it_ != src.end())
+ if(pred(*it_))
+ itl::add(object, *it_++);
+
+ return object;
+}
+
+template<class SetT, class Predicate>
+inline typename enable_if<is_element_set<SetT>, SetT>::type&
+assign_if(const Predicate& pred, SetT& object, const SetT& src)
+{
+ itl::clear(object);
+ return add_if(object, src, pred);
+}
+
+
+//---------------------------------------------------------------------------------
+template<class CharType, class CharTraits, class SetT>
+inline typename enable_if<is_element_set<SetT>, std::basic_ostream<CharType, CharTraits> >::type&
+operator << (std::basic_ostream<CharType, CharTraits>& stream, const SetT& object)
+{
+ stream << "{";
+ ITL_const_FORALL(typename SetT, it, object)
+ stream << *it << " ";
+
+ return stream << "}";
+}
+
+
+}} // namespace itl boost
+
+#endif // BOOST_ITL_SET_FUNCTIONS_HPP_JOFA_100827
+

Modified: sandbox/itl/boost/itl/split_interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/split_interval_set.hpp (original)
+++ sandbox/itl/boost/itl/split_interval_set.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -9,6 +9,7 @@
 #ifndef __split_interval_set_JOFA_990223__
 #define __split_interval_set_JOFA_990223__
 
+#include <boost/itl/type_traits/is_interval_splitter.hpp>
 #include <boost/itl/interval_base_set.hpp>
 #include <boost/itl/interval_set.hpp>
 
@@ -148,23 +149,7 @@
 template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 inline void split_interval_set<DomainT,Compare,Interval,Alloc>::add_(const value_type& addend)
 {
- if(itl::is_empty(addend)) return;
-
- std::pair<iterator,bool> insertion = this->_set.insert(addend);
-
- if(!insertion.second)
- {
- iterator first_ = this->_set.lower_bound(addend),
- last_ = insertion.first;
- //BOOST_ASSERT(next(last_) == this->_set.upper_bound(inter_val));
-
- iterator it_ = first_;
- interval_type rest_interval = addend;
-
- add_front(rest_interval, it_);
- add_main (rest_interval, it_, last_);
- add_rear (rest_interval, it_);
- }
+ detail::splitting_add(*this, addend);
 }
 
 
@@ -172,161 +157,13 @@
 inline typename split_interval_set<DomainT,Compare,Interval,Alloc>::iterator
     split_interval_set<DomainT,Compare,Interval,Alloc>::add_(iterator prior_, const value_type& addend)
 {
- if(itl::is_empty(addend))
- return prior_;
-
- iterator insertion = this->_set.insert(prior_, addend);
-
- if(*insertion == addend)
- return insertion;
- else
- {
- std::pair<iterator,iterator> overlap = this->_set.equal_range(addend);
- iterator first_ = overlap.first,
- end_ = overlap.second,
- last_ = end_; --last_;
-
- iterator it_ = first_;
- interval_type rest_interval = addend;
-
- add_front(rest_interval, it_);
- add_main (rest_interval, it_, last_);
- add_rear (rest_interval, it_);
-
- return it_;
- }
-}
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline void split_interval_set<DomainT,Compare,Interval,Alloc>
- ::add_front(const interval_type& inter_val, iterator& first_)
-{
- // If the collision sequence has a left residual 'left_resid' it will
- // be split, to provide a standardized start of algorithms:
- // The addend interval 'inter_val' covers the beginning of the collision sequence.
-
- // only for the first there can be a left_resid: a part of *first_ left of inter_val
- interval_type left_resid = right_subtract(*first_, inter_val);
-
- if(!itl::is_empty(left_resid))
- { // [------------ . . .
- // [left_resid---first_ --- . . .
- iterator prior_ = this->prior(first_);
- const_cast<interval_type&>(*first_) = left_subtract(*first_, left_resid);
- //NOTE: Only splitting
- iterator insertion_ = this->_set.insert(prior_, left_resid);
- }
-
- //POST:
- // [----- inter_val ---- . . .
- // ...[-- first_ --...
-}
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline void split_interval_set<DomainT,Compare,Interval,Alloc>
- ::add_main(interval_type& x_rest, iterator& it_, const iterator& last_)
-{
- interval_type cur_interval;
- while(it_!=last_)
- {
- cur_interval = *it_ ;
- add_segment(x_rest, it_);
- // shrink interval
- x_rest = left_subtract(x_rest, cur_interval);
- }
+ return detail::splitting_add(*this, prior_, addend);
 }
 
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline void split_interval_set<DomainT,Compare,Interval,Alloc>
- ::add_segment(const interval_type& inter_val, iterator& it_)
-{
- interval_type lead_gap = right_subtract(inter_val, *it_);
- if(!itl::is_empty(lead_gap))
- // [lead_gap--- . . .
- // [prior_) [-- it_ ...
- this->_set.insert(prior(it_), lead_gap);
-
- // . . . --------- . . . addend interval
- // [-- it_ --) has a common part with the first overval
- ++it_;
-}
-
-
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline void split_interval_set<DomainT,Compare,Interval,Alloc>
- ::add_rear(const interval_type& inter_val, iterator& it_)
-{
- iterator prior_ = this->prior(it_);
- interval_type cur_itv = *it_;
-
- interval_type lead_gap = right_subtract(inter_val, cur_itv);
- if(!itl::is_empty(lead_gap))
- // [lead_gap--- . . .
- // [prior_) [-- it_ ...
- this->_set.insert(prior_, lead_gap);
-
- interval_type end_gap = left_subtract(inter_val, cur_itv);
- if(!itl::is_empty(end_gap))
- // [---------------end_gap)
- // [-- it_ --)
- it_ = this->_set.insert(it_, end_gap);
- else
- {
- // only for the last there can be a right_resid: a part of *it_ right of addend
- interval_type right_resid = left_subtract(cur_itv, inter_val);
-
- if(!itl::is_empty(right_resid))
- {
- // [--------------)
- // [-- it_ --right_resid)
- const_cast<interval_type&>(*it_) = right_subtract(*it_, right_resid);
- it_ = this->_set.insert(it_, right_resid);
- }
- }
-}
-
-
 template<class DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
 inline void split_interval_set<DomainT,Compare,Interval,Alloc>::subtract_(const value_type& minuend)
 {
- if(itl::is_empty(minuend)) return;
- iterator first_ = this->_set.lower_bound(minuend);
- if(first_==this->_set.end()) return;
- iterator end_ = this->_set.upper_bound(minuend);
- iterator second_= first_; ++second_;
- iterator last_ = end_; --last_;
-
- interval_type leftResid = right_subtract(*first_, minuend);
- interval_type rightResid;
- if(first_ != end_ )
- rightResid = left_subtract(*last_ , minuend);
-
- this->_set.erase(first_, end_ );
-
- if(!itl::is_empty(leftResid))
- this->_set.insert(leftResid);
-
- if(!itl::is_empty(rightResid))
- this->_set.insert(rightResid);
-}
-
-
-//==============================================================================
-//= Equivalences and Orderings
-//==============================================================================
-/** Equality on discrete interval sets. Discrete interval sets are equal, if
- their elements are equal and their fragmentation is equal.
- NOTE: This is not inline with the mathematical view.
- We have a distinction between 'element equality' and 'lexicographical
- equality'. */
-template <typename DomainT, ITL_COMPARE Compare, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
-inline bool operator == (const split_interval_set<DomainT,Compare,Interval,Alloc>& lhs,
- const split_interval_set<DomainT,Compare,Interval,Alloc>& rhs)
-{
- return Set::lexicographical_equal(lhs, rhs);
+ detail::subtract(*this, minuend);
 }
 
 //-----------------------------------------------------------------------------

Added: sandbox/itl/boost/itl/type_traits/is_assoc_element_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_assoc_element_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,32 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2008-2009: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_TYPE_TRAITS_IS_ASSOC_ELEMENT_CONTAINER_HPP_JOFA_100831
+#define BOOST_ITL_TYPE_TRAITS_IS_ASSOC_ELEMENT_CONTAINER_HPP_JOFA_100831
+
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/itl/type_traits/is_element_container.hpp>
+#include <boost/itl/type_traits/is_set.hpp>
+
+namespace boost{ namespace itl
+{
+ template <class Type>
+ struct is_assoc_element_container
+ {
+ typedef is_assoc_element_container type;
+ BOOST_STATIC_CONSTANT(bool, value =
+ (mpl::or_<is_element_set<Type>, is_element_map<Type> >::value));
+ };
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/type_traits/is_associative_element_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_associative_element_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,32 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2008-2009: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_TYPE_TRAITS_IS_ASSOCIATIVE_ELEMENT_CONTAINER_HPP_JOFA_100831
+#define BOOST_ITL_TYPE_TRAITS_IS_ASSOCIATIVE_ELEMENT_CONTAINER_HPP_JOFA_100831
+
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/itl/type_traits/is_element_container.hpp>
+#include <boost/itl/type_traits/is_set.hpp>
+
+namespace boost{ namespace itl
+{
+ template <class Type>
+ struct is_associative_element_container
+ {
+ typedef is_associative_element_container type;
+ BOOST_STATIC_CONSTANT(bool, value =
+ (mpl::or_<is_element_set<Type>, is_element_map<Type> >::value));
+ };
+
+
+}} // namespace boost itl
+
+#endif
+
+

Modified: sandbox/itl/boost/itl/type_traits/is_element_container.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_element_container.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_element_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -16,15 +16,6 @@
 
 namespace boost{ namespace itl
 {
- template <class Type>
- struct is_element_container
- {
- typedef is_element_container<Type> type;
- BOOST_STATIC_CONSTANT(bool, value =
- (mpl::and_<is_set<Type>, mpl::not_<is_interval_container<Type> > >::value)
- );
- };
-
     template<class Type>
     struct is_element_map
     {
@@ -34,7 +25,23 @@
             );
     };
 
+ template<class Type>
+ struct is_element_set
+ {
+ typedef is_element_set<Type> type;
+ BOOST_STATIC_CONSTANT(bool, value =
+ (mpl::and_<is_set<Type>, mpl::not_<is_interval_container<Type> > >::value)
+ );
+ };
 
+ template <class Type>
+ struct is_element_container
+ {
+ typedef is_element_container<Type> type;
+ BOOST_STATIC_CONSTANT(bool, value =
+ (mpl::or_<is_element_set<Type>, is_element_map<Type> >::value)
+ );
+ };
 }} // namespace boost itl
 
 #endif

Added: sandbox/itl/boost/itl/type_traits/is_icl_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_icl_container.hpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -0,0 +1,33 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_TYPE_TRAITS_IS_ICL_CONTAINER_HPP_JOFA_100831
+#define BOOST_ITL_TYPE_TRAITS_IS_ICL_CONTAINER_HPP_JOFA_100831
+
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/itl/type_traits/is_element_container.hpp>
+#include <boost/itl/type_traits/is_interval_container.hpp>
+#include <boost/itl/type_traits/is_set.hpp>
+
+namespace boost{ namespace itl
+{
+ template <class Type>
+ struct is_icl_container
+ {
+ typedef is_icl_container<Type> type;
+ BOOST_STATIC_CONSTANT(bool, value =
+ (mpl::or_< is_element_container<Type>
+ , is_interval_container<Type> >::value));
+ };
+
+}} // namespace boost itl
+
+#endif
+
+

Modified: sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp (original)
+++ sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp 2010-09-01 05:01:35 EDT (Wed, 01 Sep 2010)
@@ -27,6 +27,7 @@
 #include <boost/itl/detail/element_iterator.hpp>
 #include <boost/itl/type_traits/is_key_container_of.hpp>
 #include <boost/itl/type_traits/codomain_type_of.hpp>
+#include <boost/itl/type_traits/is_icl_container.hpp>
 
 
 #include <boost/itl_xt/detail/bit_element_iterator.hpp>
@@ -229,6 +230,7 @@
         BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII, has_codomain_type<MapII>::value >::type, itl::no_type>::value), false);
 
         BOOST_CHECK_EQUAL((is_map<MapII>::value), true);
+ BOOST_CHECK_EQUAL((is_icl_container<MapII>::value), true);
 
 
         //BOOST_CHECK_EQUAL(xx, true);


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