Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79799 - in sandbox/icl: boost/icl boost/icl/concept boost/icl/detail libs/icl/test/test_casual_
From: afojgo_at_[hidden]
Date: 2012-07-30 02:57:59


Author: jofaber
Date: 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
New Revision: 79799
URL: http://svn.boost.org/trac/boost/changeset/79799

Log:
interval_map concept. Trait class and add algorithm.
Added:
   sandbox/icl/boost/icl/_flat_interval_map.hpp (contents, props changed)
   sandbox/icl/boost/icl/_interval_map.hpp (contents, props changed)
   sandbox/icl/boost/icl/_interval_map_traits.hpp (contents, props changed)
Text files modified:
   sandbox/icl/boost/icl/concept/_interval_map.hpp | 124 +++++++++++++++------------------------
   sandbox/icl/boost/icl/detail/design_config.hpp | 3
   sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp | 48 +++++++++++---
   3 files changed, 87 insertions(+), 88 deletions(-)

Added: sandbox/icl/boost/icl/_flat_interval_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/icl/boost/icl/_flat_interval_map.hpp 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
@@ -0,0 +1,194 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2012-2012: 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_ICL__FLAT_INTERVAL_MAP_HPP_JOFA_120729
+#define BOOST_ICL__FLAT_INTERVAL_MAP_HPP_JOFA_120729
+
+#include <boost/icl/impl_config.hpp>
+
+#if defined(ICL_USE_BOOST_MOVE_IMPLEMENTATION)
+# include <boost/container/vector.hpp>
+#elif defined(ICL_USE_STD_IMPLEMENTATION)
+# include <vector>
+#else // Default for implementing containers
+# include <vector>
+#endif
+
+
+#include <boost/assert.hpp>
+#include <boost/icl/type_traits/is_map.hpp>
+#include <boost/icl/_interval_map_traits.hpp>
+#include <boost/icl/concept/_interval_map.hpp>
+
+namespace boost{namespace icl
+{
+
+/**JODO \brief implements a map as a map of intervals - on insertion
+ overlapping intervals are split and associated values are combined.*/
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits = icl::partial_absorber, //JODO ImplType could also be coded within Traits to enable a short notation for std cases.
+ ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT),
+ ICL_COMBINE Combine = ICL_COMBINE_INSTANCE(icl::inplace_plus, CodomainT),
+ ICL_SECTION Section = ICL_SECTION_INSTANCE(icl::inter_section, CodomainT),
+ ICL_INTERVAL(ICL_COMPARE) Interval = ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, DomainT, Compare)
+>
+class flat_interval_map //JODO private inheritace and using?
+{
+public:
+ typedef ICL_IMPL_SPACE::vector< std::pair<DomainT, CodomainT> > impl_type;
+ typedef _interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,impl_type> base_type;
+ typedef flat_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval> type;
+ typedef ICL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
+
+ typedef typename base_type::interpair_iterator interpair_iterator;
+ typedef typename base_type::interpair_const_iterator interpair_const_iterator;
+ typedef typename base_type::value_type value_type;
+ typedef typename DomainT element_type;
+ //JODO typedef typename base_type::segment_type segment_type;
+ typedef typename DomainT domain_type;
+ typedef typename base_type::value_type::second_type codomain_type;
+ //JODO typedef typename base_type::domain_mapping_type domain_mapping_type;
+ //JODO typedef typename base_type::interval_mapping_type interval_mapping_type;
+
+ //JODO typedef typename base_type::size_type size_type;
+ typedef typename Compare<DomainT> domain_compare;
+ typedef typename Combine<CodomainT> codomain_combine;
+
+ enum { fineness = 1 };
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+
+ /// Default constructor for the empty object
+ flat_interval_map(): m_data() {}
+
+ /// Copy constructor
+ flat_interval_map(const flat_interval_map& src): m_data(src.m_data) {}
+
+ /// Copy constructor for base_type
+ /*JODO
+ template<class SubType>
+ explicit _interval_map
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ { this->assign(src); }
+
+ explicit _interval_map(domain_mapping_type& base_pair): base_type()
+ { this->add(base_pair); }
+
+ explicit _interval_map(const value_type& value_pair): base_type()
+ { this->add(value_pair); }
+ */
+
+
+ /// Assignment operator
+ flat_interval_map& operator = (const flat_interval_map& src)
+ {
+ m_data = src.m_data;
+ return *this;
+ }
+
+ /*JODO
+ /// Assignment from a base _interval_map.
+ template<class SubType>
+ void assign(const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ {
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> base_map_type;
+ this->clear();
+ iterator prior_ = this->_map.end();
+ ICL_const_FORALL(typename base_map_type, it_, src)
+ prior_ = this->add(prior_, *it_);
+ }
+
+# ifndef BOOST_NO_RVALUE_REFERENCES
+ //==========================================================================
+ //= Move semantics
+ //==========================================================================
+
+ /// Move constructor
+ _interval_map(_interval_map&& src)
+ : base_type(boost::move(src))
+ {}
+
+ /// Move assignment operator
+ _interval_map& operator = (_interval_map&& src)
+ {
+ base_type::operator=(boost::move(src));
+ return *this;
+ }
+
+ //==========================================================================
+# endif // BOOST_NO_RVALUE_REFERENCES
+ */
+
+ interpair_iterator begin(){ return m_data.begin(); }
+ interpair_iterator end() { return m_data.end(); }
+ interpair_const_iterator begin()const{ return m_data.begin(); }
+ interpair_const_iterator end()const { return m_data.end(); }
+
+ //JODO insert -> into the traits. what about reserving memory for vectors?
+ interpair_iterator insert(interpair_const_iterator pos, const value_type& value)
+ { return m_data.insert(pos, value); }
+
+ //JODO This is temporary for testing.
+ std::pair<interpair_iterator,bool> insert(const value_type& value)
+ { return m_data.insert(value); }
+
+private:
+ base_type m_data;
+} ;
+
+//==============================================================================
+//=T flat_interval_map -> concept _interval_map
+//==============================================================================
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits,
+ ICL_COMPARE Compare,
+ ICL_COMBINE Combine,
+ ICL_SECTION Section,
+ ICL_INTERVAL(ICL_COMPARE) Interval
+>
+struct interval_map_traits
+ <
+ flat_interval_map< DomainT, CodomainT, Traits
+ , Compare, Combine, Section
+ , Interval >
+ >
+{
+ typedef interval_map_traits type;
+ typedef typename
+ flat_interval_map< DomainT, CodomainT, Traits
+ , Compare, Combine, Section
+ , Interval > model_type;
+
+ typedef ICL_IMPL_SPACE::vector< std::pair<DomainT, CodomainT> > impl_type;
+ typedef typename
+ _interval_map< DomainT, CodomainT, Traits
+ , Compare, Combine, Section
+ , Interval, impl_type > base_type;
+
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ ICL_INTERVAL_MAP_TRAIT_TYPES(base_type);
+ ICL_INTERVAL_MAP_TRAIT_FUNCTIONS(model_type);
+};
+
+
+}} // namespace icl boost
+
+#endif
+
+

