Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65335 - in sandbox/itl/boost/itl: . detail
From: afojgo_at_[hidden]
Date: 2010-09-07 12:33:14


Author: jofaber
Date: 2010-09-07 12:33:09 EDT (Tue, 07 Sep 2010)
New Revision: 65335
URL: http://svn.boost.org/trac/boost/changeset/65335

Log:
Refactoring: Extraction of member functions from interval_map and split_interval_map complete. Stable{msvc-9.0, gcc-3.4.4}
Text files modified:
   sandbox/itl/boost/itl/detail/interval_map_algo.hpp | 323 ++++++++++++++++++++++++++++++++++++---
   sandbox/itl/boost/itl/interval_base_map.hpp | 43 -----
   sandbox/itl/boost/itl/interval_map.hpp | 144 -----------------
   sandbox/itl/boost/itl/split_interval_map.hpp | 134 ---------------
   4 files changed, 308 insertions(+), 336 deletions(-)

Modified: sandbox/itl/boost/itl/detail/interval_map_algo.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/interval_map_algo.hpp (original)
+++ sandbox/itl/boost/itl/detail/interval_map_algo.hpp 2010-09-07 12:33:09 EDT (Tue, 07 Sep 2010)
@@ -182,14 +182,84 @@
     return object._insert(prior_, value_type(inter_val, version<Combiner>()(co_val)));
 }
 
+template <class Type, class Combiner>
+inline typename Type::iterator
+_map_insert( Type& object,
+ typename Type::iterator prior_,
+ const typename Type::interval_type& inter_val,
+ const typename Type::codomain_type& co_val)
+{
+ typedef typename Type::value_type value_type;
 
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-template<class Type, int absorbs_neutrons>
+ return object._insert(prior_, value_type(inter_val, version<Combiner>()(co_val)));
+}
+
+template <class Type, class Combiner>
+inline std::pair<typename Type::iterator, bool>
+_map_insert( Type& object,
+ const typename Type::interval_type& inter_val,
+ const typename Type::codomain_type& co_val)
+{
+ typedef typename Type::value_type value_type;
+
+ return object._insert(value_type(inter_val, version<Combiner>()(co_val)));
+}
+
+template<class Type, class Combiner, int absorbs_neutrons>
 struct on_neutric;
 
-template<class Type>
-struct on_neutric<Type, false>
+template <class Type, class Combiner>
+inline std::pair<typename Type::iterator, bool>
+informing_add( Type& object,
+ const typename Type::iterator& prior_,
+ const typename Type::interval_type& inter_val,
+ const typename Type::codomain_type& co_val )
+{
+ typedef typename Type::value_type value_type;
+ typedef typename Type::iterator iterator;
+ typedef typename on_neutric<Type,Combiner,
+ absorbs_neutrons<Type>::value>::type on_neutric_;
+
+ // Never try to insert a neutron into a neutron absorber here:
+ BOOST_ASSERT(!(on_neutric_::is_absorbable(co_val)));
+
+ iterator inserted_
+ = object._insert(prior_, value_type(inter_val, Combiner::neutron()));
+
+ if(inserted_->first == inter_val && inserted_->second == Combiner::neutron())
+ {
+ Combiner()(inserted_->second, co_val);
+ return std::pair<iterator,bool>(inserted_, true);
+ }
+ else
+ return std::pair<iterator,bool>(inserted_, false);
+}
+
+template <class Type>
+inline std::pair<typename Type::iterator, bool>
+informing_insert( Type& object,
+ const typename Type::iterator& prior_,
+ const typename Type::interval_type& inter_val,
+ const typename Type::codomain_type& co_val )
+{
+ typedef typename Type::value_type value_type;
+ typedef typename Type::iterator iterator;
+
+ iterator inserted_
+ = object._insert(prior_, value_type(inter_val, co_val));
+
+ if(inserted_ == prior_)
+ return std::pair<iterator,bool>(inserted_, false);
+ else if(inserted_->first == inter_val)
+ return std::pair<iterator,bool>(inserted_, true);
+ else
+ return std::pair<iterator,bool>(inserted_, false);
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+template<class Type, class Combiner>
+struct on_neutric<Type, Combiner, false>
 {
     typedef on_neutric type;
     typedef typename Type::codomain_type codomain_type;
@@ -197,8 +267,8 @@
     static bool is_absorbable(const codomain_type&){ return false; }
 };
 
-template<class Type>
-struct on_neutric<Type, true>
+template<class Type, class Combiner>
+struct on_neutric<Type, Combiner, true>
 {
     typedef on_neutric type;
     typedef typename Type::codomain_type codomain_type;
@@ -207,7 +277,7 @@
     static bool is_absorbable(const codomain_type& co_value)
     {
         return absorbs_neutrons<Type>::value
- && co_value == codomain_combine::neutron();
+ && co_value == Combiner::neutron();
     }
 };
 
@@ -221,8 +291,9 @@
 {
     typedef on_style type;
     typedef typename Type::iterator iterator;
- static void handle_inserted(Type&, iterator, iterator&){}
- static iterator handle_end_inserted(Type&, iterator it_){ return it_; }
+
+ static iterator handle_inserted(Type&, iterator it_){ return it_; }
+ static void handle_inserted(Type&, iterator, iterator&) {}
 };
 
 template<class Type>
@@ -231,18 +302,17 @@
     typedef on_style type;
     typedef typename Type::iterator iterator;
 
+ static iterator handle_inserted(Type& object, iterator it_)
+ {
+ return join_neighbours(object, it_);
+ }
+
     static void handle_inserted(Type& object, iterator inserted_, iterator& it_)
     {
         join_left(object, inserted_);
         // after filling that gap there may be another joining opportunity
         join_left(object, it_);
     }
-
- static iterator handle_end_inserted(Type& object, iterator inserted_)
- {
- return join_neighbours(object, inserted_);
- }
-
 };
 
 
@@ -450,7 +520,7 @@
 //------------------------------------------------------------------------------
 
 //==============================================================================
-//= Addition
+//= Addition detail
 //==============================================================================
 
 template<class Type, class Combiner>
@@ -568,7 +638,98 @@
 }
 
 //==============================================================================
-//= Subtract
+//= Addition
+//==============================================================================
+template<class Type, class Combiner>
+typename Type::iterator add( Type& object,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+ typedef typename Type::codomain_type codomain_type;
+ typedef typename Type::iterator iterator;
+ typedef typename on_style<Type,Type::fineness>::type on_style_;
+ typedef typename on_neutric<Type,Combiner,
+ absorbs_neutrons<Type>::value>::type on_neutric_;
+
+ const interval_type& inter_val = addend.first;
+ if(itl::is_empty(inter_val))
+ return object.end();
+
+ const codomain_type& co_val = addend.second;
+ if(on_neutric_::is_absorbable(co_val))
+ return object.end();
+
+ std::pair<iterator,bool> insertion
+ = _map_insert<Type,Combiner>(object, inter_val, co_val);
+
+ if(insertion.second)
+ return on_style_::handle_inserted(object, insertion.first);
+ else
+ {
+ // Detect the first and the end iterator of the collision sequence
+ iterator first_ = object.lower_bound(inter_val),
+ last_ = insertion.first;
+ //assert(end_ == this->_map.upper_bound(inter_val));
+
+ iterator it_ = first_;
+ interval_type rest_interval = inter_val;
+
+ Interval_Set::add_front (object, rest_interval, it_ );
+ Interval_Map::add_main<Type,Combiner>(object, rest_interval, co_val, it_, last_);
+ Interval_Map::add_rear<Type,Combiner>(object, rest_interval, co_val, it_ );
+ return it_;
+ }
+}
+
+
+template<class Type, class Combiner>
+typename Type::iterator add( Type& object,
+ typename Type::iterator prior_,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+ typedef typename Type::codomain_type codomain_type;
+ typedef typename Type::iterator iterator;
+ typedef typename on_style<Type,Type::fineness>::type on_style_;
+ typedef typename on_neutric<Type,Combiner,
+ absorbs_neutrons<Type>::value>::type on_neutric_;
+
+ const interval_type& inter_val = addend.first;
+ if(itl::is_empty(inter_val))
+ return prior_;
+
+ const codomain_type& co_val = addend.second;
+ if(on_neutric_::is_absorbable(co_val))
+ return prior_;
+
+ std::pair<iterator,bool> insertion
+ = informing_add<Type,Combiner>(object,prior_, inter_val, co_val);
+
+ if(insertion.second)
+ return on_style_::handle_inserted(object, insertion.first);
+ else
+ {
+ // Detect the first and the end iterator of the collision sequence
+ std::pair<iterator,iterator> overlap = object.equal_range(inter_val);
+ iterator it_ = overlap.first,
+ last_ = overlap.second;
+ --last_;
+ interval_type rest_interval = inter_val;
+
+ Interval_Set::add_front (object, rest_interval, it_ );
+ Interval_Map::add_main<Type,Combiner>(object, rest_interval, co_val, it_, last_);
+ Interval_Map::add_rear<Type,Combiner>(object, rest_interval, co_val, it_ );
+
+ return it_;
+ }
+}
+
+
+
+//==============================================================================
+//= Subtract detail
 //==============================================================================
 
 template<class Type>