Added: sandbox/icl/boost/icl/_interval_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/icl/boost/icl/_interval_map.hpp 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
@@ -0,0 +1,190 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2012-2012: 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_ICL__INTERVAL_MAP_HPP_JOFA_120728
+#define BOOST_ICL__INTERVAL_MAP_HPP_JOFA_120728
+
+#include <boost/icl/impl_config.hpp>
+
+#if defined(ICL_USE_BOOST_MOVE_IMPLEMENTATION)
+# include <boost/container/set.hpp>
+#elif defined(ICL_USE_STD_IMPLEMENTATION)
+# include <set>
+#else // Default for implementing containers
+# include <set>
+#endif
+
+
+#include <boost/assert.hpp>
+#include <boost/icl/type_traits/is_map.hpp>
+#include <boost/icl/_interval_map_traits.hpp>
+#include <boost/icl/concept/_interval_map.hpp>
+
+namespace boost{namespace icl
+{
+
+/** \brief implements a map as a map of intervals - on insertion
+ overlapping intervals are split and associated values are combined.*/
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits = icl::partial_absorber, //JODO ImplType could also be coded within Traits to enable a short notation for std cases.
+ ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT),
+ ICL_COMBINE Combine = ICL_COMBINE_INSTANCE(icl::inplace_plus, CodomainT),
+ ICL_SECTION Section = ICL_SECTION_INSTANCE(icl::inter_section, CodomainT),
+ ICL_INTERVAL(ICL_COMPARE) Interval = ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, DomainT, Compare),
+ ICL_IMPL_TYPE ImplT = ICL_IMPL_SPACE::map< DomainT, CodomainT >
+>
+class _interval_map
+{
+public:
+ typedef Traits traits;
+ typedef _interval_map type;
+ typedef ImplT impl_type;
+ typedef ICL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
+
+ typedef typename impl_type::iterator interpair_iterator;
+ typedef typename impl_type::const_iterator interpair_const_iterator;
+ typedef typename impl_type::value_type value_type;
+ typedef typename DomainT element_type;
+ //JODO typedef typename impl_type::segment_type segment_type;
+ typedef typename DomainT domain_type;
+ typedef typename impl_type::value_type::second_type codomain_type;
+ //JODO typedef typename impl_type::domain_mapping_type domain_mapping_type;
+ //JODO typedef typename impl_type::interval_mapping_type interval_mapping_type;
+
+ //JODO typedef typename impl_type::size_type size_type;
+ typedef typename Compare<DomainT> domain_compare;
+ typedef typename Combine<CodomainT> codomain_combine;
+
+ enum { fineness = 1 };
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+
+ /// Default constructor for the empty object
+ _interval_map(): m_data() {}
+
+ /// Copy constructor
+ _interval_map(const _interval_map& src): m_data(src.m_data) {}
+
+ /// Copy constructor for impl_type
+ /*JODO
+ template<class SubType>
+ explicit _interval_map
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ { this->assign(src); }
+
+ explicit _interval_map(domain_mapping_type& base_pair): impl_type()
+ { this->add(base_pair); }
+
+ explicit _interval_map(const value_type& value_pair): impl_type()
+ { this->add(value_pair); }
+ */
+
+
+ /// Assignment operator
+ _interval_map& operator = (const _interval_map& src)
+ {
+ m_data = src.m_data;
+ return *this;
+ }
+
+ /*JODO
+ /// Assignment from a base _interval_map.
+ template<class SubType>
+ void assign(const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ {
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> base_map_type;
+ this->clear();
+ iterator prior_ = this->_map.end();
+ ICL_const_FORALL(typename base_map_type, it_, src)
+ prior_ = this->add(prior_, *it_);
+ }
+
+# ifndef BOOST_NO_RVALUE_REFERENCES
+ //==========================================================================
+ //= Move semantics
+ //==========================================================================
+
+ /// Move constructor
+ _interval_map(_interval_map&& src)
+ : impl_type(boost::move(src))
+ {}
+
+ /// Move assignment operator
+ _interval_map& operator = (_interval_map&& src)
+ {
+ impl_type::operator=(boost::move(src));
+ return *this;
+ }
+
+ //==========================================================================
+# endif // BOOST_NO_RVALUE_REFERENCES
+ */
+
+ interpair_iterator begin(){ return m_data.begin(); }
+ interpair_iterator end() { return m_data.end(); }
+ interpair_const_iterator begin()const{ return m_data.begin(); }
+ interpair_const_iterator end()const { return m_data.end(); }
+
+ //JODO insert -> into the traits. what about reserving memory for vectors?
+ interpair_iterator insert(interpair_const_iterator pos, const value_type& value)
+ { return m_data.insert(pos, value); }
+
+ //JODO This is temporary for testing.
+ std::pair<interpair_iterator,bool> insert(const value_type& value)
+ { return m_data.insert(value); }
+
+private:
+ impl_type m_data;
+} ;
+
+//==============================================================================
+//=T _interval_map -> concept _interval_map
+//==============================================================================
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits,
+ ICL_COMPARE Compare,
+ ICL_COMBINE Combine,
+ ICL_SECTION Section,
+ ICL_INTERVAL(ICL_COMPARE) Interval,
+ ICL_IMPL_TYPE ImplT
+>
+struct interval_map_traits
+ <
+ _interval_map< DomainT, CodomainT, Traits
+ , Compare, Combine, Section
+ , Interval, ImplT >
+ >
+{
+ typedef interval_map_traits type;
+ typedef typename
+ _interval_map< DomainT, CodomainT, Traits
+ , Compare, Combine, Section
+ , Interval, ImplT > model_type;
+
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ ICL_INTERVAL_MAP_TRAIT_TYPES(model_type);
+ ICL_INTERVAL_MAP_TRAIT_FUNCTIONS(model_type);
+};
+
+
+}} // namespace icl boost
+
+#endif
+
+