@@ -587,8 +748,8 @@
         iterator prior_ = object.prior(it_);
         const_cast<interval_type&>(it_->first) = left_subtract(it_->first, left_resid);
         object._insert(prior_, value_type(left_resid, it_->second));
- // The segemnt *it_ is split at inter_val.first(), so as an invariant
- // segment *it_ is always "under" inter_val and a left_resid is empty.
+ // The segemnt *it_ is split at inter_val.first(), so as an invariant
+ // segment *it_ is always "under" inter_val and a left_resid is empty.
     }
 }
 
@@ -640,6 +801,41 @@
 }
 
 //==============================================================================
+//= Subtract
+//==============================================================================
+template<class Type, class Combiner>
+void subtract( Type& object,
+ const typename Type::value_type& minuend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+ typedef typename Type::codomain_type codomain_type;
+ typedef typename Type::iterator iterator;
+ typedef typename on_style<Type,Type::fineness>::type on_style_;
+ typedef typename on_neutric<Type,Combiner,
+ absorbs_neutrons<Type>::value>::type on_neutric_;
+
+ interval_type inter_val = minuend.first;
+ if(itl::is_empty(inter_val))
+ return;
+
+ const codomain_type& co_val = minuend.second;
+ if(on_neutric_::is_absorbable(co_val))
+ return;
+
+ std::pair<iterator, iterator> exterior = object.equal_range(inter_val);
+ if(exterior.first == exterior.second)
+ return;
+
+ iterator last_ = prior(exterior.second);
+ iterator it_ = exterior.first;
+ Interval_Map::subtract_front<Type> (object, inter_val, it_ );
+ Interval_Map::subtract_main <Type,Combiner>(object, co_val, it_, last_);
+ Interval_Map::subtract_rear <Type,Combiner>(object, inter_val, co_val, it_ );
+}
+
+
+//==============================================================================
 //= Insertion
 //==============================================================================
 
@@ -671,8 +867,6 @@
         {
             inserted_ = object._insert(prior_, value_type(left_gap, co_val));
             on_style_::handle_inserted(object, inserted_, it_);
-
-
         }
 
         // shrink interval
@@ -685,14 +879,91 @@
     interval_type end_gap = left_subtract(rest_interval, last_interval);
     if(!itl::is_empty(end_gap))
     {
- inserted_ = object._insert(prior_, value_type(end_gap, co_val));
- it_ = on_style_::handle_end_inserted(object, inserted_);
+ inserted_ = object._insert(prior_, value_type(end_gap, co_val));
+ it_ = on_style_::handle_inserted(object, inserted_);
     }
     else
         it_ = prior_;
 }
 
 
+
+template<class Type>
+typename Type::iterator insert( Type& object,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::codomain_type codomain_type;
+ typedef typename Type::iterator iterator;
+ typedef typename Type::codomain_combine codomain_combine;
+ typedef typename on_style<Type,Type::fineness>::type on_style_;
+ typedef typename on_neutric<Type, codomain_combine,
+ absorbs_neutrons<Type>::value>::type on_neutric_;
+
+ interval_type inter_val = addend.first;
+ if(itl::is_empty(inter_val))
+ return object.end();
+
+ const codomain_type& co_val = addend.second;
+ if(on_neutric_::is_absorbable(co_val))
+ return object.end();
+
+ std::pair<iterator,bool> insertion = object._insert(addend);
+
+ if(insertion.second)
+ return on_style_::handle_inserted(object, insertion.first);
+ else
+ {
+ // Detect the first and the end iterator of the collision sequence
+ iterator first_ = object.lower_bound(inter_val),
+ last_ = insertion.first;
+ //assert((++last_) == this->_map.upper_bound(inter_val));
+ iterator it_ = first_;
+ Interval_Map::insert_main(object, inter_val, co_val, it_, last_);
+ return it_;
+ }
+}
+
+
+template<class Type>
+typename Type::iterator insert( Type& object,
+ typename Type::iterator prior_,
+ const typename Type::value_type& addend)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::codomain_type codomain_type;
+ typedef typename Type::iterator iterator;
+ typedef typename Type::codomain_combine codomain_combine;
+ typedef typename on_style<Type,Type::fineness>::type on_style_;
+ typedef typename on_neutric<Type, codomain_combine,
+ absorbs_neutrons<Type>::value>::type on_neutric_;
+
+ interval_type inter_val = addend.first;
+ if(itl::is_empty(inter_val))
+ return prior_;
+
+ const codomain_type& co_val = addend.second;
+ if(on_neutric_::is_absorbable(co_val))
+ return prior_;
+
+ std::pair<iterator,bool> insertion
+ = informing_insert(object, prior_, inter_val, co_val);
+
+ if(insertion.second)
+ return on_style_::handle_inserted(object, insertion.first);
+ {
+ // Detect the first and the end iterator of the collision sequence
+ std::pair<iterator,iterator> overlap = object.equal_range(inter_val);
+ iterator it_ = overlap.first,
+ last_ = prior(overlap.second);
+ Interval_Map::insert_main(object, inter_val, co_val, it_, last_);
+ return it_;
+ }
+}
+
+
+
+
 //==============================================================================
 //= Erasure
 //==============================================================================
@@ -704,7 +975,9 @@
     typedef typename Type::codomain_type codomain_type;
     typedef typename Type::value_type value_type;
     typedef typename Type::iterator iterator;
- typedef typename on_neutric<Type,absorbs_neutrons<Type>::value>::type
+ typedef typename on_neutric<Type,
+ typename Type::codomain_combine,
+ absorbs_neutrons<Type>::value>::type
                                          on_neutric_;
 
     interval_type inter_val = minuend.first;

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-07 12:33:09 EDT (Tue, 07 Sep 2010)
@@ -860,54 +860,11 @@
     return Interval_Map::contains(*this, sub_segment);
 }
 
-//CL JODO unify
-//{
-// interval_type sub_interval = sub_segment.first;
-// if(itl::is_empty(sub_interval))
-// return true;
-//
-// std::pair<const_iterator, const_iterator> exterior = equal_range(sub_interval);
-// if(exterior.first == exterior.second)
-// return false;
-//
-// const_iterator last_overlap = prior(exterior.second);
-//
-// if(!(sub_segment.second == exterior.first->second) )
-// return false;
-//
-// return
-// itl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
-// && Interval_Map::is_joinable(*this, exterior.first, last_overlap);
-//}
-
-
 
 //==============================================================================
 //= Size
 //==============================================================================
 