Added: sandbox/icl/boost/icl/_interval_map_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/icl/boost/icl/_interval_map_traits.hpp 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
@@ -0,0 +1,67 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2012-2012: 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_ICL_CONCEPT__INTERVAL_MAP_TRAITS_HPP_JOFA_120728
+#define BOOST_ICL_CONCEPT__INTERVAL_MAP_TRAITS_HPP_JOFA_120728
+
+#include <iterator>
+#include <map>
+#include <boost/icl/functors.hpp>
+#include <boost/icl/_interval_map_traits.hpp>
+
+namespace boost{ namespace icl
+{
+
+template<class Model>
+struct interval_map_traits
+{
+ typedef interval_map_traits type;
+ typedef interval_map_traits concept_mapping;
+ typedef Model model_type;
+ typedef typename model_type::key_type domain_type;
+ typedef typename model_type::value_type::second_type codomain_type;
+ typedef typename model_type::key_compare domain_compare;
+ typedef typename model_type::codomain_combine codomain_combine;
+ typedef typename model_type::interpair_type interpair_type;
+ typedef typename model_type::iterator interpair_iterator;
+ typedef typename model_type::const_iterator interpair_const_iterator;
+
+ BOOST_STATIC_CONSTANT(bool, value = false);
+
+//conceptual private:
+ static interpair_iterator interpairs_begin (model_type&);
+ static interpair_iterator interpairs_end (model_type&);
+ static interpair_const_iterator interpairs_cbegin(const model_type&);
+ static interpair_const_iterator interpairs_cend (const model_type&);
+
+ static interpair_iterator insert(model_type&, interpair_iterator, const interpair_type&);
+};
+
+}} // namespace boost icl
+
+//#define ICL_REFINED_TYPE(base, type_name) typedef typename base::type_name type_name ;
+
+#define ICL_INTERVAL_MAP_TRAIT_TYPES(base_type)\
+ typedef typename base_type::domain_type domain_type;\
+ typedef typename base_type::codomain_type codomain_type;\
+ typedef typename base_type::domain_compare domain_compare;\
+ typedef typename base_type::codomain_combine codomain_combine;\
+ typedef typename base_type::value_type interpair_type;\
+ typedef typename base_type::interpair_iterator interpair_iterator;\
+ typedef typename base_type::interpair_const_iterator interpair_const_iterator;
+
+#define ICL_INTERVAL_MAP_TRAIT_FUNCTIONS(model_type)\
+ static interpair_iterator interpairs_begin (model_type& model) { return model.begin(); };\
+ static interpair_iterator interpairs_end (model_type& model) { return model.end(); };\
+ static interpair_const_iterator interpairs_cbegin(const model_type& model){ return model.begin(); };\
+ static interpair_const_iterator interpairs_cend (const model_type& model){ return model.end(); };\
+ static interpair_iterator insert(model_type& model, interpair_iterator position, const interpair_type& value)\
+ { return model.insert(position, value); }
+
+#endif //BOOST_ICL_CONCEPT__INTERVAL_MAP_TRAITS_HPP_JOFA_120728
+
+