-/*CL
-template
-<
- class SubType, class DomainT, class CodomainT, class Traits,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section,
- ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc
->
-typename interval_base_map<SubType,DomainT,CodomainT,Traits,
- Compare,Combine,Section,Interval,Alloc>::size_type
-interval_base_map<SubType,DomainT,CodomainT,Traits,
- Compare,Combine,Section,Interval,Alloc>::cardinality()const
-{
- using namespace boost::mpl;
- return if_<
- bool_<is_continuous<DomainT>::value>,
- continuous_interval_container,
- discrete_interval_container
- >
- ::type::cardinality(*this);
-}
-*/
-
 template
 <
     class SubType, class DomainT, class CodomainT, class Traits,

Modified: sandbox/itl/boost/itl/interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_map.hpp 2010-09-07 12:33:09 EDT (Tue, 07 Sep 2010)
@@ -138,26 +138,6 @@
     void insert_(const value_type& value);
     iterator insert_(iterator prior_, const value_type& value);
     void erase_(const value_type& value);
-
-private:
- bool insertable(const value_type& value)const
- {
- return !empty(value.first)
- && !(Traits::absorbs_neutrons && value.second == codomain_combine::neutron());
- }
-
- template<class Combiner>
- void subtract_main(const CodomainT& co_val, iterator& it_, iterator& end_ );
-
- void subtract_front(const interval_type& inter_val, const CodomainT& co_val, iterator& it_);
-
- template<class Combiner>
- void subtract_rear(const interval_type& inter_val, const CodomainT& co_val, iterator& it_);
-
- void insert_range(const interval_type& inter_val, const CodomainT& co_val, iterator& it_, iterator& end_ );
-
- void erase_rest(const interval_type& inter_val, const CodomainT& co_val, iterator& it_, iterator& last_);
-
 } ;
 
 
@@ -169,33 +149,7 @@
 inline void interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::add_(const value_type& addend)
 {
- const interval_type& inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==Combiner::neutron())
- return;
-
- std::pair<iterator,bool> insertion
- = this->template _map_insert<Combiner>(inter_val, co_val);
-
- if(insertion.second)
- segmental::join_neighbours(*this, insertion.first);
- else
- {
- // Detect the first and the end iterator of the collision sequence
- iterator first_ = this->_map.lower_bound(inter_val),
- last_ = insertion.first;
- //assert(end_ == this->_map.upper_bound(inter_val));
-
- iterator it_ = first_;
- interval_type rest_interval = inter_val;
-
- Interval_Set::add_front (*this, rest_interval, it_ );
- Interval_Map::add_main<type,Combiner>(*this, rest_interval, co_val, it_, last_);
- Interval_Map::add_rear<type,Combiner>(*this, rest_interval, co_val, it_ );
- }
+ Interval_Map::add<type,Combiner>(*this, addend);
 }
 
 
@@ -205,34 +159,7 @@
     interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::add_(iterator prior_, const value_type& addend)
 {
- const interval_type& inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return prior_;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==Combiner::neutron())
- return prior_;
-
- std::pair<iterator,bool> insertion
- = this->template _map_add<Combiner>(prior_, inter_val, co_val);
-
- if(insertion.second)
- return segmental::join_neighbours(*this, insertion.first);
- else
- {
- // Detect the first and the end iterator of the collision sequence
- std::pair<iterator,iterator> overlap = this->_map.equal_range(inter_val);
- iterator it_ = overlap.first,
- last_ = overlap.second;
- --last_;
- interval_type rest_interval = inter_val;
-
- Interval_Set::add_front (*this, rest_interval, it_ );
- Interval_Map::add_main<type,Combiner>(*this, rest_interval, co_val, it_, last_);
- Interval_Map::add_rear<type,Combiner>(*this, rest_interval, co_val, it_ );
-
- return it_;
- }
+ return Interval_Map::add<type,Combiner>(*this, prior_, addend);
 }
 
 
@@ -244,27 +171,7 @@
 void interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::subtract_(const value_type& minuend)
 {
- interval_type inter_val = minuend.first;
-
- if(itl::is_empty(inter_val))
- return;
-
- const CodomainT& co_val = minuend.second;
- if(Traits::absorbs_neutrons && co_val==Combiner::neutron())
- return;
-
- iterator first_ = this->_map.lower_bound(inter_val);
- if(first_==this->_map.end())
- return;
- iterator end_ = this->_map.upper_bound(inter_val);
- if(first_==end_ )
- return;
-
- iterator last_ = end_; --last_;
- iterator it_ = first_;
- Interval_Map::subtract_front<type> (*this, inter_val, it_ );
- Interval_Map::subtract_main <type,Combiner>(*this, co_val, it_, last_);
- Interval_Map::subtract_rear <type,Combiner>(*this, inter_val, co_val, it_ );
+ Interval_Map::subtract<type,Combiner>(*this, minuend);
 }
 
 
@@ -276,27 +183,7 @@
 void interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::insert_(const value_type& addend)
 {
- interval_type inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==codomain_combine::neutron())
- return;
-
- std::pair<iterator,bool> insertion = this->_map.insert(addend);
-
- if(insertion.second)
- segmental::join_neighbours(*this, insertion.first);
- else
- {
- // Detect the first and the end iterator of the collision sequence
- iterator first_ = this->_map.lower_bound(inter_val),
- last_ = insertion.first;
- //assert((++last_) == this->_map.upper_bound(inter_val));
- iterator it_ = first_;
- Interval_Map::insert_main(*this, inter_val, co_val, it_, last_);
- }
+ Interval_Map::insert(*this, addend);
 }
 
 template <typename DomainT, typename CodomainT, class Traits,
@@ -305,28 +192,7 @@
     interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::insert_(iterator prior_, const value_type& addend)
 {
- interval_type inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return prior_;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==codomain_combine::neutron())
- return prior_;
-
- std::pair<iterator,bool> insertion
- = this->template _map_insert<codomain_combine>(prior_, inter_val, co_val);
-
- if(insertion.second)
- return segmental::join_neighbours(*this, insertion.first);
- {
- // Detect the first and the end iterator of the collision sequence
- std::pair<iterator,iterator> overlap = this->_map.equal_range(inter_val);
- iterator it_ = overlap.first,
- last_ = overlap.second;
- --last_;
- Interval_Map::insert_main(*this, inter_val, co_val, it_, last_);
- return it_;
- }
+ return Interval_Map::insert(*this, prior_, addend);
 }
 
 //-----------------------------------------------------------------------------

Modified: sandbox/itl/boost/itl/split_interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/split_interval_map.hpp (original)
+++ sandbox/itl/boost/itl/split_interval_map.hpp 2010-09-07 12:33:09 EDT (Tue, 07 Sep 2010)
@@ -134,20 +134,6 @@
     void insert_(const value_type& value);
     iterator insert_(iterator, const value_type& value);
     void erase_(const value_type& value);
-
-private:
- void handle_neighbours(const iterator& it_){}
-
- template<class Combiner>
- void subtract_main(const CodomainT& co_val, iterator& it_, iterator& end_ );
-
- void subtract_front(const interval_type& inter_val, iterator& it_);
-
- template<class Combiner>
- void subtract_rear(const interval_type& inter_val, const CodomainT& co_val, iterator& it_);
-
- void insert_range(const interval_type& inter_val, const CodomainT& co_val, iterator& it_, iterator& end_ );
- void erase_rest(const interval_type& inter_val, const CodomainT& co_val, iterator& it_, iterator& last_);
 } ;
 
 //-----------------------------------------------------------------------------
@@ -158,31 +144,7 @@
 inline void split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::add_(const value_type& addend)
 {
- interval_type inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==Combiner::neutron())
- return;
-
- std::pair<iterator,bool> insertion
- = this->template _map_insert<Combiner>(inter_val, co_val);
-
- if(!insertion.second)
- {
- // Detect the first and the end iterator of the collision sequence
- iterator first_ = this->_map.lower_bound(inter_val),
- last_ = insertion.first;
- //assert(end_ == this->_map.upper_bound(inter_val));
-
- iterator it_ = first_;
- interval_type rest_interval = inter_val;
-
- Interval_Set::add_front<type> (*this, rest_interval, it_);
- Interval_Map::add_main <type,Combiner>(*this, rest_interval, co_val, it_, last_);
- Interval_Map::add_rear <type,Combiner>(*this, rest_interval, co_val, it_);
- }
+ Interval_Map::add<type,Combiner>(*this, addend);
 }
 
 template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_INTERVAL(ITL_COMPARE) Interval, ITL_ALLOC Alloc>