Modified: sandbox/icl/boost/icl/concept/_interval_map.hpp
==============================================================================
--- sandbox/icl/boost/icl/concept/_interval_map.hpp (original)
+++ sandbox/icl/boost/icl/concept/_interval_map.hpp 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
@@ -8,76 +8,15 @@
 #ifndef BOOST_ICL_CONCEPT__INTERVAL_MAP_HPP_JOFA_120724
 #define BOOST_ICL_CONCEPT__INTERVAL_MAP_HPP_JOFA_120724
 
+#include <boost/utility/enable_if.hpp>
 #include <iterator>
 #include <map>
 #include <boost/icl/functors.hpp>
+#include <boost/icl/_interval_map_traits.hpp>
 
 namespace boost{ namespace icl
 {
 
-template<class Model>
-struct interval_map_traits
-{
- typedef interval_map_traits type;
- typedef interval_map_traits concept_mapping;
- typedef Model model_type;
- typedef typename model_type::key_type domain_type;
- typedef typename model_type::value_type::second_type codomain_type;
- typedef typename model_type::key_compare domain_compare;
- typedef typename model_type::iterator interpair_iterator;
- typedef typename model_type::const_iterator interpair_const_iterator;
-
- BOOST_STATIC_CONSTANT(bool, value = false);
-
- static interpair_iterator interpairs_begin (model_type&);
- static interpair_iterator interpairs_end (model_type&);
- static interpair_const_iterator interpairs_cbegin(const model_type&);
- static interpair_const_iterator interpairs_cend (const model_type&);
-};
-
-template<class DomainT, class CodomainT>
-struct interval_map_traits< std::map<DomainT, CodomainT> >
-{
- typedef interval_map_traits type;
- typedef interval_map_traits concept_mapping;
- typedef typename std::map<DomainT, CodomainT> model_type;
-
- typedef typename model_type::key_type domain_type;
- typedef typename model_type::value_type::second_type codomain_type;
- typedef typename model_type::key_compare domain_compare;
- typedef typename inplace_plus<codomain_type> codomain_combine;
- typedef typename model_type::iterator interpair_iterator;
- typedef typename model_type::const_iterator interpair_const_iterator;
-
- BOOST_STATIC_CONSTANT(bool, value = true);
-
- static interpair_iterator interpairs_begin (model_type& model) { return model.begin(); };
- static interpair_iterator interpairs_end (model_type& model) { return model.end(); };
- static interpair_const_iterator interpairs_cbegin(const model_type& model){ return model.begin(); };
- static interpair_const_iterator interpairs_cend (const model_type& model){ return model.end(); };
-};
-
-template<class DomainT, class CodomainT>
-struct interval_map_traits< std::vector<std::pair<DomainT, CodomainT> > >
-{
- typedef interval_map_traits type;
- typedef interval_map_traits concept_mapping;
- typedef typename std::vector<std::pair<DomainT, CodomainT> > model_type;
-
- typedef typename model_type::value_type::first_type domain_type;
- typedef typename model_type::value_type::second_type codomain_type;
- typedef typename std::less<domain_type> domain_compare;
- typedef typename inplace_plus<codomain_type> codomain_combine;
- typedef typename model_type::iterator interpair_iterator;
- typedef typename model_type::const_iterator interpair_const_iterator;
-
- BOOST_STATIC_CONSTANT(bool, value = true);
-
- static interpair_iterator interpairs_begin (model_type& model) { return model.begin(); };
- static interpair_iterator interpairs_end (model_type& model) { return model.end(); };
- static interpair_const_iterator interpairs_cbegin(const model_type& model){ return model.begin(); };
- static interpair_const_iterator interpairs_cend (const model_type& model){ return model.end(); };
-};
 
 template<class Type> //JODO different interval_map-Types
 bool domain_less_( typename interval_map_traits<Type>::interpair_const_iterator left
@@ -120,16 +59,36 @@
 }
 
 template<class Type>
-typename interval_map_traits<Type>::interpair_const_iterator
+typename interval_map_traits<Type>::interpair_iterator
+interpairs_begin( Type& object )
+{
+ return interval_map_traits<Type>::interpairs_begin(object);
+}
+
+template<class Type>
+typename interval_map_traits<Type>::interpair_iterator
 interpairs_end( Type& object )
 {
     return interval_map_traits<Type>::interpairs_end(object);
 }
 
 template<class Type>
-//typename enable_if<is_interval_map<Type>, Type>::type
-Type
-new_add(const Type& map1, const Type& map2)
+inline typename
+ enable_if< interval_map_traits<Type>
+ , typename interval_map_traits<Type>::interpair_iterator>::type
+insert( Type& object
+ , typename interval_map_traits<Type>::interpair_iterator position
+ , const typename interval_map_traits<Type>::interpair_type& value )
+{
+ return interval_map_traits<Type>::insert(object, position, value);
+}
+
+
+
+
+template<class Type>
+typename enable_if<interval_map_traits<Type>, Type>::type
+joining_add(const Type& map1, const Type& map2, bool join=true)
 {
     typedef typename interval_map_traits<Type>::type Concept;
     typedef typename Concept::codomain_type codomain_type;
@@ -148,10 +107,10 @@
     interpair_const_iterator it1_ = interpairs_cbegin(map1),
                               it2_ = interpairs_cbegin(map2),
                               pred1_, pred2_;
- interpair_iterator last_in_ = sum.begin();
+ interpair_iterator last_in_ = interpairs_begin(sum);
 
     codomain_type co_val = co_combine<Type>(it1_, it2_);
- last_in_ = sum.insert(interpairs_end(sum), make_pair((*it1_).first, co_val));
+ last_in_ = insert(sum, interpairs_end(sum), make_pair((*it1_).first, co_val));
     //JODO *sum_ = construct<interpair>(it1_, co_val);
     pred1_ = it1_++;
     pred2_ = it2_++;
@@ -161,7 +120,7 @@
         if( domain_less_<Type>(it1_,it2_) )
         {
             codomain_type co_val = co_combine<Type>(it1_, pred2_);
- if((*last_in_).second != co_val)
+ if(!join || (*last_in_).second != co_val)
                 last_in_ = sum.insert(interpairs_end(sum), make_pair((*it1_).first, co_val));
 
             pred1_ = it1_++;
@@ -169,7 +128,7 @@
         else if ( domain_less_<Type>(it2_,it1_) )
         {
             codomain_type co_val = co_combine<Type>(it2_, pred1_);
- if((*last_in_).second != co_val)
+ if(!join || (*last_in_).second != co_val)
                 last_in_ = sum.insert(interpairs_end(sum), make_pair((*it2_).first, co_val));
 
             pred2_ = it2_++;
@@ -177,7 +136,7 @@
         else //( domain_equal(it1_,it2_) )
         {
             codomain_type co_val = co_combine<Type>(it1_, it2_);
- if((*last_in_).second != co_val)
+ if(!join || (*last_in_).second != co_val)
                 last_in_ = sum.insert(interpairs_end(sum), make_pair((*it1_).first, co_val));
 
             pred1_ = it1_++;
@@ -188,7 +147,7 @@
     while(it1_ != interpairs_cend(map1))
     {
         codomain_type co_val = co_combine<Type>(it1_, pred2_);
- if((*last_in_).second != co_val)
+ if(!join || (*last_in_).second != co_val)
             last_in_ = sum.insert(interpairs_end(sum), make_pair((*it1_).first, co_val));
 
         pred1_ = it1_++;
@@ -196,7 +155,7 @@
     while(it2_ != interpairs_cend(map2))
     {
         codomain_type co_val = co_combine<Type>(it2_, pred1_);
- if((*last_in_).second != co_val)
+ if(!join || (*last_in_).second != co_val)
             last_in_ = sum.insert(interpairs_end(sum), make_pair((*it2_).first, co_val));
 
         pred2_ = it2_++;
@@ -205,10 +164,23 @@
     return sum;
 }
 
+/*CONTINUE
+template<class Type>
+typename enable_if<interval_map_traits<Type>, Type>::type
+add_interval( const Type& map1
+ , const typename Type::segment_type& segment
+ , bool join=true)
+{
+ Type sum;
+ sum.insert(sum.end(), make_pair(0, 0));
+ sum.insert(sum.end(), make_pair(inter_val.lower(), 0));
+}
+*/
+
 template<class Type>
 void new_show(const Type& object)
 {
- typedef typename interval_map_traits<Type>::type Concept;
+ typedef typename interval_map_traits<Type>::type Concept;
     typedef typename Concept::domain_type domain_type;
     typedef typename Concept::codomain_type codomain_type;
     typedef typename Concept::interpair_iterator interpair_iterator;
@@ -229,7 +201,7 @@
 template<class Type>
 void raw_show(const Type& object)
 {
- typedef typename interval_map_traits<Type>::type Concept;
+ typedef typename interval_map_traits<Type>::type Concept;
     typedef typename Concept::domain_type domain_type;
     typedef typename Concept::codomain_type codomain_type;
     typedef typename Concept::interpair_iterator interpair_iterator;

Modified: sandbox/icl/boost/icl/detail/design_config.hpp
==============================================================================
--- sandbox/icl/boost/icl/detail/design_config.hpp (original)
+++ sandbox/icl/boost/icl/detail/design_config.hpp 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
@@ -98,6 +98,9 @@
 #define ICL_ALLOC template<class>class
 
 //------------------------------------------------------------------------------
+#define ICL_IMPL_TYPE class
+
+//------------------------------------------------------------------------------
 #define ICL_INTERVAL_DEFAULT boost::icl::interval_type_default
 
 #ifndef BOOST_ICL_USE_COMPARE_STD_GREATER

Modified: sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp (original)
+++ sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp 2012-07-30 02:57:56 EDT (Mon, 30 Jul 2012)
@@ -32,7 +32,8 @@
 #include <boost/icl/interval_set.hpp>
 #include <boost/icl/interval.hpp>
 
-#include <boost/icl/concept/_interval_map.hpp>
+#include <boost/icl/_interval_map.hpp>
+#include <boost/icl/_flat_interval_map.hpp>
 
 using namespace std;
 using namespace boost;
@@ -46,22 +47,22 @@
 {
     typedef int T;
     typedef int U;
- typedef interval_map<T,U, partial_absorber> IntervalMapT;
- typedef interval_set<T> IntervalSetT;
- typedef IntervalMapT::interval_type IntervalT;
- typedef IntervalSetT::iterator SetIterT;
+ typedef _interval_map<T,U, partial_absorber> IntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef IntervalMapT::interval_type IntervalT;
+ typedef IntervalSetT::iterator SetIterT;
 
     IntervalSetT is = IntervalSetT(I_I(1,1)) + IntervalSetT(I_I(3,3));
     cout << is << endl;
 
- std::map<int,int> m1;
+ IntervalMapT m1;
     m1.insert(make_pair(0, 1));
     m1.insert(make_pair(6, 2));
- std::map<int,int> m2;
+ IntervalMapT m2;
     m2.insert(make_pair(0, 1));
     m2.insert(make_pair(4, 3));
 
- std::map<int,int> m3 = new_add(m1, m2);
+ IntervalMapT m3 = joining_add(m1, m2);
 
     new_show(m3);
 
@@ -71,17 +72,40 @@
 BOOST_AUTO_TEST_CASE(interval_map_via_vector)
 {
     typedef std::pair<int,int> PairT;
- typedef std::vector<PairT> IntervalMapT;
+ typedef _interval_map<int,int, icl::partial_absorber
+ , std::less,inplace_plus,inplace_plus
+ , right_open_interval<int,std::less>
+ , std::vector<std::pair<int,int> > > FlatIntervalMapT;
 
- IntervalMapT m1;
+ FlatIntervalMapT m1;
     m1.insert(m1.end(), make_pair(0, 1));
     m1.insert(m1.end(), make_pair(6, 2));
- IntervalMapT m2;
+ FlatIntervalMapT m2;
     m2.insert(m2.end(), make_pair(0, 1));
     m2.insert(m2.end(), make_pair(4, 3));
 
- IntervalMapT m3 = new_add(m1, m2);
+ FlatIntervalMapT m3 = joining_add(m1, m2);
 
     new_show(m3);
 }
 
+
+BOOST_AUTO_TEST_CASE(interval_map_via_vector2)
+{
+ typedef std::pair<int,int> PairT;
+ typedef flat_interval_map<int,int> FlatIntervalMapT;
+
+ FlatIntervalMapT m1;
+ m1.insert(m1.end(), make_pair(0, 1));
+ m1.insert(m1.end(), make_pair(6, 2));
+ FlatIntervalMapT m2;
+ m2.insert(m2.end(), make_pair(0, 1));
+ m2.insert(m2.end(), make_pair(4, 3));
+
+ FlatIntervalMapT m3 = joining_add(m1, m2);
+
+ new_show(m3);
+}
+
+
+


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