@@ -191,34 +153,7 @@
     split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::add_(iterator prior_, const value_type& addend)
 {
- interval_type inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return prior_;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==Combiner::neutron())
- return prior_;
-
- std::pair<iterator,bool> insertion
- = this->template _map_add<Combiner>(prior_, inter_val, co_val);
-
- if(insertion.second)
- return insertion.first;
- else
- {
- // Detect the first and the end iterator of the collision sequence
- std::pair<iterator,iterator> overlap = this->_map.equal_range(inter_val);
- iterator it_ = overlap.first,
- last_ = overlap.second;
- --last_;
- interval_type rest_interval = inter_val;
-
- Interval_Set::add_front<type> (*this, rest_interval, it_);
- Interval_Map::add_main <type,Combiner>(*this, rest_interval, co_val, it_, last_);
- Interval_Map::add_rear <type,Combiner>(*this, rest_interval, co_val, it_);
-
- return it_;
- }
+ return Interval_Map::add<type,Combiner>(*this, addend);
 }
 
 
@@ -230,27 +165,7 @@
 inline void split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::subtract_(const value_type& minuend)
 {
- interval_type inter_val = minuend.first;
-
- if(itl::is_empty(inter_val))
- return;
-
- const CodomainT& co_val = minuend.second;
- if(Traits::absorbs_neutrons && co_val==Combiner::neutron())
- return;
-
- iterator first_ = this->_map.lower_bound(inter_val);
- if(first_==this->_map.end())
- return;
- iterator end_ = this->_map.upper_bound(inter_val);
- if(first_==end_ )
- return;
-
- iterator last_ = end_; --last_;
- iterator it_ = first_;
- Interval_Map::subtract_front<type> (*this, inter_val, it_ );
- Interval_Map::subtract_main <type,Combiner>(*this, co_val, it_, last_);
- Interval_Map::subtract_rear <type,Combiner>(*this, inter_val, co_val, it_ );
+ Interval_Map::subtract<type,Combiner>(*this, minuend);
 }
 
 //-----------------------------------------------------------------------------
@@ -261,25 +176,7 @@
 void split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::insert_(const value_type& addend)
 {
- interval_type inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==codomain_combine::neutron())
- return;
-
- std::pair<iterator,bool> insertion = this->_map.insert(addend);
-
- if(!insertion.second)
- {
- // Detect the first and the end iterator of the collision sequence
- iterator first_ = this->_map.lower_bound(inter_val),
- last_ = insertion.first;
- //assert((++last_) == this->_map.upper_bound(inter_val));
- iterator it_ = first_;
- Interval_Map::insert_main(*this, inter_val, co_val, it_, last_);
- }
+ Interval_Map::insert(*this, addend);
 }
 
 template <typename DomainT, typename CodomainT, class Traits,
@@ -288,28 +185,7 @@
     split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
     ::insert_(iterator prior_, const value_type& addend)
 {
- interval_type inter_val = addend.first;
- if(itl::is_empty(inter_val))
- return prior_;
-
- const CodomainT& co_val = addend.second;
- if(Traits::absorbs_neutrons && co_val==codomain_combine::neutron())
- return prior_;
-
- std::pair<iterator,bool> insertion
- = this->template _map_insert<codomain_combine>(prior_, inter_val, co_val);
-
- if(insertion.second)
- return insertion.first;
- {
- // Detect the first and the end iterator of the collision sequence
- std::pair<iterator,iterator> overlap = this->_map.equal_range(inter_val);
- iterator it_ = overlap.first,
- last_ = overlap.second;
- --last_;
- Interval_Map::insert_main(*this, inter_val, co_val, it_, last_);
- return it_;
- }
+ return Interval_Map::insert(*this, prior_, addend);
 }
 
 //-----------------------------------------------------------------------------


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