Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51196 - sandbox/itl/boost/itl
From: afojgo_at_[hidden]
Date: 2009-02-11 07:58:43


Author: jofaber
Date: 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
New Revision: 51196
URL: http://svn.boost.org/trac/boost/changeset/51196

Log:
Reviewed Documentation. Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/interval.hpp | 84 +-
   sandbox/itl/boost/itl/interval_base_map.hpp | 252 ++----
   sandbox/itl/boost/itl/interval_base_set.hpp | 108 +-
   sandbox/itl/boost/itl/interval_map.hpp | 9
   sandbox/itl/boost/itl/interval_maps.hpp | 417 +++++-----
   sandbox/itl/boost/itl/interval_set.hpp | 11
   sandbox/itl/boost/itl/interval_sets.hpp | 100 +-
   sandbox/itl/boost/itl/map.hpp | 1437 +++++++++++++++++++--------------------
   sandbox/itl/boost/itl/separate_interval_set.hpp | 11
   sandbox/itl/boost/itl/set.hpp | 1003 +++++++++++++-------------
   sandbox/itl/boost/itl/split_interval_map.hpp | 431 ++++++-----
   sandbox/itl/boost/itl/split_interval_set.hpp | 663 +++++++++---------
   12 files changed, 2228 insertions(+), 2298 deletions(-)

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -36,7 +36,7 @@
 #undef min
 #undef max
 
-#define BOUND_VAL first
+#define BOUND_VALUE first
 #define BOUND_TYPES second
 
 namespace boost{namespace itl
@@ -329,6 +329,10 @@
     /// The size type of an interval which is mostly std::size_t
     typedef typename itl::size<DomainT>::type size_type;
 
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
     /** Default constructor; yields an empty interval <tt>[1,0]</tt> */
     interval() : _lwb(unon<DomainT>::value()), _upb(neutron<DomainT>::value()),
                          _boundtype(itl::closed_bounded) {}
@@ -361,6 +365,38 @@
 
     //NOTE: Compiler generated assignment operator = used
 
+ //==========================================================================
+ //= Emptieness, containmnet
+ //==========================================================================
+ /** Is the interval empty? */
+ bool empty()const;
+
+ /** Does the interval contain <tt>x</tt>? */
+ bool contains(const DomainT& x)const;
+ /** <tt>*this</tt> is subset of <tt>super</tt> */
+ bool contained_in(const interval& super)const ;
+ /** <tt>*this</tt> is superset of <tt>sub</tt> */
+ bool contains(const interval& sub)const;
+
+ /** <tt>*this</tt> and <tt>x2</tt> are disjoint; their intersection is empty */
+ bool is_disjoint(const interval& x2)const
+ { return exclusive_less(x2) || x2.exclusive_less(*this); }
+
+ //==========================================================================
+ //= Size
+ //==========================================================================
+ /** Cardinality of the interval: The number of elements */
+ size_type cardinality()const;
+
+ /** Arithmetic size of the interval */
+ difference_type length()const;
+
+ /** Size of the interval */
+ size_type size()const { return cardinality(); }
+
+ //==========================================================================
+ //= Range
+ //==========================================================================
     /** Lower bound of the interval */
     DomainT lower()const { return _lwb; }
     /** Upper bound of the interval */
@@ -368,10 +404,6 @@
     /** Typ of interval bounds */
     bound_type boundtype()const { return _boundtype; }
 
- /** Is the interval empty? */
- bool empty()const;
- /** Does the interval contain <tt>x</tt>? */
- bool contains(const DomainT& x)const;
 
         /** What type is the interval?
 \code
@@ -408,14 +440,6 @@
         }
 
 
- /** <tt>*this</tt> is subset of <tt>super</tt> */
- bool contained_in(const interval& super)const ;
- /** <tt>*this</tt> is superset of <tt>sub</tt> */
- bool contains(const interval& sub)const;
-
- /** <tt>*this</tt> and <tt>x2</tt> are disjoint; their intersection is empty */
- bool is_disjoint(const interval& x2)const
- { return exclusive_less(x2) || x2.exclusive_less(*this); }
     /** There is no gap between <tt>*this</tt> and <tt>x2</tt> but they have no element in common */
     bool touches(const interval& x2)const;
 
@@ -500,15 +524,6 @@
     /** Last (largest) element of the interval */
     DomainT last()const;
 
- /** Cardinality of the interval: The number of elements */
- size_type cardinality()const;
-
- /** Arithmetic size of the interval */
- difference_type length()const;
-
- /** Size of the interval */
- size_type size()const { return cardinality(); }
-
     /** Transforms the interval to the bound-type <tt>bounded</tt> without
         changing it's content. Requires Integral<domain_type>.
 \code
@@ -572,8 +587,8 @@
 
     bound_type succession_bounds()const;
 
- void set_lwb(const BoundT& lw) { _lwb=lw.BOUND_VAL; set_lwb_type(lw.BOUND_TYPES); }
- void set_upb(const BoundT& up) { _upb=up.BOUND_VAL; set_upb_type(up.BOUND_TYPES); }
+ void set_lwb(const BoundT& lw) { _lwb=lw.BOUND_VALUE; set_lwb_type(lw.BOUND_TYPES); }
+ void set_upb(const BoundT& up) { _upb=up.BOUND_VALUE; set_upb_type(up.BOUND_TYPES); }
 
     BoundT lwb_min(const interval& x2)const;
     BoundT lwb_max(const interval& x2)const;
@@ -1082,7 +1097,9 @@
         return *this;
 }
 
-
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
 /** Equality on intervals */
 template <class DomainT, ITL_COMPARE Compare>
 inline bool operator == (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
@@ -1114,23 +1131,8 @@
 inline bool operator >= (const interval<DomainT,Compare>& lhs, const interval<DomainT,Compare>& rhs)
 { return !(lhs < rhs); }
 
-/// Comparison functor on intervals implementing an overlap free less
-/**
- <b>Template-Klasse exclusive_less: Comparison Functor for Intervals</b>
 
- Template parameter <b>IntervalType</b>: needs to implement the boolean function
-
- <tt>bool IntervalType::exclusive_less(IntervalType x2)const; </tt>
-
- <b>exclusive_less</b> implements a strict weak ordering that serves to
- sort sets and maps of intervals interval_set, split_interval_set and
- split_interval_map.
-
- Function <tt>bool IntervalType::exclusive_less(IntervalType x2)const; </tt> is true if every
- element of the interval <tt>*this</tt> is less than any element of <tt>x2</tt>
-
- @author Joachim Faulhaber
-*/
+/// Comparison functor on intervals implementing an overlap free less
 template <class IntervalType>
 struct exclusive_less {
     /** Operator <tt>operator()</tt> implements a strict weak ordering on intervals. */

Modified: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -1,36 +1,12 @@
-/*----------------------------------------------------------------------------+
-Copyright (c) 2007-2008: Joachim Faulhaber
-+-----------------------------------------------------------------------------+
+/*-----------------------------------------------------------------------------+
+Author: Joachim Faulhaber
+Copyright (c) 2007-2009: Joachim Faulhaber
 Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
-+-----------------------------------------------------------------------------+
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-+----------------------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
-class interval_base_map
---------------------------------------------------------------------*/
++------------------------------------------------------------------------------+
+ 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 __interval_base_map_h_JOFA_990223__
 #define __interval_base_map_h_JOFA_990223__
 
@@ -68,72 +44,7 @@
 
 
 
-/// Implements a map as a map of intervals (abstract base class)
-/**
- class template <b>interval_base_map</b>
- implements a map as a map of intervals
-
- Template parameter <b>DomainT</b>: Domain type of the map. Also type of the
- map's keys.
-
- Suitable as domain types are all datatypes that posess a strict weak order.
- In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
- atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
-
- Template parameter <b>CodomainT</b>: The map's codomain type or data type: Type
- of associated values contained in the map.
-
- Datatypes for the codomain parameter have to <b>implement</b> operations
- <tt>+=</tt>, <tt>-=</tt>, <tt>==</tt> (equality) and <tt>CodomainT()</tt> (default constructor).
-
- The default constructor <tt>CodomainT()</tt> has to contruct a neutral element
- such that the following holds:
-
- If <tt>x = y; y += CodomainT();</tt> then <tt>x==y;</tt> and
- If <tt>x = y; y -= CodomainT();</tt> then <tt>x==y;</tt>
-
- Template parameter <b>Interval=itl::interval</b>: Type of interval template used
- to implement the set. The default <b>itl::interval</b> uses the
- interval class that comes with this library. Own implementation of interval
- classes are possible (but not trivial).
-
- <b>interval_base_map</b> implements a map <tt>map<DomainT, CodomainT></tt> as a map
- of intervals <tt>map<interval<DomainT>, CodomainT, exclusive_less<interval_type> ></tt>
-
- Interval maps <tt>interval_base_map<DomainT,CodomainT></tt> can be used similar (and in many
- aspects exactly like) common stl-maps. Unlike to stl-maps where you store
- a value for every key an interval map stores a contents value for an interval of
- keys. In it's degenerated form the key intervals contain a single element
- only. Then the interval map works like a normal stl-map. But if you work in problem
- domains where you associate values to large contiguous intervals, interval maps
- are very useful and efficient.
-
- <b>Class <tt>interval_base_map</tt> yields the following benefits: </b>
-
- <ul>
- <li> A set of intervals is conceived as the domain set of the map.
- The complexity involved with
- operations on intervals maps is encapsulated. The user of the class who
- wants to perform operations on interval maps is no more concerned
- with questions of overlapping, joining and bordering intervals.
- <li>
- <b>interval_base_map</b> gives an efficient implementation of maps consisting
- of larger contiguous chunks. Very large, even uncountably infinite maps
- can be represented in a compact way and handled efficiently.
- </ul>
-
- <b>Restrictions: </b>
-
- A small number of functions can only be used for <b>discrete</b> domain datatypes
- (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
-
- These functions are tagged in the documentation. Using such functions
- for continuous domain datatypes yields compiletime errors. C.f. getting
- the <tt>first()</tt> element of a left open interval makes sense for intervals of
- int but not for intervals of double.
-
- @author Joachim Faulhaber
-*/
+/// Implements a map as a map of intervals (base class)
 template
 <
     class SubType,
@@ -152,45 +63,58 @@
 class interval_base_map
 {
 public:
-
-/** @name A: Type definitions for the template class
-*/
-//@{
- typedef Traits traits;
- typedef SubType sub_type;
-
+ //==========================================================================
+ //= Associated types
+ //==========================================================================
     typedef interval_base_map<SubType,DomainT,CodomainT,
                               Traits,Compare,Combine,Section,Interval,Alloc>
                               type;
 
- typedef interval_base_map<SubType,DomainT,CodomainT,
- itl::partial_absorber,Compare,Combine,Section,Interval,Alloc>
- partial_absorber_type;
+ /// The designated \e derived or \e sub_type of this base class
+ typedef SubType sub_type;
 
+ /// Auxilliary type for overloadresolution
         typedef type overloadable_type;
 
+ /// Traits of an itl map
+ typedef Traits traits;
+
+ //--------------------------------------------------------------------------
+ //- Associated types: Related types
+ //--------------------------------------------------------------------------
+ /// The atomized type representing the corresponding container of elements
+ typedef typename itl::map<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Alloc> atomized_type;
+
+ //--------------------------------------------------------------------------
+ //- Associated types: Data
+ //--------------------------------------------------------------------------
     /// Domain type (type of the keys) of the map
     typedef DomainT domain_type;
     /// Domain type (type of the keys) of the map
     typedef CodomainT codomain_type;
- /// basic value type
- typedef std::pair<domain_type,codomain_type> mapping_type; //JODO
     /// Auxiliary type to help the compiler resolve ambiguities when using std::make_pair
     typedef mapping_pair<domain_type,codomain_type> domain_mapping_type;
         /// Conceptual is a map a set of elements of type \c element_type
     typedef domain_mapping_type element_type;
     /// The interval type of the map
     typedef Interval<DomainT,Compare> interval_type;
-
+ /// Auxiliary type for overload resolution
         typedef std::pair<interval_type,CodomainT> interval_mapping_type;
+ /// Type of an interval containers segment, that is spanned by an interval
         typedef std::pair<interval_type,CodomainT> segment_type;
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Size
+ //--------------------------------------------------------------------------
     /// The difference type of an interval which is sometimes different form the domain_type
     typedef typename interval_type::difference_type difference_type;
-
     /// The size type of an interval which is mostly std::size_t
     typedef typename interval_type::size_type size_type;
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Functors
+ //--------------------------------------------------------------------------
     /// Comparison functor for domain values
     typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
     /// Combine functor for codomain value aggregation
@@ -208,6 +132,9 @@
     /// Comparison functor for keys
     typedef exclusive_less<interval_type> key_compare;
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Implementation and stl related
+ //--------------------------------------------------------------------------
     /// The allocator type of the set
     typedef Alloc<std::pair<const interval_type, codomain_type> >
         allocator_type;
@@ -231,15 +158,6 @@
     typedef typename ImplMapT::reverse_iterator reverse_iterator;
     /// const_iterator for iteration over intervals
     typedef typename ImplMapT::const_reverse_iterator const_reverse_iterator;
-
-
- // Corresponding abstract interval set type
- //typedef interval_base_set<SetSubType,DomainT,Compare,Interval,Alloc> interval_base_set_type;
-
- /// The atomized type is elementbased map that is equivalent to the interval map
- typedef typename itl::map<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Alloc> atomized_type;
-//@}
         
 public:
     inline static bool has_symmetric_difference()
@@ -248,10 +166,10 @@
         enum{ is_itl_container = true };
 
 public:
-/** @name B: Constructors, destructors, assignment
-*/
-//@{
- /// Default constructor for the empty map
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
     interval_base_map(){}
 
     /// Copy constructor
@@ -266,25 +184,18 @@
 
     /// swap the content of containers
     void swap(interval_base_map& x) { _map.swap(x._map); }
-//@}
 
-/** @name C: Basic container functions */
-//@{
+ //==========================================================================
+ //= Emptieness, containmnet
+ //==========================================================================
+
     /// clear the map
     void clear() { _map.clear(); }
 
     /// is the map empty?
     bool empty()const { return _map.empty(); }
 
- //--- find --------------------------------------------------------------------
- /// Find the interval value pair, that contains element \c x
- const_iterator find(const DomainT& x)const
- {
- typename ImplMapT::const_iterator it = _map.find(interval_type(x));
- return it;
- }
-
- //--- contains: set view ------------------------------------------------------
+ //--- contains: set view ---------------------------------------------------
     /// Does the map contain the key element \c x
     bool contains(const DomainT& x)const
     {
@@ -310,18 +221,10 @@
         {
                 return Interval_Set::is_contained_in(*this, super);
         }
-//@}
 
-
-/** @name E: Bounds and other selectors */
-//@{
- /// Lower bound of the first interval
- DomainT lower()const
- { return empty()? interval_type().lower() : (*(_map.begin())).KEY_VALUE.lower(); }
-
- /// Upper bound of the last interval
- DomainT upper()const
- { return empty()? interval_type().upper() : (*(_map.rbegin())).KEY_VALUE.upper(); }
+ //==========================================================================
+ //= Size
+ //==========================================================================
 
     /// Number of intervals which is also the size of the iteration over the map
     size_t interval_count()const { return _map.size(); }
@@ -337,8 +240,39 @@
     /// The length of the interval map which is the sum of interval lenghts
     difference_type length()const;
 
-//@}
-
+ //==========================================================================
+ //= Range
+ //==========================================================================
+
+ /// Lower bound of the first interval
+ DomainT lower()const
+ { return empty()? interval_type().lower() : (*(_map.begin())).KEY_VALUE.lower(); }
+
+ /// Upper bound of the last interval
+ DomainT upper()const
+ { return empty()? interval_type().upper() : (*(_map.rbegin())).KEY_VALUE.upper(); }
+
+ //==========================================================================
+ //= Selection
+ //==========================================================================
+
+ //--- find -----------------------------------------------------------------
+ /// Find the interval value pair, that contains element \c x
+ const_iterator find(const domain_type& key_value)const
+ {
+ const_iterator it = _map.find(interval_type(key_value));
+ return it;
+ }
+
+ /** Total select function. */
+ codomain_type operator()(const domain_type& key_value)const
+ {
+ const_iterator it = _map.find(interval_type(key_value));
+ if(it==end())
+ return neutron<codomain_type>::value();
+ else
+ return it->CONT_VALUE;
+ }
 
 
 //-----------------------------------------------------------------------------
@@ -747,15 +681,6 @@
             erase_if(content_is_neutron<value_type>());
     }
 
- /// Copies this map into a partial_absorber type.
- /** \c x is a copy of \c *this as a neutron_aborber.
- A neutron absorber is a map that does not store neutral elements
- (<tt>neutron() == codomain_type()</tt>)
- as associated values.
- */
- void as_neutron_absorber(partial_absorber_type& x)const
- { FOR_IMPLMAP(it) x.add(*it); }
-
     /// Join bounding intervals
     interval_base_map& join();
             
@@ -1351,12 +1276,9 @@
     return *that();
 }
 
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-// itl::global function templates
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
 //-----------------------------------------------------------------------------
 // equality
 //-----------------------------------------------------------------------------

Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -1,36 +1,12 @@
-/*----------------------------------------------------------------------------+
-Copyright (c) 2007-2008: Joachim Faulhaber
-+-----------------------------------------------------------------------------+
+/*-----------------------------------------------------------------------------+
+Author: Joachim Faulhaber
+Copyright (c) 2007-2009: Joachim Faulhaber
 Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
-+-----------------------------------------------------------------------------+
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-+----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------+
-class interval_base_set
-+----------------------------------------------------------------------------*/
++------------------------------------------------------------------------------+
+ 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 __interval_base_set_h_JOFA_990223__
 #define __interval_base_set_h_JOFA_990223__
 
@@ -112,15 +88,26 @@
 class interval_base_set
 {
 public:
-
- //A: Type definitions for the template class
+ //==========================================================================
+ //= Associated types
+ //==========================================================================
     typedef interval_base_set<SubType,DomainT,Compare,Interval,Alloc> type;
 
     /// The designated \e derived or \e sub_type of this base class
     typedef SubType sub_type;
 
+ /// Auxilliary type for overloadresolution
         typedef type overloadable_type;
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Related types
+ //--------------------------------------------------------------------------
+ /// The atomized type representing the corresponding container of elements
+ typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
+
+ //--------------------------------------------------------------------------
+ //- Associated types: Data
+ //--------------------------------------------------------------------------
     /// The domain type of the set
     typedef DomainT domain_type;
     /// The codomaintype is the same as domain_type
@@ -134,6 +121,9 @@
     /// The segment type of the set
     typedef interval_type segment_type;
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Size
+ //--------------------------------------------------------------------------
     /// The difference type of an interval which is sometimes different form the data_type
     typedef typename interval_type::difference_type difference_type;
 
@@ -141,6 +131,9 @@
     typedef typename interval_type::size_type size_type;
 
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Order
+ //--------------------------------------------------------------------------
     /// Comparison functor for domain values
     typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
     /// Comparison functor for intervals
@@ -149,18 +142,15 @@
     /// Comparison functor for keys
     typedef exclusive_less<interval_type> key_compare;
 
+ //--------------------------------------------------------------------------
+ //- Associated types: Implementation and stl related
+ //--------------------------------------------------------------------------
     /// The allocator type of the set
     typedef Alloc<interval_type> allocator_type;
 
     /// allocator type of the corresponding element set
     typedef Alloc<DomainT> domain_allocator_type;
 
- /// The type of the set of elements that is equivalent to the set of intervals
- typedef typename itl::set<DomainT,Compare,Alloc> element_set;
-
- /// The corresponding atomized type representing this interval container of elements
- typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
-
     /// Container type for the implementation
     typedef typename itl::set<interval_type,ITL_EXCLUSIVE_LESS(interval_type),Alloc> ImplSetT;
 
@@ -180,10 +170,14 @@
     /// const_iterator for iteration over intervals
     typedef typename ImplSetT::const_reverse_iterator const_reverse_iterator;
 
+
 public:
- // B: Constructors, destructors, assignment
- /// Default constructor for the empty set
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
     interval_base_set(){}
+
     /// Copy constructor
     interval_base_set(const interval_base_set& src): _set()
     { that()->assign(src); }
@@ -197,22 +191,15 @@
 
     void swap(interval_base_set& x) { _set.swap(x._set); }
 
- // ------------------------------------------------------------------------
- // Basic set concept
- // C:
+ //==========================================================================
+ //= Emptieness, containmnet
+ //==========================================================================
 
     /// sets the container empty
     void clear() { _set.clear(); }
     /// is the container empty
     bool empty()const { return _set.empty(); }
 
- /// Find the interval value pair, that contains element \c x
- const_iterator find(const DomainT& x)const
- {
- typename ImplSetT::const_iterator it = this->_map.find(interval_type(x));
- return it;
- }
-
     /// Does the container contain the element \c x
     bool contains(const DomainT& x)const
         { return that()->contains_(interval_type(x)); }
@@ -246,6 +233,16 @@
                 return Interval_Set::is_contained_in(*this, super);
         }
 
+
+
+ /// Find the interval value pair, that contains element \c x
+ const_iterator find(const DomainT& x)const
+ {
+ typename ImplSetT::const_iterator it = this->_map.find(interval_type(x));
+ return it;
+ }
+
+
 /** @name E: Bounds and other selectors
     */
 //@{
@@ -451,6 +448,10 @@
     */
     DomainT last()const { return (*(_set.rbegin())).last(); } // JODO NONCONT
 
+ //==========================================================================
+ //= Size
+ //==========================================================================
+
     /** Number of elements in the set (cardinality).
         Infinite for continuous domain datatyps */
     size_type cardinality()const;
@@ -758,6 +759,9 @@
 }
 
 
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
 template<class SubType,
          class DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
 inline bool operator == (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& lhs,

Modified: sandbox/itl/boost/itl/interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_map.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -132,9 +132,6 @@
     typedef interval_base_map <interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
                                DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> base_type;
 
- typedef interval_map<DomainT,CodomainT,itl::partial_absorber,Compare,Combine,Section,Interval,Alloc>
- partial_absorber_type;
-
     typedef Interval<DomainT,Compare> interval_type;
     typedef typename base_type::iterator iterator;
     typedef typename base_type::value_type value_type;
@@ -151,7 +148,11 @@
 
         enum { fineness = 1 };
 
- /// Default constructor for the empty map
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
     interval_map(): base_type() {}
     /// Copy constructor
     interval_map(const interval_map& src): base_type(src) {}

Modified: sandbox/itl/boost/itl/interval_maps.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_maps.hpp (original)
+++ sandbox/itl/boost/itl/interval_maps.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -23,161 +23,192 @@
 class interval_map;
 
 
-//-----------------------------------------------------------------------------
-// addition +=
-//-----------------------------------------------------------------------------
+//==============================================================================
+//= Emptieness, containmnet
+//==============================================================================
 template
 <
- class ObjectT,
     class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template
- <
+ <
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
- class IntervalMap
+ class LeftIntervalMap,
+ template
+ <
+ class, class, class,
+ ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
+ >
+ class RightIntervalMap
>
-ObjectT& operator +=
+bool is_contained_in
 (
- ObjectT& object,
- const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand
+ const LeftIntervalMap <DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& left,
+ const RightIntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& right
 )
 {
- typedef IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
- const_FORALL(typename operand_type, elem_, operand)
- object.add(*elem_);
-
- return object;
+ return Interval_Set::is_contained_in(left, right);
 }
 
-//-----------------------------------------------------------------------------
-// subtraction -=
-//-----------------------------------------------------------------------------
 template
 <
- class ObjectT,
     class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template
- <
+ <
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
- class IntervalMap
+ class LeftIntervalMap,
+ template
+ <
+ class, class, class,
+ ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
+ >
+ class RightIntervalMap
>
-ObjectT& operator -=
+bool contains
 (
- ObjectT& object,
- const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand
+ const LeftIntervalMap <DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& left,
+ const RightIntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& right
 )
 {
- typedef IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
- const_FORALL(typename operand_type, elem_, operand)
- object.subtract(*elem_);
-
- return object;
+ return Interval_Set::contains(left, right);
 }
 
 //-----------------------------------------------------------------------------
-// symmetric difference ^=
+// is_disjoint
 //-----------------------------------------------------------------------------
+
+//--- IntervalMap -------------------------------------------------------------
 template
 <
- class ObjectT,
- class DomainT, class CodomainT, class Traits,
+ class SubType, class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template
- <
+ <
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
     class IntervalMap
>
-ObjectT& operator ^=
+//JODO boost::enable_if
+bool is_disjoint
 (
- ObjectT& object,
- const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& object,
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& operand
 )
 {
- return object.flip(operand);
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> object_type;
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
+ object_type intersection;
+
+ if(operand.empty())
+ return true;
+
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return true;
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ {
+ object.add_intersection(intersection, (it++)->KEY_VALUE);
+ if(!intersection.empty())
+ return false;
+ }
+
+ return true;
 }
 
-//-----------------------------------------------------------------------------
-// erasure -= of elements given by an interval_set
-//-----------------------------------------------------------------------------
+//--- IntervalSet -------------------------------------------------------------
 template
 <
- class ObjectT,
- class DomainT, class CodomainT, class Traits,
+ class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ template
+ <
+ class, class, class,
+ ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
+ >
+ class IntervalMap,
     template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
>
-ObjectT&
-operator -=
+//JODO boost::enable_if
+bool is_disjoint
 (
- ObjectT& object,
- const IntervalSet<DomainT,Compare,Interval,Alloc>& erasure
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& object,
+ const IntervalSet<DomainT,Compare,Interval,Alloc>& operand
 )
 {
- typedef IntervalSet<DomainT,Compare,Interval,Alloc> set_type;
- const_FORALL(typename set_type, interval_, erasure)
- object.erase(*interval_);
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> object_type;
+ typedef IntervalSet<DomainT,Compare,Interval,Alloc> operand_type;
+ object_type intersection;
 
- return object;
-}
+ if(operand.empty())
+ return true;
 
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
 
-//-----------------------------------------------------------------------------
-// insert
-//-----------------------------------------------------------------------------
-template
-<
- class SubType, class DomainT, class CodomainT, class Traits,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- class OperandT
->
-interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>&
-insert
-(
- interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& object,
- const OperandT& operand
-)
-{
- const_FORALL(typename OperandT, elem_, operand)
- object.insert(*elem_);
- return object;
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return true;
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ {
+ object.add_intersection(intersection, *it++);
+ if(!intersection.empty())
+ return false;
+ }
+
+ return true;
 }
 
-//-----------------------------------------------------------------------------
-// erase
-//-----------------------------------------------------------------------------
 template
 <
- class SubType, class DomainT, class CodomainT, class Traits,
+ class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- class OperandT
+ template
+ <
+ class, class, class,
+ ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
+ >
+ class IntervalMap,
+ template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
>
-interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>&
-erase
+//JODO boost::enable_if
+bool is_disjoint
 (
- interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& object,
- const OperandT& operand
+ const IntervalSet<DomainT,Compare,Interval,Alloc>& left,
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& right
 )
 {
- const_FORALL(typename OperandT, elem_, operand)
- object.erase(*elem_);
- return object;
+ return is_disjoint(right, left);
 }
 
 
-//-----------------------------------------------------------------------------
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+//------------------------------------------------------------------------------
 // is_element_equal
-//-----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 template
 <
     class DomainT, class CodomainT, class Traits,
@@ -262,9 +293,9 @@
     return Interval_Set::is_element_greater(left, right);
 }
 
-//-----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 // is_inclusion_equal
-//-----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
 template
 <
     class DomainT, class CodomainT, class Traits,
@@ -293,6 +324,9 @@
     return Interval_Set::is_inclusion_equal(left, right);
 }
 
+//-----------------------------------------------------------------------------
+// is_protonic_equal
+//-----------------------------------------------------------------------------
 template
 <
     class DomainT, class CodomainT, class Traits,
@@ -302,197 +336,170 @@
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
- class LeftIntervalMap,
- template
- <
- class, class, class,
- ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
- >
- class RightIntervalMap
+ class IntervalMap
>
-bool is_contained_in
+bool is_protonic_equal
 (
- const LeftIntervalMap <DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& left,
- const RightIntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& right
+ const IntervalMap <DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& left,
+ const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& right
 )
 {
- return Interval_Set::is_contained_in(left, right);
+ return Map::lexicographical_protonic_equal(left, right);
 }
 
+//-----------------------------------------------------------------------------
+// addition +=
+//-----------------------------------------------------------------------------
 template
 <
+ class ObjectT,
     class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template
- <
- class, class, class,
- ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
- >
- class LeftIntervalMap,
- template
- <
+ <
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
- class RightIntervalMap
+ class IntervalMap
>
-bool contains
+ObjectT& operator +=
 (
- const LeftIntervalMap <DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& left,
- const RightIntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& right
+ ObjectT& object,
+ const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand
 )
 {
- return Interval_Set::contains(left, right);
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
+ object.add(*elem_);
+
+ return object;
 }
 
 //-----------------------------------------------------------------------------
-// is_protonic_equal
+// subtraction -=
 //-----------------------------------------------------------------------------
 template
 <
+ class ObjectT,
     class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template
- <
+ <
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
     class IntervalMap
>
-bool is_protonic_equal
+ObjectT& operator -=
 (
- const IntervalMap <DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& left,
- const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& right
+ ObjectT& object,
+ const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand
 )
 {
- return Map::lexicographical_protonic_equal(left, right);
-}
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
+ object.subtract(*elem_);
 
+ return object;
+}
 
 //-----------------------------------------------------------------------------
-// is_disjoint
+// symmetric difference ^=
 //-----------------------------------------------------------------------------
-
-//--- IntervalMap -------------------------------------------------------------
 template
 <
- class SubType, class DomainT, class CodomainT, class Traits,
+ class ObjectT,
+ class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template
- <
+ <
         class, class, class,
         ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
>
     class IntervalMap
>
-//JODO boost::enable_if
-bool is_disjoint
+ObjectT& operator ^=
 (
- interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& object,
- const IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& operand
+ ObjectT& object,
+ const IntervalMap<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>& operand
 )
 {
- typedef interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc> object_type;
- typedef IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc> operand_type;
- object_type intersection;
-
- if(operand.empty())
- return true;
-
- typename operand_type::const_iterator common_lwb;
- typename operand_type::const_iterator common_upb;
-
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return true;
-
- typename operand_type::const_iterator it = common_lwb;
- while(it != common_upb)
- {
- object.add_intersection(intersection, (it++)->KEY_VALUE);
- if(!intersection.empty())
- return false;
- }
-
- return true;
+ return object.flip(operand);
 }
 
-//--- IntervalSet -------------------------------------------------------------
+//-----------------------------------------------------------------------------
+// erasure -= of elements given by an interval_set
+//-----------------------------------------------------------------------------
 template
 <
- class DomainT, class CodomainT, class Traits,
+ class ObjectT,
+ class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- template
- <
- class, class, class,
- ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
- >
- class IntervalMap,
     template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
>
-//JODO boost::enable_if
-bool is_disjoint
+ObjectT&
+operator -=
 (
- const IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& object,
- const IntervalSet<DomainT,Compare,Interval,Alloc>& operand
+ ObjectT& object,
+ const IntervalSet<DomainT,Compare,Interval,Alloc>& erasure
 )
 {
- typedef IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc> object_type;
- typedef IntervalSet<DomainT,Compare,Interval,Alloc> operand_type;
- object_type intersection;
-
- if(operand.empty())
- return true;
-
- typename operand_type::const_iterator common_lwb;
- typename operand_type::const_iterator common_upb;
+ typedef IntervalSet<DomainT,Compare,Interval,Alloc> set_type;
+ const_FORALL(typename set_type, interval_, erasure)
+ object.erase(*interval_);
 
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return true;
+ return object;
+}
 
- typename operand_type::const_iterator it = common_lwb;
- while(it != common_upb)
- {
- object.add_intersection(intersection, *it++);
- if(!intersection.empty())
- return false;
- }
 
- return true;
+//-----------------------------------------------------------------------------
+// insert
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT, class Traits,
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ class OperandT
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>&
+insert
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& object,
+ const OperandT& operand
+)
+{
+ const_FORALL(typename OperandT, elem_, operand)
+ object.insert(*elem_);
+ return object;
 }
 
+//-----------------------------------------------------------------------------
+// erase
+//-----------------------------------------------------------------------------
 template
 <
- class DomainT, class CodomainT, class Traits,
+ class SubType, class DomainT, class CodomainT, class Traits,
     ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- template
- <
- class, class, class,
- ITL_COMPARE, ITL_COMBINE, ITL_SECTION, template<class,ITL_COMPARE>class, ITL_ALLOC
- >
- class IntervalMap,
- template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
+ class OperandT
>
-//JODO boost::enable_if
-bool is_disjoint
+interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>&
+erase
 (
- const IntervalSet<DomainT,Compare,Interval,Alloc>& left,
- const IntervalMap<DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& right
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& object,
+ const OperandT& operand
 )
 {
- return is_disjoint(right, left);
+ const_FORALL(typename OperandT, elem_, operand)
+ object.erase(*elem_);
+ return object;
 }
 
+
+
 //-----------------------------------------------------------------------------
 // enclosure
 //-----------------------------------------------------------------------------

Modified: sandbox/itl/boost/itl/interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_set.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -148,9 +148,6 @@
     /// allocator type of the corresponding element set
     typedef Alloc<DomainT> domain_allocator_type;
 
- /// The type of the set of elements that is equivalent to the set of intervals
- typedef typename itl::set<DomainT,Compare,Alloc> element_set;
-
     /// The corresponding atomized type representing this interval container of elements
     typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
 
@@ -171,9 +168,11 @@
 
         enum { fineness = 1 };
 
-
- // B: Constructors, destructors, assignment
- /// Default constructor for the empty set
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
     interval_set(): base_type() {}
     /// Copy constructor
     interval_set(const interval_set& src): base_type(src) {}

Modified: sandbox/itl/boost/itl/interval_sets.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_sets.hpp (original)
+++ sandbox/itl/boost/itl/interval_sets.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -18,6 +18,57 @@
 template<typename, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>
 class interval_set;
 
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+//------------------------------------------------------------------------------
+// is_element_equal
+//------------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT,
+ ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
+>
+bool is_element_equal
+(
+ const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& left,
+ const IntervalSet <DomainT,Compare,Interval,Alloc>& right
+)
+{
+ return Interval_Set::is_element_equal(left, right);
+}
+
+template
+<
+ class SubType, class DomainT,
+ ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
+>
+bool is_element_less
+(
+ const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& left,
+ const IntervalSet <DomainT,Compare,Interval,Alloc>& right
+)
+{
+ return Interval_Set::is_element_less(left, right);
+}
+
+template
+<
+ class SubType, class DomainT,
+ ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
+>
+bool is_element_greater
+(
+ const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& left,
+ const IntervalSet <DomainT,Compare,Interval,Alloc>& right
+)
+{
+ return Interval_Set::is_element_greater(left, right);
+}
+
 //-----------------------------------------------------------------------------
 // addition +=
 //-----------------------------------------------------------------------------
@@ -76,55 +127,6 @@
 }
 
 
-//-----------------------------------------------------------------------------
-// is_element_equal
-//-----------------------------------------------------------------------------
-template
-<
- class SubType, class DomainT,
- ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
->
-bool is_element_equal
-(
- const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& left,
- const IntervalSet <DomainT,Compare,Interval,Alloc>& right
-)
-{
- return Interval_Set::is_element_equal(left, right);
-}
-
-template
-<
- class SubType, class DomainT,
- ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
->
-bool is_element_less
-(
- const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& left,
- const IntervalSet <DomainT,Compare,Interval,Alloc>& right
-)
-{
- return Interval_Set::is_element_less(left, right);
-}
-
-template
-<
- class SubType, class DomainT,
- ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
- template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
->
-bool is_element_greater
-(
- const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& left,
- const IntervalSet <DomainT,Compare,Interval,Alloc>& right
-)
-{
- return Interval_Set::is_element_greater(left, right);
-}
-
-
 
 //-----------------------------------------------------------------------------
 // is_disjoint

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -5,12 +5,6 @@
       (See accompanying file LICENCE.txt or copy at
            http://www.boost.org/LICENSE_1_0.txt)
 +-----------------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------------+
-class itl::map
- a general map class that extends stl-maps
- for concepts InplaceAddable and InplaceSubtractable
-+-----------------------------------------------------------------------------*/
 #ifndef __itl_map_h_JOFA_070519__
 #define __itl_map_h_JOFA_070519__
 
@@ -29,786 +23,783 @@
 namespace boost{namespace itl
 {
 
- struct partial_absorber
- {
- enum { absorbs_neutrons = true };
- enum { is_total = false };
- };
-
- template<>
- inline std::string type_to_string<partial_absorber>::apply() { return "@0"; }
-
-
- struct partial_enricher
- {
- enum { absorbs_neutrons = false };
- enum { is_total = false };
-
- };
-
- template<>
- inline std::string type_to_string<partial_enricher>::apply() { return "e0"; }
-
- struct total_absorber
- {
- enum { absorbs_neutrons = true };
- enum { is_total = true };
- };
-
- template<>
- inline std::string type_to_string<total_absorber>::apply() { return "^0"; }
-
- struct total_enricher
- {
- enum { absorbs_neutrons = false };
- enum { is_total = true };
- };
-
- template<>
- inline std::string type_to_string<total_enricher>::apply() { return "e^0"; }
-
-
- /*JODO move this comment to concept InplaceAddable, InplaceSubtractable, InplaceCombinable
-
- Many features of the itl are based on the concept, that instances of
- template parameter are InplaceAddable(InplaceSubtractible). That is,
- operators += and -= are implemented.
- */
-
- /// an stl based map implementing inplace addition and subtraction operators += and -=
- //JODO 1_0_1 documentation
- /**
-
- @author Joachim Faulhaber
- */
- template
- <
- typename DomainT,
- typename CodomainT,
- class Traits = itl::partial_absorber,
- ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
- ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, CodomainT),
- ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_et, CodomainT),
- ITL_ALLOC Alloc = std::allocator
- >
- class map: private std::map<DomainT, CodomainT, ITL_COMPARE_DOMAIN(Compare,DomainT),
- Alloc<std::pair<const DomainT, CodomainT> > >
- {
- public:
- typedef Alloc<typename std::pair<const DomainT, CodomainT> > allocator_type;
-
- typedef typename itl::map<DomainT,CodomainT,Traits, Compare,Combine,Section,Alloc> type;
- typedef typename std::map<DomainT, CodomainT, ITL_COMPARE_DOMAIN(Compare,DomainT),
- allocator_type> base_type;
- typedef typename itl::set<DomainT, Compare, Alloc > set_type;
-
- typedef itl::map<DomainT,CodomainT,itl::partial_absorber,Compare,Combine,Section,Alloc>
- partial_absorber_type;
- typedef Traits traits;
-
- public:
- typedef DomainT domain_type;
- typedef DomainT key_type;
- typedef CodomainT codomain_type;
- typedef CodomainT mapped_type;
- typedef CodomainT data_type;
- typedef std::pair<const DomainT, CodomainT> element_type;
- typedef std::pair<const DomainT, CodomainT> value_type;
- typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
- typedef ITL_COMBINE_CODOMAIN(Combine,CodomainT) codomain_combine;
- typedef domain_compare key_compare;
- typedef typename inverse<codomain_combine >::type inverse_codomain_combine;
- typedef ITL_SECTION_CODOMAIN(Section,CodomainT) codomain_intersect;
- typedef typename inverse<codomain_intersect>::type inverse_codomain_intersect;
- typedef typename base_type::value_compare value_compare;
-
- public:
- typedef typename base_type::pointer pointer;
- typedef typename base_type::const_pointer const_pointer;
- typedef typename base_type::reference reference;
- typedef typename base_type::const_reference const_reference;
- typedef typename base_type::iterator iterator;
- typedef typename base_type::const_iterator const_iterator;
- typedef typename base_type::size_type size_type;
- typedef typename base_type::difference_type difference_type;
- typedef typename base_type::reverse_iterator reverse_iterator;
- typedef typename base_type::const_reverse_iterator const_reverse_iterator;
-
- public:
- map(){}
- map(const key_compare& comp): base_type(comp){}
-
- template <class InputIterator>
- map(InputIterator f, InputIterator l): base_type(f,l) {}
-
- template <class InputIterator>
- map(InputIterator f, InputIterator l, const key_compare& comp): base_type(f,l,comp) {}
-
- map(const map& src): base_type::map(src){}
-
- map& operator=(const map& src) { base_type::operator=(src); return *this; }
- void swap(map& src) { base_type::swap(src); }
-
- using base_type::begin;
- using base_type::end;
- using base_type::rbegin;
- using base_type::rend;
-
- using base_type::size;
- using base_type::max_size;
- using base_type::empty;
-
- using base_type::key_comp;
- using base_type::value_comp;
-
- using base_type::insert;
- using base_type::erase;
- using base_type::clear;
- using base_type::find;
- using base_type::count;
-
- using base_type::lower_bound;
- using base_type::upper_bound;
- using base_type::equal_range;
-
- using base_type::operator[];
-
- public:
- inline static bool has_symmetric_difference()
- { return is_set<codomain_type>::value || (!is_set<codomain_type>::value && !traits::is_total); }
-
- public:
- // --------------------------------------------------------------------
- // itl specific extensions
-
- //JODO concept set
- /** Checks if a key element is in the map */
- bool contains(const DomainT& x)const { return !(find(x) == end()); }
-
- /** Is <tt>*this</tt> contained in <tt>super</tt>? */
- bool contained_in(const map& super)const
- { return Map::contained_in(*this, super); }
-
- /** Does <tt>*this</tt> contain <tt>sub</tt>? */
- bool contains(const map& sub)const
- { return Map::contained_in(sub, *this); }
-
- std::pair<iterator,bool> insert(const value_type& value_pair)
- {
- if(Traits::absorbs_neutrons && value_pair.CONT_VALUE == codomain_combine::neutron())
- return std::pair<iterator,bool>(end(),true);
- else
- return base_type::insert(value_pair);
- }
-
- /** \c add inserts \c value_pair into the map if it's key does
- not exist in the map.
- If \c value_pairs's key value exists in the map, it's data
- value is added to the data value already found in the map. */
- map& add(const value_type& value_pair) { return add<codomain_combine>(value_pair); }
-
- /** If the \c value_pair's key value is in the map, it's data value is
- subtraced from the data value stored in the map. */
- map& subtract(const value_type& value_pair)
- {
- if(Traits::is_total && has_inverse<codomain_type>::value)
- this->template add<inverse_codomain_combine>(value_pair);
- else
- this->template subtract<inverse_codomain_combine>(value_pair);
-
- return *this;
- }
-
- void add_intersection(map& section, const domain_type& key_value)const;
-
- void add_intersection(map& section, const value_type& value_pair)const;
+struct partial_absorber
+{
+ enum { absorbs_neutrons = true };
+ enum { is_total = false };
+};
 
- void add_intersection(map& section, const set_type& sectant)const;
+template<>
+inline std::string type_to_string<partial_absorber>::apply() { return "@0"; }
 
- void add_intersection(map& section, const map& sectant)const;
 
- //JODO
- /** erase the value pair \c pair(key,val) from the map.
- Erase only if, the exact value content \c val is stored at key \key. */
- size_type erase(const value_type& value);
-
- /** \c key_value allows for a uniform access to \c key_values which is
- is used for common algorithms on sets and maps. */
- template<typename IteratorT>
- static const key_type& key_value(IteratorT& value_)
- { return (*value_).first; }
-
- /** \c data_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 data_type& data_value(IteratorT& value_){ return (*value_).second; }
-
- /** \c key_less allows for a uniform notation of key comparison which
- is used for common algorithms on sets and maps. */
- template<typename LeftIterT, typename RightIterT>
- static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
- { return key_compare()((*lhs_).first,(*rhs_).first); }
-
- /** \c iterative_size() yields the number of elements that is visited
- throu complete iteration. For interval sets \c iterative_size() is
- different from \c size(). */
- static value_type make_element(const key_type& key_val, const data_type& data_val)
- { return value_type(key_val, data_val); }
-
- /** \c iterative_size() yields the number of elements that is visited
- throu complete iteration. For interval sets \c iterative_size() is
- different from \c size(). */
- size_t iterative_size()const { return size(); }
-
- size_t cardinality()const { return size(); }
-
- void absorb_neutrons()
- {
- //content_is_neutron<key_type, data_type> neutron_dropper;
- if(!Traits::absorbs_neutrons)
- erase_if(content_is_neutron<value_type>());
- }
-
- /** Erase the elements in *this map to which property \c hasProperty applies.
- Keep all the rest. */
- template<class Predicate>
- map& erase_if(const Predicate&);
-
- /** Copy the elements in map \c src to which property \c hasProperty applies
- into \c *this map. */
- template<class Predicate>
- map& assign_if(const map& src, const Predicate&);
-
- /** Represent this map as string */
- std::string as_string()const;
-
- private:
- template<class Combiner>
- map& add(const value_type& value_pair);
-
- template<class Combiner>
- map& subtract(const value_type& value_pair);
- };
-
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- template <class Combiner>
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::add(const value_type& val)
- {
- if(Traits::absorbs_neutrons && val.CONT_VALUE == Combiner::neutron())
- *this;
+struct partial_enricher
+{
+ enum { absorbs_neutrons = false };
+ enum { is_total = false };
 
- std::pair<iterator, bool> insertion;
- if(Traits::is_total)
- {
- CodomainT added_val = Combiner::neutron();
- Combiner()(added_val, val.CONT_VALUE);
- insertion = insert(value_type(val.KEY_VALUE, added_val));
- }
- else // Existential case
- insertion = insert(val);
+};
 
- if( insertion.WAS_SUCCESSFUL )
- return *this;
- else
- {
- iterator it = insertion.ITERATOR;
- Combiner()((*it).CONT_VALUE, val.CONT_VALUE);
+template<>
+inline std::string type_to_string<partial_enricher>::apply() { return "e0"; }
 
- if(Traits::absorbs_neutrons && (*it).CONT_VALUE == Combiner::neutron())
- erase(it);
+struct total_absorber
+{
+ enum { absorbs_neutrons = true };
+ enum { is_total = true };
+};
 
- return *this;
- }
- }
+template<>
+inline std::string type_to_string<total_absorber>::apply() { return "^0"; }
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- typename map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::size_type
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::erase(const value_type& value_pair)
- {
- if(Traits::absorbs_neutrons && value_pair.CONT_VALUE == codomain_combine::neutron())
- return 0; // neutrons are never contained 'substantially'
- // only 'virually'.
-
- iterator it_ = find(value_pair.KEY_VALUE);
- if(it_ != end() && value_pair.CONT_VALUE == it_->CONT_VALUE)
- {
- erase(it_);
- return 1;
- }
+struct total_enricher
+{
+ enum { absorbs_neutrons = false };
+ enum { is_total = true };
+};
+
+template<>
+inline std::string type_to_string<total_enricher>::apply() { return "e^0"; }
+
+
+/// adds addition, subtraction and intersection to std::maps
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits = itl::partial_absorber,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
+ ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, CodomainT),
+ ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_et, CodomainT),
+ ITL_ALLOC Alloc = std::allocator
+>
+class map: private std::map<DomainT, CodomainT, ITL_COMPARE_DOMAIN(Compare,DomainT),
+ Alloc<std::pair<const DomainT, CodomainT> > >
+{
+public:
+ typedef Alloc<typename std::pair<const DomainT, CodomainT> > allocator_type;
 
- return 0;
+ typedef typename itl::map<DomainT,CodomainT,Traits, Compare,Combine,Section,Alloc> type;
+ typedef typename std::map<DomainT, CodomainT, ITL_COMPARE_DOMAIN(Compare,DomainT),
+ allocator_type> base_type;
+ typedef typename itl::set<DomainT, Compare, Alloc > set_type;
+
+ typedef Traits traits;
+
+public:
+ typedef DomainT domain_type;
+ typedef DomainT key_type;
+ typedef CodomainT codomain_type;
+ typedef CodomainT mapped_type;
+ typedef CodomainT data_type;
+ typedef std::pair<const DomainT, CodomainT> element_type;
+ typedef std::pair<const DomainT, CodomainT> value_type;
+ typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
+ typedef ITL_COMBINE_CODOMAIN(Combine,CodomainT) codomain_combine;
+ typedef domain_compare key_compare;
+ typedef typename inverse<codomain_combine >::type inverse_codomain_combine;
+ typedef ITL_SECTION_CODOMAIN(Section,CodomainT) codomain_intersect;
+ typedef typename inverse<codomain_intersect>::type inverse_codomain_intersect;
+ typedef typename base_type::value_compare value_compare;
+
+public:
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::size_type size_type;
+ typedef typename base_type::difference_type difference_type;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ map(){}
+ map(const key_compare& comp): base_type(comp){}
+
+ template <class InputIterator>
+ map(InputIterator f, InputIterator l): base_type(f,l) {}
+
+ template <class InputIterator>
+ map(InputIterator f, InputIterator l, const key_compare& comp): base_type(f,l,comp) {}
+
+ map(const map& src): base_type::map(src){}
+
+ map& operator=(const map& src) { base_type::operator=(src); return *this; }
+ void swap(map& src) { base_type::swap(src); }
+
+ //==========================================================================
+ using base_type::empty;
+ using base_type::clear;
+
+ using base_type::begin;
+ using base_type::end;
+ using base_type::rbegin;
+ using base_type::rend;
+
+ using base_type::size;
+ using base_type::max_size;
+
+ using base_type::key_comp;
+ using base_type::value_comp;
+
+ using base_type::insert;
+ using base_type::erase;
+ using base_type::find;
+ using base_type::count;
+
+ using base_type::lower_bound;
+ using base_type::upper_bound;
+ using base_type::equal_range;
+
+ using base_type::operator[];
+
+public:
+ inline static bool has_symmetric_difference()
+ { return is_set<codomain_type>::value || (!is_set<codomain_type>::value && !traits::is_total); }
+
+public:
+ //==========================================================================
+ //= Emptieness, containmnet
+ //==========================================================================
+
+ /** Checks if a key element is in the map */
+ bool contains(const DomainT& x)const { return !(find(x) == end()); }
+
+ /** Is <tt>*this</tt> contained in <tt>super</tt>? */
+ bool contained_in(const map& super)const
+ { return Map::contained_in(*this, super); }
+
+ /** Does <tt>*this</tt> contain <tt>sub</tt>? */
+ bool contains(const map& sub)const
+ { return Map::contained_in(sub, *this); }
+
+ //==========================================================================
+ //= Size
+ //==========================================================================
+ /** \c iterative_size() yields the number of elements that is visited
+ throu complete iteration. For interval sets \c iterative_size() is
+ different from \c size(). */
+ size_t iterative_size()const { return size(); }
+
+ size_t cardinality()const { return size(); }
+
+ void absorb_neutrons()
+ {
+ //content_is_neutron<key_type, data_type> neutron_dropper;
+ if(!Traits::absorbs_neutrons)
+ erase_if(content_is_neutron<value_type>());
     }
 
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- template <class Combiner>
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::subtract(const value_type& val)
+ std::pair<iterator,bool> insert(const value_type& value_pair)
     {
- iterator it_ = find(val.KEY_VALUE);
- if(it_ != end())
- {
- Combiner()((*it_).CONT_VALUE, val.CONT_VALUE);
- if(Traits::absorbs_neutrons && (*it_).CONT_VALUE == codomain_combine::neutron())
- erase(it_);
- }
- return *this;
+ if(Traits::absorbs_neutrons && value_pair.CONT_VALUE == codomain_combine::neutron())
+ return std::pair<iterator,bool>(end(),true);
+ else
+ return base_type::insert(value_pair);
     }
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::add_intersection(map& section, const value_type& sectant)const
+ /** \c add inserts \c value_pair into the map if it's key does
+ not exist in the map.
+ If \c value_pairs's key value exists in the map, it's data
+ value is added to the data value already found in the map. */
+ map& add(const value_type& value_pair) { return add<codomain_combine>(value_pair); }
+
+ /** If the \c value_pair's key value is in the map, it's data value is
+ subtraced from the data value stored in the map. */
+ map& subtract(const value_type& value_pair)
         {
- if(Traits::is_total)
- {
- section = *this;
- section.add(sectant);
- }
- else
- {
- const_iterator it_ = find(sectant.KEY_VALUE);
- if(it_ != end())
- {
- section.add(*it_);
- if(is_set<CodomainT>::value)
- section.template add<codomain_intersect>(sectant);
- else
- section.template add<codomain_combine>(sectant);
- }
- }
+ if(Traits::is_total && has_inverse<codomain_type>::value)
+ this->template add<inverse_codomain_combine>(value_pair);
+ else
+ this->template subtract<inverse_codomain_combine>(value_pair);
+
+ return *this;
         }
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::add_intersection(map& section, const domain_type& sectant)const
- {
- const_iterator it_ = find(sectant);
- if(it_ != end())
- add(*it_);
- }
+ void add_intersection(map& section, const domain_type& key_value)const;
 
+ void add_intersection(map& section, const value_type& value_pair)const;
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::add_intersection(map& section, const typename map::set_type& sectant)const
- {
- typename set_type::const_iterator common_lwb_;
- typename set_type::const_iterator common_upb_;
- if(!common_range(common_lwb_, common_upb_, sectant, *this))
- return;
-
- typename set_type::const_iterator sec_ = common_lwb_;
- while(sec_ != common_upb_)
- add_intersection(*sec_++);
- }
-
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::add_intersection(map& section, const map& sectant)const
- {
- const_iterator common_lwb_;
- const_iterator common_upb_;
- if(!Set::common_range(common_lwb_, common_upb_, sectant, *this))
- return;
-
- typename const_iterator sec_ = common_lwb_;
- while(sec_ != common_upb_)
- {
- const_iterator it_ = find(sec_->KEY_VALUE);
- if(it_ != end())
- {
- section.add(*it_);
- if(is_set<CodomainT>::value)
- section.template add<codomain_intersect>(*sec_);
- else
- section.template add<codomain_combine>(*sec_);
- }
- ++sec_;
- }
- }
+ void add_intersection(map& section, const set_type& sectant)const;
 
+ void add_intersection(map& section, const map& sectant)const;
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- std::string map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::as_string()const
- {
- std::string repr;
- const_FORALL_THIS(it) {
- std::string elem("(");
- elem += to_string<DomainT>::apply((*it).KEY_VALUE);
- elem += "->";
- elem += to_string<CodomainT>::apply((*it).CONT_VALUE);
- elem += ")";
-
- repr += elem;
- }
- return repr;
- }
+ //JODO
+ /** erase the value pair \c pair(key,val) from the map.
+ Erase only if, the exact value content \c val is stored at key \key. */
+ size_type erase(const value_type& value);
+
+ /** \c key_value allows for a uniform access to \c key_values which is
+ is used for common algorithms on sets and maps. */
+ template<typename IteratorT>
+ static const key_type& key_value(IteratorT& value_)
+ { return (*value_).first; }
+
+ /** \c data_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 data_type& data_value(IteratorT& value_){ return (*value_).second; }
+
+ /** \c key_less allows for a uniform notation of key comparison which
+ is used for common algorithms on sets and maps. */
+ template<typename LeftIterT, typename RightIterT>
+ static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
+ { return key_compare()((*lhs_).first,(*rhs_).first); }
+
+ /** \c iterative_size() yields the number of elements that is visited
+ throu complete iteration. For interval sets \c iterative_size() is
+ different from \c size(). */
+ static value_type make_element(const key_type& key_val, const data_type& data_val)
+ { return value_type(key_val, data_val); }
+
+ /** Erase the elements in *this map to which property \c hasProperty applies.
+ Keep all the rest. */
+ template<class Predicate>
+ map& erase_if(const Predicate&);
+
+ /** Copy the elements in map \c src to which property \c hasProperty applies
+ into \c *this map. */
+ template<class Predicate>
+ map& assign_if(const map& src, const Predicate&);
+
+ /** Represent this map as string */
+ std::string as_string()const;
+
+private:
+ template<class Combiner>
+ map& add(const value_type& value_pair);
+
+ template<class Combiner>
+ map& subtract(const value_type& value_pair);
+};
+
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ template <class Combiner>
+map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::add(const value_type& val)
+{
+ if(Traits::absorbs_neutrons && val.CONT_VALUE == Combiner::neutron())
+ *this;
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- template<class Predicate>
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::erase_if(const Predicate& pred)
+ std::pair<iterator, bool> insertion;
+ if(Traits::is_total)
     {
- iterator it = begin();
- while(it != end())
- if(Predicate()(*it))
- erase(it++);
- else ++it;
- return *this;
+ CodomainT added_val = Combiner::neutron();
+ Combiner()(added_val, val.CONT_VALUE);
+ insertion = insert(value_type(val.KEY_VALUE, added_val));
     }
+ else // Existential case
+ insertion = insert(val);
 
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- template<class Predicate>
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- ::assign_if(const map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& src, const Predicate& pred)
- {
- clear();
- const_iterator it = src.begin();
- while(it != src.end()) {
- if(Predicate()(*it))
- add(*it++);
- }
+ if( insertion.WAS_SUCCESSFUL )
         return *this;
- }
- //-------------------------------------------------------------------------
- template <typename DomainT, typename CodomainT, class Traits,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- insert(map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& insertee)
+ else
     {
- typedef map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> map_type;
-
- const_FORALL(typename map_type, elem_, insertee)
- object.insert(*elem_);
-
- return object;
- }
-
- template <typename DomainT, typename CodomainT, class Traits,
- ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- erase(map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& erasee)
- {
- typedef map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> map_type;
-
- const_FORALL(typename map_type, elem_, erasee)
- object.erase(*elem_);
-
- return object;
- }
+ iterator it = insertion.ITERATOR;
+ Combiner()((*it).CONT_VALUE, val.CONT_VALUE);
 
+ if(Traits::absorbs_neutrons && (*it).CONT_VALUE == Combiner::neutron())
+ erase(it);
 
- //-----------------------------------------------------------------------------
- // non member functions
- //-----------------------------------------------------------------------------
-
- /** Standard equality, which is lexicographical equality of the sets
- as sequences, that are given by their Compare order. */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool operator == (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
- {
- typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
- return operator==((const base_type&)lhs, (const base_type&)rhs);
+ return *this;
     }
+}
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool operator != (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
- { return !(lhs == rhs); }
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+typename map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::size_type
+ map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::erase(const value_type& value_pair)
+{
+ if(Traits::absorbs_neutrons && value_pair.CONT_VALUE == codomain_combine::neutron())
+ return 0; // neutrons are never contained 'substantially'
+ // only 'virually'.
 
- //JODO comment...
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool is_element_equal(const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+ iterator it_ = find(value_pair.KEY_VALUE);
+ if(it_ != end() && value_pair.CONT_VALUE == it_->CONT_VALUE)
     {
- typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
- return operator==((const base_type&)lhs, (const base_type&)rhs);
+ erase(it_);
+ return 1;
     }
 
- /** Protonic equality is equality on all elements that do not carry a neutron as content. */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool is_protonic_equal (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
- {
- //JODO: Efficient implementation.
- typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
+ return 0;
+}
 
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> lhs0 = lhs;
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> rhs0 = rhs;
- lhs0.absorb_neutrons();
- rhs0.absorb_neutrons();
- return operator==((const base_type&)lhs0, (const base_type&)rhs0);
- }
 
- /** Strict weak less ordering which is given by the Compare order */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool operator < (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ template <class Combiner>
+map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::subtract(const value_type& val)
+{
+ iterator it_ = find(val.KEY_VALUE);
+ if(it_ != end())
     {
- typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
- return operator<((const base_type&)lhs, (const base_type&)rhs);
+ Combiner()((*it_).CONT_VALUE, val.CONT_VALUE);
+ if(Traits::absorbs_neutrons && (*it_).CONT_VALUE == codomain_combine::neutron())
+ erase(it_);
     }
+ return *this;
+}
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool operator > (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
- { return rhs < lhs; }
-
- /** Partial ordering which is induced by Compare */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool operator <= (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
- { return !(lhs > rhs); }
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline bool operator >= (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
- { return !(lhs < rhs); }
-
- //--------------------------------------------------------------------------
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator += ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
- { return object.add(operand); }
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator + ( const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) += operand;
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const value_type& sectant)const
+{
+ if(Traits::is_total)
+ {
+ section = *this;
+ section.add(sectant);
         }
-
-
- /** Add a map \c operand to map \c object. If an element of \c operand already exists
- in \c object, add up the contents. */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator += ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- { Set::add(object, operand); return object; }
-
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator + (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) += operand;
+ else
+ {
+ const_iterator it_ = find(sectant.KEY_VALUE);
+ if(it_ != end())
+ {
+ section.add(*it_);
+ if(is_set<CodomainT>::value)
+ section.template add<codomain_intersect>(sectant);
+ else
+ section.template add<codomain_combine>(sectant);
+ }
         }
+}
 
- //--------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const domain_type& sectant)const
+{
+ const_iterator it_ = find(sectant);
+ if(it_ != end())
+ section.add(*it_);
+}
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator |= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
- { return object.add(operand); }
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator | ( const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) |= operand;
- }
-
 
- /** Add a map \c operand to map \c object. If an element of \c operand already exists
- in \c object, add up the contents. */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator |= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- { Set::add(object, operand); return object; }
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const typename map::set_type& sectant)const
+{
+ typename set_type::const_iterator common_lwb_;
+ typename set_type::const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, sectant, *this))
+ return;
+
+ typename set_type::const_iterator sec_ = common_lwb_;
+ while(sec_ != common_upb_)
+ add_intersection(section, *sec_++);
+}
 
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator | (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) |= operand;
- }
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const map& sectant)const
+{
+ const_iterator common_lwb_;
+ const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, sectant, *this))
+ return;
 
- //--------------------------------------------------------------------------
+ typename const_iterator sec_ = common_lwb_;
+ while(sec_ != common_upb_)
+ {
+ const_iterator it_ = find(sec_->KEY_VALUE);
+ if(it_ != end())
+ {
+ section.add(*it_);
+ if(is_set<CodomainT>::value)
+ section.template add<codomain_intersect>(*sec_);
+ else
+ section.template add<codomain_combine>(*sec_);
+ }
+ ++sec_;
+ }
+}
 
- /** Subtract a map \c x2 from this map. If an element of \c x2 already exists
- in \c *this, subtract the contents using <tt>operator -=</tt>. */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator -= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- const_FORALL(typename ObjectT, it_, operand)
- object.subtract(*it_);
 
- return object;
- }
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+std::string map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::as_string()const
+{
+ std::string repr;
+ const_FORALL_THIS(it) {
+ std::string elem("(");
+ elem += to_string<DomainT>::apply((*it).KEY_VALUE);
+ elem += "->";
+ elem += to_string<CodomainT>::apply((*it).CONT_VALUE);
+ elem += ")";
+
+ repr += elem;
+ }
+ return repr;
+}
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ template<class Predicate>
+map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::erase_if(const Predicate& pred)
+{
+ iterator it = begin();
+ while(it != end())
+ if(Predicate()(*it))
+ erase(it++);
+ else ++it;
+ return *this;
+}
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator - (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) -= operand;
- }
 
- /** Subtract a set \c x2 from this map. Every element of \c this map that
- has a key that is element of \c x2 is deleted from the map. */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator -= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
- { Set::erase(object, operand); return object; }
-
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator - (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) -= operand;
- }
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ template<class Predicate>
+map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::assign_if(const map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& src, const Predicate& pred)
+{
+ clear();
+ const_iterator it = src.begin();
+ while(it != src.end()) {
+ if(Predicate()(*it))
+ add(*it++);
+ }
+ return *this;
+}
+//-------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits,
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ insert(map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& insertee)
+{
+ typedef map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> map_type;
 
+ const_FORALL(typename map_type, elem_, insertee)
+ object.insert(*elem_);
 
- /** Intersect map \c x2 and \c *this.
- So \c *this becomes the intersection of \c *this and \c x2 */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> object_type;
- if(Traits::is_total) return object += operand;
- else
- {
- object_type section;
- object.add_intersection(section, operand);
- object.swap(section);
- return object;
- }
- //CL{ Map::intersect(object, operand); return object; }
- }
+ return object;
+}
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator & (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) &= operand;
- }
+template <typename DomainT, typename CodomainT, class Traits,
+ ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ erase(map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& erasee)
+{
+ typedef map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> map_type;
 
- /** Intersect set \c x2 and \c *this.
- So \c *this becomes the intersection of \c *this and \c x2 */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
- { Map::intersect(object, operand); return object; } //JODO TEST
-
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator & (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) &= operand;
- }
+ const_FORALL(typename map_type, elem_, erasee)
+ object.erase(*elem_);
 
+ return object;
+}
 
- /** Symmetric subtract map \c x2 and \c *this.
- So \c *this becomes the symmetric difference of \c *this and \c x2 */
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
- operator ^= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- Map::flip(object, operand);
- return object;
- }
 
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
- operator ^ (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
- const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
- {
- typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- return ObjectT(object) ^= operand;
- }
+//-----------------------------------------------------------------------------
+// non member functions
+//-----------------------------------------------------------------------------
+
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+/** Standard equality, which is lexicographical equality of the sets
+ as sequences, that are given by their Compare order. */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool operator == (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{
+ typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+}
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool operator != (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{ return !(lhs == rhs); }
+
+//JODO comment...
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool is_element_equal(const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{
+ typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+}
+
+/** Protonic equality is equality on all elements that do not carry a neutron as content. */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool is_protonic_equal (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{
+ //JODO: Efficient implementation.
+ typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
 
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> lhs0 = lhs;
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> rhs0 = rhs;
+ lhs0.absorb_neutrons();
+ rhs0.absorb_neutrons();
+ return operator==((const base_type&)lhs0, (const base_type&)rhs0);
+}
+
+/** Strict weak less ordering which is given by the Compare order */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool operator < (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{
+ typedef std::map<DomainT,CodomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
+ return operator<((const base_type&)lhs, (const base_type&)rhs);
+}
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool operator > (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{ return rhs < lhs; }
+
+/** Partial ordering which is induced by Compare */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool operator <= (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{ return !(lhs > rhs); }
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline bool operator >= (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& lhs,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
+{ return !(lhs < rhs); }
+
+//--------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator += ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
+{ return object.add(operand); }
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator + ( const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) += operand;
+}
+
+
+/** Add a map \c operand to map \c object. If an element of \c operand already exists
+ in \c object, add up the contents. */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator += ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{ Set::add(object, operand); return object; }
+
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator + (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) += operand;
+}
+
+//--------------------------------------------------------------------------
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator |= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
+{ return object.add(operand); }
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator | ( const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) |= operand;
+}
+
+
+/** Add a map \c operand to map \c object. If an element of \c operand already exists
+ in \c object, add up the contents. */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator |= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{ Set::add(object, operand); return object; }
+
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator | (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) |= operand;
+}
+
+//--------------------------------------------------------------------------
+
+/** Subtract a map \c x2 from this map. If an element of \c x2 already exists
+ in \c *this, subtract the contents using <tt>operator -=</tt>. */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator -= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ const_FORALL(typename ObjectT, it_, operand)
+ object.subtract(*it_);
+
+ return object;
+}
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator - (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) -= operand;
+}
+
+/** Subtract a set \c x2 from this map. Every element of \c this map that
+ has a key that is element of \c x2 is deleted from the map. */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator -= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
+{ Set::erase(object, operand); return object; }
+
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator - (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) -= operand;
+}
+
+
+/** Intersect map \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> object_type;
+ if(Traits::is_total) return object += operand;
+ else
+ {
+ object_type section;
+ object.add_intersection(section, operand);
+ object.swap(section);
+ return object;
+ }
+ //CL{ Map::intersect(object, operand); return object; }
+}
 
- //-----------------------------------------------------------------------------
- // type traits
- //-----------------------------------------------------------------------------
- template<class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct is_set<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- {
- typedef is_set<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
- static const bool value = true;
- };
-
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct is_map<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- {
- typedef is_map<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
- static const bool value = true;
- };
-
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct has_inverse<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- {
- typedef has_inverse<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
- static const bool value = has_inverse<CodomainT>::value;
- };
-
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct is_interval_container<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- {
- typedef is_interval_container<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
- enum{value = true};
- };
-
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct is_interval_splitter<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- { enum{value = false}; };
-
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct absorbs_neutrons<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- { enum{value = Traits::absorbs_neutrons}; };
-
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct is_total<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
- { enum{value = Traits::is_total}; };
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator & (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) &= operand;
+}
+
+/** Intersect set \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
+{ Map::intersect(object, operand); return object; } //JODO TEST
+
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator & (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) &= operand;
+}
+
+
+/** Symmetric subtract map \c x2 and \c *this.
+ So \c *this becomes the symmetric difference of \c *this and \c x2 */
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+operator ^= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ Map::flip(object, operand);
+ return object;
+}
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+operator ^ (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+{
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) ^= operand;
+}
+
+
+//-----------------------------------------------------------------------------
+// type traits
+//-----------------------------------------------------------------------------
+template<class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct is_set<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{
+ typedef is_set<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
+ static const bool value = true;
+};
+
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct is_map<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{
+ typedef is_map<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
+ static const bool value = true;
+};
+
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct has_inverse<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{
+ typedef has_inverse<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
+ static const bool value = has_inverse<CodomainT>::value;
+};
+
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct is_interval_container<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{
+ typedef is_interval_container<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> > type;
+ enum{value = true};
+};
+
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct is_interval_splitter<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{ enum{value = false}; };
+
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct absorbs_neutrons<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{ enum{value = Traits::absorbs_neutrons}; };
+
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct is_total<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{ enum{value = Traits::is_total}; };
 
- template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
- struct type_to_string<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+template <class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+struct type_to_string<itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> >
+{
+ static std::string apply()
     {
- static std::string apply()
- {
- return "map<"+ type_to_string<DomainT>::apply() + ","
- + type_to_string<CodomainT>::apply() + ","
- + type_to_string<Traits>::apply() +">";
- }
- };
+ return "map<"+ type_to_string<DomainT>::apply() + ","
+ + type_to_string<CodomainT>::apply() + ","
+ + type_to_string<Traits>::apply() +">";
+ }
+};
 
 
 }} // namespace itl boost

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 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -112,9 +112,6 @@
     /// allocator type of the corresponding element set
     typedef Alloc<DomainT> domain_allocator_type;
 
- /// The type of the set of elements that is equivalent to the set of intervals
- typedef typename itl::set<DomainT,Compare,Alloc> element_set;
-
     /// The corresponding atomized type representing this interval container of elements
     typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
 
@@ -136,9 +133,11 @@
 
         enum { fineness = 2 };
 
-
- // B: Constructors, destructors, assignment
- /// Default constructor for the empty set
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
     separate_interval_set(): base_type() {}
     /// Copy constructor
     separate_interval_set(const separate_interval_set& src): base_type(src) {}

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -1,37 +1,10 @@
-/*----------------------------------------------------------------------------+
-Copyright (c) 2007-2008: Joachim Faulhaber
-+-----------------------------------------------------------------------------+
-Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
-+-----------------------------------------------------------------------------+
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-+----------------------------------------------------------------------------*/
-/* ----------------------------------------------------------------------------
-class itl::set
-a general set class that extends stl-sets
-for concepts InplaceAddable and InplaceSubtractable
------------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2007-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 __itl_set_h_JOFA_070519__
 #define __itl_set_h_JOFA_070519__
 
@@ -50,492 +23,518 @@
 
 namespace boost{namespace itl
 {
- /// adds inplace addition, subtraction and intersection to std::set
- /**
- Class template <b>itl::set</b> extends <b>std::set</b> by inplace operators
- <b>+=, -= and *=</b>. These operations implement the fundamental set
- functions union, difference and intersection.
-
- In contrast to the classic stl style design, template parameters for set
- ordering <b>Compare</b> and allocation <b>Alloc</b> are passed as template
- template parameters. This allows for more flexible passing of those
- parameters to derived types via typedef.
-
- <b>Note</b> that itl::set provides all functionality of std::set via
- private inheritence. This can not be seen in the documentation because
- unfortunately doxygen does not evaluate using statements.
-
- @author Joachim Faulhaber
- */
- template
- <
- typename DomainT,
- ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
- ITL_ALLOC Alloc = std::allocator
- >
- class set: private std::set<DomainT, ITL_COMPARE_DOMAIN(Compare,DomainT), Alloc<DomainT> >
- {
- public:
- typedef typename itl::set<DomainT, Compare, Alloc > type;
- typedef typename std::set<DomainT, ITL_COMPARE_DOMAIN(Compare,DomainT), Alloc<DomainT> > base_type;
-
- public:
- typedef DomainT domain_type;
- typedef DomainT codomain_type;
- typedef DomainT element_type;
- typedef DomainT key_type;
- typedef DomainT value_type;
- typedef DomainT data_type;
- typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
- typedef ITL_COMPARE_DOMAIN(Compare,DomainT) key_compare;
- typedef ITL_COMPARE_DOMAIN(Compare,DomainT) value_compare;
- typedef Alloc<DomainT> allocator_type;
-
- public:
- typedef typename base_type::pointer pointer;
- typedef typename base_type::const_pointer const_pointer;
- typedef typename base_type::reference reference;
- typedef typename base_type::const_reference const_reference;
- typedef typename base_type::iterator iterator;
- typedef typename base_type::const_iterator const_iterator;
- typedef typename base_type::size_type size_type;
- typedef typename base_type::difference_type difference_type;
- typedef typename base_type::reverse_iterator reverse_iterator;
- typedef typename base_type::const_reverse_iterator const_reverse_iterator;
-
- public:
- set(){}
- set(const domain_compare& comp):
- std::set<DomainT, domain_compare, Alloc<DomainT> >(comp){}
-
- template <class InputIterator>
- set(InputIterator f, InputIterator l): std::set<InputIterator>(f,l) {}
-
- template <class InputIterator>
- set(InputIterator f, InputIterator l, const key_compare& comp): std::set<InputIterator>(f,l,comp) {}
-
- set(const set& src): base_type::set(src){}
-
- set& operator=(const set& src) { base_type::operator=(src); return *this; }
- void swap(set& src) { base_type::swap(src); }
-
- using base_type::begin;
- using base_type::end;
- using base_type::rbegin;
- using base_type::rend;
-
- using base_type::size;
- using base_type::max_size;
- using base_type::empty;
-
- using base_type::key_comp;
- using base_type::value_comp;
-
- using base_type::insert;
- using base_type::erase;
- using base_type::clear;
- using base_type::find;
- using base_type::count;
-
- using base_type::lower_bound;
- using base_type::upper_bound;
- using base_type::equal_range;
-
- public:
- // --------------------------------------------------------------------
- // itl specific extensions
-
- //JODO concept set
- /// Checks if the element \c x is in the set
- bool contains(const DomainT& x)const { return !(find(x) == end()); }
-
- /** Is <tt>*this</tt> contained in <tt>super</tt>? */
- bool contained_in(const set& super)const { return Set::contained_in(*this, super); }
-
- /** Does <tt>*this</tt> contain <tt>sub</tt>? */
- bool contains(const set& sub)const { return Set::contained_in(sub, *this); }
-
- /** <tt>*this</tt> and <tt>x2</tt> are disjoint, if their intersection is empty */
- bool disjoint(const set& x2)const { return disjoint(*this, x2); }
-
- /** Add an element \c value to the set. */
- set& add(const value_type& value) { insert(value); return *this; }
-
- /** Subtract an element \c value from the set. */
- set& subtract(const value_type& value);
-
- /** \c key_value allows for a uniform access to \c key_values which is
- is used for common algorithms on sets and maps. */
- template<typename IteratorT>
- static const key_type& key_value(IteratorT& value_){ return (*value_); }
-
- /** \c data_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 data_type& data_value(IteratorT& value_){ return (*value_); }
-
- /** \c key_less allows for a uniform notation of key comparison which
- is used for common algorithms on sets and maps. */
- template<typename LeftIterT, typename RightIterT>
- static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
- { return key_compare()(*lhs_, *rhs_); }
-
- /** \c make_element allows for a uniform notation of key comparison which
- is used for common algorithms on sets and maps. */
- static value_type make_element(const key_type& key_val, const data_type& data_val)
- { return key_val; }
-
- /** \c iterative_size() yields the number of elements that is visited
- throu complete iteration. For interval sets \c iterative_size() is
- different from \c size(). */
- size_t iterative_size()const { return size(); }
-
- size_t cardinality()const { return size(); }
-
- /** Erase the elements in *this set to which property \c hasProperty applies.
- Keep all the rest. */
- template<class Predicate>
- set& erase_if(const Predicate&);
-
- /** Copy the elements in set \c src to which property \c hasProperty applies
- into \c *this set. */
- template<class Predicate>
- set& assign_if(const set& src, const Predicate&);
-
- /** Represent this set as a string */
- std::string as_string(const char* sep = " ")const;
- };
-
-
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- set<DomainT,Compare,Alloc>&
- set<DomainT,Compare,Alloc>::subtract(const value_type& val)
- {
- iterator it_ = find(val);
- if(it_ != end())
- erase(it_);
-
- 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)
+/// adds addition, subtraction and intersection to std::set
+template
+<
+ typename DomainT,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
+ ITL_ALLOC Alloc = std::allocator
+>
+class set: private std::set<DomainT, ITL_COMPARE_DOMAIN(Compare,DomainT), Alloc<DomainT> >
+{
+public:
+ typedef typename itl::set<DomainT, Compare, Alloc > type;
+ typedef typename std::set<DomainT, ITL_COMPARE_DOMAIN(Compare,DomainT), Alloc<DomainT> > base_type;
+
+public:
+ typedef DomainT domain_type;
+ typedef DomainT codomain_type;
+ typedef DomainT element_type;
+ typedef DomainT key_type;
+ typedef DomainT value_type;
+ typedef DomainT data_type;
+ typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
+ typedef ITL_COMPARE_DOMAIN(Compare,DomainT) key_compare;
+ typedef ITL_COMPARE_DOMAIN(Compare,DomainT) value_compare;
+ typedef Alloc<DomainT> allocator_type;
+
+public:
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::size_type size_type;
+ typedef typename base_type::difference_type difference_type;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ set(){}
+ set(const domain_compare& comp):
+ std::set<DomainT, domain_compare, Alloc<DomainT> >(comp){}
+
+ template <class InputIterator>
+ set(InputIterator f, InputIterator l): std::set<InputIterator>(f,l) {}
+
+ template <class InputIterator>
+ set(InputIterator f, InputIterator l, const key_compare& comp): std::set<InputIterator>(f,l,comp) {}
+
+ set(const set& src): base_type::set(src){}
+
+ set& operator=(const set& src) { base_type::operator=(src); return *this; }
+ void swap(set& src) { base_type::swap(src); }
+
+ //==========================================================================
+ using base_type::empty;
+ using base_type::clear;
+
+ using base_type::begin;
+ using base_type::end;
+ using base_type::rbegin;
+ using base_type::rend;
+
+ using base_type::size;
+ using base_type::max_size;
+
+ using base_type::key_comp;
+ using base_type::value_comp;
+
+ using base_type::insert;
+ using base_type::erase;
+ using base_type::find;
+ using base_type::count;
+
+ using base_type::lower_bound;
+ using base_type::upper_bound;
+ using base_type::equal_range;
+
+public:
+ //==========================================================================
+ //= Emptieness, containmnet
+ //==========================================================================
+
+ /// Checks if the element \c x is in the set
+ bool contains(const DomainT& x)const { return !(find(x) == end()); }
+
+ /** Is <tt>*this</tt> contained in <tt>super</tt>? */
+ bool contained_in(const set& super)const { return Set::contained_in(*this, super); }
+
+ /** Does <tt>*this</tt> contain <tt>sub</tt>? */
+ bool contains(const set& sub)const { return Set::contained_in(sub, *this); }
+
+ /** <tt>*this</tt> and <tt>x2</tt> are disjoint, if their intersection is empty */
+ bool disjoint(const set& x2)const { return disjoint(*this, x2); }
+
+ //==========================================================================
+ //= Size
+ //==========================================================================
+ /** \c iterative_size() yields the number of elements that is visited
+ throu complete iteration. For interval sets \c iterative_size() is
+ different from \c size(). */
+ size_t iterative_size()const { return size(); }
+
+ size_t cardinality()const { return size(); }
+
+ /** Add an element \c value to the set. */
+ set& add(const value_type& value) { insert(value); return *this; }
+
+ /** Subtract an element \c value from the set. */
+ set& subtract(const value_type& value);
+
+ void add_intersection(set& section, const domain_type& key_value)const;
+
+ void add_intersection(set& section, const set& sectant)const;
+
+
+ /** \c key_value allows for a uniform access to \c key_values which is
+ is used for common algorithms on sets and maps. */
+ template<typename IteratorT>
+ static const key_type& key_value(IteratorT& value_){ return (*value_); }
+
+ /** \c data_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 data_type& data_value(IteratorT& value_){ return (*value_); }
+
+ /** \c key_less allows for a uniform notation of key comparison which
+ is used for common algorithms on sets and maps. */
+ template<typename LeftIterT, typename RightIterT>
+ static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
+ { return key_compare()(*lhs_, *rhs_); }
+
+ /** \c make_element allows for a uniform notation of key comparison which
+ is used for common algorithms on sets and maps. */
+ static value_type make_element(const key_type& key_val, const data_type& data_val)
+ { return key_val; }
+
+ /** Erase the elements in *this set to which property \c hasProperty applies.
+ Keep all the rest. */
+ template<class Predicate>
+ set& erase_if(const Predicate&);
+
+ /** Copy the elements in set \c src to which property \c hasProperty applies
+ into \c *this set. */
+ template<class Predicate>
+ set& assign_if(const set& src, const Predicate&);
+
+ /** Represent this set as a string */
+ std::string as_string(const char* sep = " ")const;
+};
+
+
+
+template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+set<DomainT,Compare,Alloc>&
+ set<DomainT,Compare,Alloc>::subtract(const value_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 domain_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 typename 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>
+std::string set<DomainT,Compare,Alloc>::as_string(const char* sep)const
+{
+ const_iterator it_ = begin();
+
+ if(it_ == end()) return std::string();
+ else
     {
- iterator it = begin();
- while(it != end())
- if(pred(*it))
- erase(it++);
- else ++it;
- return *this;
-
+ 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>
- ::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
- //-----------------------------------------------------------------------------
- /** 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)
- {
- typedef std::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>
+ 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;
+}
 
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- inline bool operator != (const itl::set<DomainT,Compare,Alloc>& lhs,
+//-----------------------------------------------------------------------------
+// non member functions
+//-----------------------------------------------------------------------------
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+/** 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)
+{
+ typedef std::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 !(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); }
+{
+ typedef std::set<DomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)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 std::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); }
+
+//--------------------------------------------------------------------------
+
+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>::value_type& operand)
+{ return object.add(operand); }
+
+template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+itl::set<DomainT,Compare,Alloc>
+operator + (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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>
+itl::set<DomainT,Compare,Alloc>
+operator + (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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>::value_type& operand)
+{ return object.add(operand); }
+
+template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+itl::set<DomainT,Compare,Alloc>
+operator | (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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>
+itl::set<DomainT,Compare,Alloc>
+operator | (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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>::value_type& operand)
+{ return object.subtract(operand); }
+
+template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+itl::set<DomainT,Compare,Alloc>
+operator - (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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>
+itl::set<DomainT,Compare,Alloc>
+operator - (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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>::value_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>
+itl::set<DomainT,Compare,Alloc>
+operator & (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+{ return itl::set<DomainT,Compare,Alloc>(object) &= operand; }
 
- /** 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)
- {
- typedef std::set<DomainT,ITL_COMPARE_DOMAIN(Compare,DomainT),Alloc<DomainT> > base_type;
- return operator==((const base_type&)lhs, (const base_type&)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 std::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); }
+/** 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>
+itl::set<DomainT,Compare,Alloc>
+operator & (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+{ return itl::set<DomainT,Compare,Alloc>(object) &= operand; }
+
+//--------------------------------------------------------------------------
+// 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>::value_type& operand)
+{
+ typedef itl::set<DomainT,Compare,Alloc> ObjectT;
+ if(object.contains(operand))
+ return erase(operand);
+ else
+ return add(operand);
+}
+
+template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+itl::set<DomainT,Compare,Alloc>
+operator ^ (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+{ return itl::set<DomainT,Compare,Alloc>(object) &= operand; }
 
- 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 itl::set<DomainT,Compare,Alloc>&
- operator += ( itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
- { return object.add(operand); }
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- itl::set<DomainT,Compare,Alloc>
- operator + (const itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
- { return itl::set<DomainT,Compare,Alloc>(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>
- itl::set<DomainT,Compare,Alloc>
- operator + (const itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
- { return itl::set<DomainT,Compare,Alloc>(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>::value_type& operand)
- { return object.add(operand); }
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- itl::set<DomainT,Compare,Alloc>
- operator | (const itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
- { return itl::set<DomainT,Compare,Alloc>(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>
- itl::set<DomainT,Compare,Alloc>
- operator | (const itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
- { return itl::set<DomainT,Compare,Alloc>(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>::value_type& operand)
- { return object.subtract(operand); }
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- itl::set<DomainT,Compare,Alloc>
- operator - (const itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
- { return itl::set<DomainT,Compare,Alloc>(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>
- itl::set<DomainT,Compare,Alloc>
- operator - (const itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
- { return itl::set<DomainT,Compare,Alloc>(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>::value_type& operand)
- {
- typedef itl::set<DomainT,Compare,Alloc> ObjectT;
- typename ObjectT::const_iterator element_ = object.find(operand);
- ObjectT intersection = element_ == object.end() ? ObjectT()
- : ObjectT(*element_);
- object.swap(intersection);
- return object;
- }
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- itl::set<DomainT,Compare,Alloc>
- operator & (const itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
- { return itl::set<DomainT,Compare,Alloc>(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 ^ (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+{ return itl::set<DomainT,Compare,Alloc>(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::intersect(object, operand); return object; }
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- itl::set<DomainT,Compare,Alloc>
- operator & (const itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
- { return itl::set<DomainT,Compare,Alloc>(object) &= operand; }
-
- //--------------------------------------------------------------------------
- // 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>::value_type& operand)
- {
- typedef itl::set<DomainT,Compare,Alloc> ObjectT;
- if(object.contains(operand))
- return erase(operand);
- else
- return add(operand);
- }
-
- template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- itl::set<DomainT,Compare,Alloc>
- operator ^ (const itl::set<DomainT,Compare,Alloc>& object,
- const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
- { return itl::set<DomainT,Compare,Alloc>(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 ^ (const itl::set<DomainT,Compare,Alloc>& object,
- const itl::set<DomainT,Compare,Alloc>& operand)
- { return itl::set<DomainT,Compare,Alloc>(object) &= 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; }
-
-
- //---------------------------------------------------------------------------------
- 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 set<DomainT,Compare,Alloc>& object)
- {
- typedef itl::set<DomainT,Compare,Alloc> SetT;
- stream << "{";
- const_FORALL(typename SetT, it, object)
- stream << *it;
-
- return stream << "}";
- }
-
-
- //-------------------------------------------------------------------------
- template <class Type>
- struct is_set<itl::set<Type> >
- {
- typedef is_set<itl::set<Type> > type;
- static const bool value = true;
- };
-
- template <class Type>
- struct is_interval_container<itl::set<Type> >
- {
- typedef is_interval_container<itl::set<Type> > type;
- enum{value = true};
- };
-
- template <class Type>
- struct is_interval_splitter<itl::set<Type> >
- { enum{value = false}; };
-
- template <class Type>
- struct absorbs_neutrons<itl::set<Type> >
- { enum{value = false}; };
-
- template <class Type>
- struct is_total<itl::set<Type> >
- { enum{value = false}; };
+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; }
+
+
+//---------------------------------------------------------------------------------
+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 set<DomainT,Compare,Alloc>& object)
+{
+ typedef itl::set<DomainT,Compare,Alloc> SetT;
+ stream << "{";
+ const_FORALL(typename SetT, it, object)
+ stream << *it;
+
+ return stream << "}";
+}
+
+
+//-------------------------------------------------------------------------
+template <class Type>
+struct is_set<itl::set<Type> >
+{
+ typedef is_set<itl::set<Type> > type;
+ static const bool value = true;
+};
+
+template <class Type>
+struct is_interval_container<itl::set<Type> >
+{
+ typedef is_interval_container<itl::set<Type> > type;
+ enum{value = true};
+};
+
+template <class Type>
+struct is_interval_splitter<itl::set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct absorbs_neutrons<itl::set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct is_total<itl::set<Type> >
+{ enum{value = false}; };
 
- template <class Type>
- struct type_to_string<itl::set<Type> >
- {
- static std::string apply()
- { return "set<"+ type_to_string<Type>::apply() +">"; }
- };
+template <class Type>
+struct type_to_string<itl::set<Type> >
+{
+ static std::string apply()
+ { return "set<"+ type_to_string<Type>::apply() +">"; }
+};
 
 
 }} // namespace itl boost

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 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -43,222 +43,223 @@
 namespace boost{namespace itl
 {
 
- /// implements a map as a map of intervals - on insertion overlapping intervals are split and associated values are combined.
- /**
- Template-class <b>split_interval_map</b>
- implements a map as a map of intervals - On insertion overlapping intervals are
- <b>split</b> and associated values are combined.
-
- Template parameter <b>DomainT</b>: Domain type of the map. Also type of the
- map's keys.
-
- Suitable as domain types are all datatypes that posess a partial order.
- In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
- atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
-
- Datatypes for the codomain parameter have to <b>implement</b> operations
- <tt>+=</tt>, <tt>-=</tt>, <tt>==</tt> (equality) and <tt>CodomainT()</tt> (default constructor).
-
- The default constructor <tt>CodomainT()</tt> has to contruct a neutral element
- such that the following holds:
-
- If <tt>x = y; y += CodomainT();</tt> then <tt>x==y;</tt> and
- If <tt>x = y; y -= CodomainT();</tt> then <tt>x==y;</tt>
-
- Template parameter <b>Interval=itl::interval</b>: Template type of interval used
- to implement the map. The default <b>itl::interval</b> uses the
- interval class template that comes with this library. Own implementation of interval
- classes are possible (but not trivial).
-
- <b>split_interval_map</b> implements a map <tt>map<DomainT, CodomainT></tt> as a map
- of intervals <tt>map<interval<DomainT>, CodomainT, ExclusiveLessT<Interval> ></tt>
-
- Interval maps <tt>split_interval_map<DomainT,CodomainT></tt> can be used similar (and in many
- aspects exactly like) common stl-maps. Unlike to stl-maps where you store
- a value for every key an interval map stores a contents value for an interval of
- keys. In it's degenerated form the key intervals contain a single element
- only. Then the interval map works like a normal stl-map. But if you work in problem
- domains where you associate values to large contiguous intervals, interval maps
- are very useful and efficient.
-
-
- Class <tt>interval_base_map</tt> yields the following benefits:
-
- <ul>
- <li> A set of intervals is conceived as the domain set of the map.
- The complexity involved with
- operations on intervals maps is encapsulated. The user of the class who
- wants to perform operations on interval maps is no more concerned
- with questions of overlapping, joining and bordering intervals.
- <li>
- <b>split_interval_map</b> gives an efficient implementation of maps consisting
- of larger contiguous chunks. Very large, even uncountably infinite maps
- can be represented in a compact way and handled efficiently.
- <li>
- <b>split_interval_map</b> serves as a overlay- or collision-computer.
- </ul>
-
- <b>split_interval_map as overlay computer</b>
-
- An object <tt>split_interval_map<int,int> overlays;</tt> computes the overlays or
- collisions of intervalls which have been inserted into it, if they are
- associated with the <tt>int</tt>-value <tt>1</tt> as the codommain value.
-
- If a newly inserted interval overlaps with intervals which are already in the
- map, the interval is split up at the borders of the collisions. The assiciated
- values of the overlapping intervals are incremented by 1, thus counting
- the numbers of overlaps.
-
- If sets are used as codomain types, interval_maps will compute unions of
- associated maps in case of interval collisions.
-
- <b>Restrictions: </b>
-
- A small number of functions can only be used for <b>discrete</b> domain datatypes
- (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
-
- These functions are tagged in the documentation. Using such functions
- for continuous domain datatypes yields compiletime errors. C.f. getting
- the <tt>first()</tt> element of a left open interval makes sense for intervals of
- int but not for intervals of double.
-
- @author Joachim Faulhaber
- */
- template
- <
- typename DomainT,
- typename CodomainT,
- class Traits = itl::partial_absorber,
- ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
- ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, CodomainT),
- ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_et, CodomainT),
- template<class,ITL_COMPARE>class Interval = itl::interval,
- ITL_ALLOC Alloc = std::allocator
- >
- class split_interval_map:
- public interval_base_map<split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
- DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
- {
- public:
- typedef Traits traits;
- typedef split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> type;
- typedef interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> joint_type;
- typedef type overloadable_type;
-
- typedef interval_base_map <split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
- DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> base_type;
-
- typedef split_interval_map<DomainT,CodomainT,itl::partial_absorber,Compare,Combine,Section,Interval,Alloc>
- partial_absorber_type;
-
- typedef Interval<DomainT,Compare> interval_type;
- typedef typename base_type::iterator iterator;
- typedef typename base_type::value_type value_type;
- typedef typename base_type::element_type element_type;
- typedef typename base_type::segment_type segment_type;
- typedef typename base_type::domain_mapping_type domain_mapping_type;
- typedef typename base_type::interval_mapping_type interval_mapping_type;
- typedef typename base_type::ImplMapT ImplMapT;
-
- typedef typename base_type::codomain_combine codomain_combine;
-
- typedef interval_set<DomainT,Compare,Interval,Alloc> interval_set_type;
- typedef interval_set_type set_type;
-
- enum { fineness = 3 };
-
- /// Default constructor for the empty map
- split_interval_map(): base_type() {}
- /// Copy constructor
- split_interval_map(const split_interval_map& src): base_type(src) {}
-
- explicit split_interval_map(domain_mapping_type& base_pair): base_type()
- { add(base_pair); }
-
- explicit split_interval_map(const value_type& value_pair): base_type()
- { add(value_pair); }
-
- /// Assignment operator
- template<class SubType>
- split_interval_map& operator =
- (const interval_base_map<SubType,DomainT,CodomainT,
- Traits,Compare,Combine,Section,Interval,Alloc>& src)
- { assign(src); return *this; }
-
- /// 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();
- // Can be implemented via _map.insert: Interval joining not necessary.
- const_FORALL(typename base_map_type, it, src)
- this->_map.insert(*it);
- }
+/// implements a map as a map of intervals - on insertion overlapping intervals are split and associated values are combined.
+/**
+ Template-class <b>split_interval_map</b>
+ implements a map as a map of intervals - On insertion overlapping intervals are
+ <b>split</b> and associated values are combined.
+
+ Template parameter <b>DomainT</b>: Domain type of the map. Also type of the
+ map's keys.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Datatypes for the codomain parameter have to <b>implement</b> operations
+ <tt>+=</tt>, <tt>-=</tt>, <tt>==</tt> (equality) and <tt>CodomainT()</tt> (default constructor).
+
+ The default constructor <tt>CodomainT()</tt> has to contruct a neutral element
+ such that the following holds:
+
+ If <tt>x = y; y += CodomainT();</tt> then <tt>x==y;</tt> and
+ If <tt>x = y; y -= CodomainT();</tt> then <tt>x==y;</tt>
+
+ Template parameter <b>Interval=itl::interval</b>: Template type of interval used
+ to implement the map. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>split_interval_map</b> implements a map <tt>map<DomainT, CodomainT></tt> as a map
+ of intervals <tt>map<interval<DomainT>, CodomainT, ExclusiveLessT<Interval> ></tt>
+
+ Interval maps <tt>split_interval_map<DomainT,CodomainT></tt> can be used similar (and in many
+ aspects exactly like) common stl-maps. Unlike to stl-maps where you store
+ a value for every key an interval map stores a contents value for an interval of
+ keys. In it's degenerated form the key intervals contain a single element
+ only. Then the interval map works like a normal stl-map. But if you work in problem
+ domains where you associate values to large contiguous intervals, interval maps
+ are very useful and efficient.
+
+
+ Class <tt>interval_base_map</tt> yields the following benefits:
+
+ <ul>
+ <li> A set of intervals is conceived as the domain set of the map.
+ The complexity involved with
+ operations on intervals maps is encapsulated. The user of the class who
+ wants to perform operations on interval maps is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>split_interval_map</b> gives an efficient implementation of maps consisting
+ of larger contiguous chunks. Very large, even uncountably infinite maps
+ can be represented in a compact way and handled efficiently.
+ <li>
+ <b>split_interval_map</b> serves as a overlay- or collision-computer.
+ </ul>
+
+ <b>split_interval_map as overlay computer</b>
+
+ An object <tt>split_interval_map<int,int> overlays;</tt> computes the overlays or
+ collisions of intervalls which have been inserted into it, if they are
+ associated with the <tt>int</tt>-value <tt>1</tt> as the codommain value.
+
+ If a newly inserted interval overlaps with intervals which are already in the
+ map, the interval is split up at the borders of the collisions. The assiciated
+ values of the overlapping intervals are incremented by 1, thus counting
+ the numbers of overlaps.
+
+ If sets are used as codomain types, interval_maps will compute unions of
+ associated maps in case of interval collisions.
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+
+ These functions are tagged in the documentation. Using such functions
+ for continuous domain datatypes yields compiletime errors. C.f. getting
+ the <tt>first()</tt> element of a left open interval makes sense for intervals of
+ int but not for intervals of double.
+
+ @author Joachim Faulhaber
+*/
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits = itl::partial_absorber,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
+ ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, CodomainT),
+ ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_et, CodomainT),
+ template<class,ITL_COMPARE>class Interval = itl::interval,
+ ITL_ALLOC Alloc = std::allocator
+>
+class split_interval_map:
+ public interval_base_map<split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
+ DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
+{
+public:
+ typedef Traits traits;
+ typedef split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> type;
+ typedef interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> joint_type;
+ typedef type overloadable_type;
+
+ typedef interval_base_map <split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
+ DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc> base_type;
+
+ typedef Interval<DomainT,Compare> interval_type;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::element_type element_type;
+ typedef typename base_type::segment_type segment_type;
+ typedef typename base_type::domain_mapping_type domain_mapping_type;
+ typedef typename base_type::interval_mapping_type interval_mapping_type;
+ typedef typename base_type::ImplMapT ImplMapT;
+
+ typedef typename base_type::codomain_combine codomain_combine;
+
+ typedef interval_set<DomainT,Compare,Interval,Alloc> interval_set_type;
+ typedef interval_set_type set_type;
+
+ enum { fineness = 3 };
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
+ split_interval_map(): base_type() {}
+ /// Copy constructor
+ split_interval_map(const split_interval_map& src): base_type(src) {}
+
+ explicit split_interval_map(domain_mapping_type& base_pair): base_type()
+ { add(base_pair); }
+
+ explicit split_interval_map(const value_type& value_pair): base_type()
+ { add(value_pair); }
+
+ /// Assignment operator
+ template<class SubType>
+ split_interval_map& operator =
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Compare,Combine,Section,Interval,Alloc>& src)
+ { assign(src); return *this; }
+
+ /// 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();
+ // Can be implemented via _map.insert: Interval joining not necessary.
+ const_FORALL(typename base_map_type, it, src)
+ this->_map.insert(*it);
+ }
+
+private:
+ // The following _suffixed function templates funx_ are implementations
+ // correspoding unsuffixed function templates funx of the base class.
+ // For funx_ want to be used in the base class via derived SubType pointer:
+ // that()->funx_. So they must be either public or made accessible by a
+ // friend declaration:
+ friend class
+ interval_base_map
+ <split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
+ DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc >;
 
- private:
- // The following _suffixed function templates funx_ are implementations
- // correspoding unsuffixed function templates funx of the base class.
- // For funx_ want to be used in the base class via derived SubType pointer:
- // that()->funx_. So they must be either public or made accessible by a
- // friend declaration:
- friend class
- interval_base_map
- <split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>,
- DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc >;
-
- bool contains_(const value_type& x)const;
-
- template<class Combiner>
- void add_(const value_type&);
-
- template<class Combiner>
- void subtract_(const value_type&);
-
- void insert_(const value_type& value);
- void erase_(const value_type& value);
-
- private:
- void handle_neighbours(const iterator& it){}
-
- void fill(const value_type&);
-
- template<class Combiner>
- void fill_gap(const value_type&);
-
- template<class Combiner>
- void add_rest(const interval_type& x_itv, const CodomainT& x_val,
- iterator& it, iterator& end_it);
-
- template<class Combiner>
- void add_rear(const interval_type& x_itv, const CodomainT& x_val,
- iterator& it);
-
- template<class Combiner>
- void subtract_rest(const interval_type& x_itv, const CodomainT& x_val,
- iterator& it, iterator& end_it);
-
- void insert_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
- void insert_rear(const interval_type& x_itv, const CodomainT& x_val, iterator& it);
-
- void erase_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
- } ;
-
-
- template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
- bool split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
- ::contains_(const value_type& interv_value)const
- {
- interval_type interv = interv_value.KEY_VALUE;
- if(interv.empty())
- return true;
-
- type section;
- add_intersection(section, interv);
- return is_element_equal(section, type(interv_value));
- }
+ bool contains_(const value_type& x)const;
+
+ template<class Combiner>
+ void add_(const value_type&);
+
+ template<class Combiner>
+ void subtract_(const value_type&);
+
+ void insert_(const value_type& value);
+ void erase_(const value_type& value);
+
+private:
+ void handle_neighbours(const iterator& it){}
+
+ void fill(const value_type&);
+
+ template<class Combiner>
+ void fill_gap(const value_type&);
+
+ template<class Combiner>
+ void add_rest(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it, iterator& end_it);
+
+ template<class Combiner>
+ void add_rear(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it);
+
+ template<class Combiner>
+ void subtract_rest(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it, iterator& end_it);
+
+ void insert_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+ void insert_rear(const interval_type& x_itv, const CodomainT& x_val, iterator& it);
+
+ void erase_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+} ;
+
+
+template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+bool split_interval_map<DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
+ ::contains_(const value_type& interv_value)const
+{
+ interval_type interv = interv_value.KEY_VALUE;
+ if(interv.empty())
+ return true;
+
+ type section;
+ add_intersection(section, interv);
+ return is_element_equal(section, type(interv_value));
+}
 
 
 

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 2009-02-11 07:58:42 EST (Wed, 11 Feb 2009)
@@ -36,392 +36,395 @@
 namespace boost{namespace itl
 {
 
- /// implements a set as a set of intervals - on insertion overlapping intervals are split
- /**
- Template-class <b>split_interval_set</b>
- implements a set as a set of intervals - bordering interval bounds are not merged
-
- Template parameter <b>DomainT</b>: The set's domain-type. Type of the
- set's elements.
-
- Suitable as domain types are all datatypes that posess a partial order.
- In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
- atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
-
- Template parameter <b>Interval=itl::interval</b>: Type of interval used
- to implement the set. The default <b>itl::interval</b> uses the
- interval class template that comes with this library. Own implementation of interval
- classes are possible (but not trivial).
-
- <b>split_interval_set</b> implements a set <tt>set<DomainT></tt> as a set of intervals
- <tt>set<interval<DomainT>></tt>. Intervals will not be <b>not</b> merged on
- insertion, if they border each other or overlap. The inserted intervalls will be
- be preserved.
-
- interval_base_set<DomainT> can thus be used like a set. As it is known from mathematics
- the union over a set of intervls is a set itself.
-
- <b>Class <tt>interval_set</tt> yields the following benefits: </b>
-
- <ul>
- <li>
- A set of intervals is conceived as a set. The complexity involved with
- operations on intervals and sets of intervals is encapsulated.
- The user of the class who
- wants to perform set operations on sets of intervals is no more concerned
- with questions of overlapping, joining and bordering intervals.
- <li>
- <b>interval_set</b> gives an efficient implementation of sets consisting
- of larger contiguous chunks. Very large, even uncountably infinite sets of
- elements can be represented in a compact way and handled efficiently.
- </ul>
-
- <b>Restrictions: </b>
-
- A small number of functions can only be used for <b>discrete</b> domain datatypes
- (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
- These functions are tagged in the documentation.
-
- @author Joachim Faulhaber
-
- */
- template
- <
- typename DomainT,
- ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
- template<class,ITL_COMPARE>class Interval = itl::interval,
- ITL_ALLOC Alloc = std::allocator
- >
- class split_interval_set:
- public interval_base_set<split_interval_set<DomainT,Compare,Interval,Alloc>,
- DomainT,Compare,Interval,Alloc>
- {
- public:
- typedef interval_base_set<itl::split_interval_set<DomainT,Compare,Interval,Alloc>,
- DomainT,Compare,Interval,Alloc> base_type;
-
- typedef split_interval_set<DomainT,Compare,Interval,Alloc> type;
- typedef interval_set<DomainT,Compare,Interval,Alloc> joint_type;
- typedef type overloadable_type;
-
- /// The domain type of the set
- typedef DomainT domain_type;
- /// The codomaintype is the same as domain_type
- typedef DomainT codomain_type;
-
- /// The element type of the set
- typedef DomainT element_type;
- /// The interval type of the set
- typedef Interval<DomainT,Compare> interval_type;
- /// The segment type of the set
- typedef interval_type segment_type;
-
- /// Comparison functor for domain values
- typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
- /// Comparison functor for intervals
- typedef exclusive_less<interval_type> interval_compare;
-
- /// Comparison functor for keys
- typedef exclusive_less<interval_type> key_compare;
-
- /// The allocator type of the set
- typedef Alloc<interval_type> allocator_type;
-
- /// allocator type of the corresponding element set
- typedef Alloc<DomainT> domain_allocator_type;
-
- /// The type of the set of elements that is equivalent to the set of intervals
- typedef typename itl::set<DomainT,Compare,Alloc> element_set;
-
- /// The corresponding atomized type representing this interval container of elements
- typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
-
- /// Container type for the implementation
- typedef typename itl::set<interval_type,ITL_EXCLUSIVE_LESS(interval_type),Alloc> ImplSetT;
-
- /// key type of the implementing container
- typedef typename ImplSetT::key_type key_type;
- /// data type of the implementing container
- typedef typename ImplSetT::data_type data_type;
- /// value type of the implementing container
- typedef typename ImplSetT::value_type value_type;
-
- /// iterator for iteration over intervals
- typedef typename ImplSetT::iterator iterator;
- /// const_iterator for iteration over intervals
- typedef typename ImplSetT::const_iterator const_iterator;
-
-
- enum { fineness = 3 };
-
- // B: Constructors, destructors, assignment
- /// Default constructor for the empty set
- split_interval_set(): base_type() {}
- /// Copy constructor
- split_interval_set(const split_interval_set& src): base_type(src) {}
-
- /// Copy constructor for base_type
- template<class SubType>
- split_interval_set
- (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- { assign(src); }
-
- /// Constructor for a single element
- explicit split_interval_set(const interval_type& elem): base_type() { add(elem); }
- /// Constructor for a single interval
- explicit split_interval_set(const domain_type& itv): base_type() { add(itv); }
-
- /// Assignment operator
- template<class SubType>
- split_interval_set& operator =
- (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- { assign(src); return *this; }
-
- /// Assignment from a base interval_set.
- template<class SubType>
- void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- {
- typedef interval_base_set<SubType,DomainT,Compare,Interval,Alloc> base_set_type;
- this->clear();
- // Can be implemented via _set.insert: Interval joining not necessary.
- const_FORALL(typename base_set_type, it, src)
- this->_set.insert(*it);
- }
-
- private:
- friend class
- interval_base_set<split_interval_set<DomainT,Compare,Interval,Alloc>,
- DomainT,Compare,Interval,Alloc>;
-
- /// Does the set contain the interval <tt>x</tt>?
- bool contains_(const interval_type& x)const;
-
- /// Insertion of an interval <tt>x</tt>
- void add_(const value_type& x);
-
- /// Removal of an interval <tt>x</tt>
- void subtract_(const value_type& x);
-
- private:
- /// Treatment of adjoint intervals on insertion
- void handle_neighbours(const iterator& it){}
-
- void insert_rest(const interval_type& x_itv, iterator& it, iterator& end_it);
- void subtract_rest(const interval_type& x_itv, iterator& it, iterator& end_it);
- } ;
-
- template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
- bool split_interval_set<DomainT,Compare,Interval,Alloc>::contains_(const interval_type& interv)const
+/// implements a set as a set of intervals - on insertion overlapping intervals are split
+/**
+ Template-class <b>split_interval_set</b>
+ implements a set as a set of intervals - bordering interval bounds are not merged
+
+ Template parameter <b>DomainT</b>: The set's domain-type. Type of the
+ set's elements.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Template parameter <b>Interval=itl::interval</b>: Type of interval used
+ to implement the set. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>split_interval_set</b> implements a set <tt>set<DomainT></tt> as a set of intervals
+ <tt>set<interval<DomainT>></tt>. Intervals will not be <b>not</b> merged on
+ insertion, if they border each other or overlap. The inserted intervalls will be
+ be preserved.
+
+ interval_base_set<DomainT> can thus be used like a set. As it is known from mathematics
+ the union over a set of intervls is a set itself.
+
+ <b>Class <tt>interval_set</tt> yields the following benefits: </b>
+
+ <ul>
+ <li>
+ A set of intervals is conceived as a set. The complexity involved with
+ operations on intervals and sets of intervals is encapsulated.
+ The user of the class who
+ wants to perform set operations on sets of intervals is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_set</b> gives an efficient implementation of sets consisting
+ of larger contiguous chunks. Very large, even uncountably infinite sets of
+ elements can be represented in a compact way and handled efficiently.
+ </ul>
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+ These functions are tagged in the documentation.
+
+ @author Joachim Faulhaber
+
+*/
+template
+<
+ typename DomainT,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
+ template<class,ITL_COMPARE>class Interval = itl::interval,
+ ITL_ALLOC Alloc = std::allocator
+>
+class split_interval_set:
+ public interval_base_set<split_interval_set<DomainT,Compare,Interval,Alloc>,
+ DomainT,Compare,Interval,Alloc>
+{
+public:
+ typedef interval_base_set<itl::split_interval_set<DomainT,Compare,Interval,Alloc>,
+ DomainT,Compare,Interval,Alloc> base_type;
+
+ typedef split_interval_set<DomainT,Compare,Interval,Alloc> type;
+ typedef interval_set<DomainT,Compare,Interval,Alloc> joint_type;
+ typedef type overloadable_type;
+
+ /// The domain type of the set
+ typedef DomainT domain_type;
+ /// The codomaintype is the same as domain_type
+ typedef DomainT codomain_type;
+
+ /// The element type of the set
+ typedef DomainT element_type;
+ /// The interval type of the set
+ typedef Interval<DomainT,Compare> interval_type;
+ /// The segment type of the set
+ typedef interval_type segment_type;
+
+ /// Comparison functor for domain values
+ typedef ITL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
+ /// Comparison functor for intervals
+ typedef exclusive_less<interval_type> interval_compare;
+
+ /// Comparison functor for keys
+ typedef exclusive_less<interval_type> key_compare;
+
+ /// The allocator type of the set
+ typedef Alloc<interval_type> allocator_type;
+
+ /// allocator type of the corresponding element set
+ typedef Alloc<DomainT> domain_allocator_type;
+
+ /// The corresponding atomized type representing this interval container of elements
+ typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
+
+ /// Container type for the implementation
+ typedef typename itl::set<interval_type,ITL_EXCLUSIVE_LESS(interval_type),Alloc> ImplSetT;
+
+ /// key type of the implementing container
+ typedef typename ImplSetT::key_type key_type;
+ /// data type of the implementing container
+ typedef typename ImplSetT::data_type data_type;
+ /// value type of the implementing container
+ typedef typename ImplSetT::value_type value_type;
+
+ /// iterator for iteration over intervals
+ typedef typename ImplSetT::iterator iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplSetT::const_iterator const_iterator;
+
+ enum { fineness = 3 };
+
+public:
+ //==========================================================================
+ //= Construct, copy, destruct
+ //==========================================================================
+ /// Default constructor for the empty object
+ split_interval_set(): base_type() {}
+
+ /// Copy constructor
+ split_interval_set(const split_interval_set& src): base_type(src) {}
+
+ /// Copy constructor for base_type
+ template<class SubType>
+ split_interval_set
+ (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
+ { assign(src); }
+
+ /// Constructor for a single element
+ explicit split_interval_set(const interval_type& elem): base_type() { add(elem); }
+ /// Constructor for a single interval
+ explicit split_interval_set(const domain_type& itv): base_type() { add(itv); }
+
+ /// Assignment operator
+ template<class SubType>
+ split_interval_set& operator =
+ (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
+ { assign(src); return *this; }
+
+ /// Assignment from a base interval_set.
+ template<class SubType>
+ void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
     {
- if(interv.empty())
- return true;
-
- type section;
- add_intersection(section, interv);
- return is_element_equal(section, type(interv));
+ typedef interval_base_set<SubType,DomainT,Compare,Interval,Alloc> base_set_type;
+ this->clear();
+ // Can be implemented via _set.insert: Interval joining not necessary.
+ const_FORALL(typename base_set_type, it, src)
+ this->_set.insert(*it);
     }
+
+private:
+ friend class
+ interval_base_set<split_interval_set<DomainT,Compare,Interval,Alloc>,
+ DomainT,Compare,Interval,Alloc>;
+
+ /// Does the set contain the interval <tt>x</tt>?
+ bool contains_(const interval_type& x)const;
+
+ /// Insertion of an interval <tt>x</tt>
+ void add_(const value_type& x);
+
+ /// Removal of an interval <tt>x</tt>
+ void subtract_(const value_type& x);
+
+private:
+ /// Treatment of adjoint intervals on insertion
+ void handle_neighbours(const iterator& it){}
+
+ void insert_rest(const interval_type& x_itv, iterator& it, iterator& end_it);
+ void subtract_rest(const interval_type& x_itv, iterator& it, iterator& end_it);
+} ;
 
+template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+bool split_interval_set<DomainT,Compare,Interval,Alloc>::contains_(const interval_type& interv)const
+{
+ if(interv.empty())
+ return true;
 
- template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
- void split_interval_set<DomainT,Compare,Interval,Alloc>::add_(const value_type& x)
- {
- if(x.empty()) return;
-
- std::pair<typename ImplSetT::iterator,bool> insertion = this->_set.insert(x);
-
- if(!insertion.WAS_SUCCESSFUL)
- {
- iterator fst_it = this->_set.lower_bound(x);
- iterator end_it = this->_set.upper_bound(x);
-
- if(fst_it == this->_set.end())
- fst_it = end_it;
-
- iterator cur_it = fst_it ;
- interval_type cur_itv = *cur_it;
+ type section;
+ add_intersection(section, interv);
+ return is_element_equal(section, type(interv));
+}
 
- interval_type leadGap; x.right_subtract(leadGap, cur_itv);
- // this is a new Interval that is a gap in the current map
- add_(leadGap);
 
- // only for the first there can be a leftResid: a part of *it left of x
- interval_type leftResid; cur_itv.right_subtract(leftResid, x);
+template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+void split_interval_set<DomainT,Compare,Interval,Alloc>::add_(const value_type& x)
+{
+ if(x.empty()) return;
 
- // handle special case for first
- interval_type interSec;
- cur_itv.intersect(interSec, x);
-
- iterator snd_it = fst_it; snd_it++;
- if(snd_it == end_it)
- {
- // first == last
-
- interval_type endGap; x.left_subtract(endGap, cur_itv);
- // this is a new Interval that is a gap in the current map
- add_(endGap);
-
- // only for the last there can be a rightResid: a part of *it right of x
- interval_type rightResid; (*cur_it).left_subtract(rightResid, x);
-
- this->_set.erase(cur_it);
- add_(leftResid);
- add_(interSec);
- add_(rightResid);
- }
- else
- {
- this->_set.erase(cur_it);
- add_(leftResid);
- add_(interSec);
-
- // shrink interval
- interval_type x_rest(x);
- x_rest.left_subtract(cur_itv);
+ std::pair<typename ImplSetT::iterator,bool> insertion = this->_set.insert(x);
 
- insert_rest(x_rest, snd_it, end_it);
- }
- }
- }
+ if(!insertion.WAS_SUCCESSFUL)
+ {
+ iterator fst_it = this->_set.lower_bound(x);
+ iterator end_it = this->_set.upper_bound(x);
 
+ if(fst_it == this->_set.end())
+ fst_it = end_it;
 
- template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
- void split_interval_set<DomainT,Compare,Interval,Alloc>::insert_rest(const interval_type& x_itv, iterator& it, iterator& end_it)
- {
- iterator nxt_it = it; nxt_it++;
+ iterator cur_it = fst_it ;
+ interval_type cur_itv = *cur_it;
 
- interval_type cur_itv = *it;
-
- interval_type newGap; x_itv.right_subtract(newGap, cur_itv);
+ interval_type leadGap; x.right_subtract(leadGap, cur_itv);
         // this is a new Interval that is a gap in the current map
- add_(newGap);
+ add_(leadGap);
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; cur_itv.right_subtract(leftResid, x);
 
+ // handle special case for first
         interval_type interSec;
- cur_itv.intersect(interSec, x_itv);
+ cur_itv.intersect(interSec, x);
 
- if(nxt_it==end_it)
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
         {
- interval_type endGap; x_itv.left_subtract(endGap, cur_itv);
+ // first == last
+
+ interval_type endGap; x.left_subtract(endGap, cur_itv);
             // this is a new Interval that is a gap in the current map
             add_(endGap);
 
             // only for the last there can be a rightResid: a part of *it right of x
- interval_type rightResid; cur_itv.left_subtract(rightResid, x_itv);
+ interval_type rightResid; (*cur_it).left_subtract(rightResid, x);
 
- this->_set.erase(it);
+ this->_set.erase(cur_it);
+ add_(leftResid);
             add_(interSec);
             add_(rightResid);
         }
         else
- {
- this->_set.erase(it);
+ {
+ this->_set.erase(cur_it);
+ add_(leftResid);
             add_(interSec);
 
             // shrink interval
- interval_type x_rest(x_itv);
+ interval_type x_rest(x);
             x_rest.left_subtract(cur_itv);
 
- insert_rest(x_rest, nxt_it, end_it);
+ insert_rest(x_rest, snd_it, end_it);
         }
     }
+}
 
 
- template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
- void split_interval_set<DomainT,Compare,Interval,Alloc>::subtract_(const value_type& x)
- {
- if(x.empty()) return;
- if(this->_set.empty()) return;
+template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+void split_interval_set<DomainT,Compare,Interval,Alloc>::insert_rest(const interval_type& x_itv, iterator& it, iterator& end_it)
+{
+ iterator nxt_it = it; nxt_it++;
 
- iterator fst_it;
- if(x.exclusive_less(*(this->_set.begin())))
- return;
- if(x.lower() < this->_set.begin()->upper())
- fst_it = this->_set.begin();
- else
- fst_it = this->_set.lower_bound(x);
+ interval_type cur_itv = *it;
+
+ interval_type newGap; x_itv.right_subtract(newGap, cur_itv);
+ // this is a new Interval that is a gap in the current map
+ add_(newGap);
 
- if(fst_it==this->_set.end()) return;
- iterator end_it = this->_set.upper_bound(x);
- if(fst_it==end_it) return;
+ interval_type interSec;
+ cur_itv.intersect(interSec, x_itv);
 
- iterator cur_it = fst_it ;
- interval_type cur_itv = *cur_it ;
+ if(nxt_it==end_it)
+ {
+ interval_type endGap; x_itv.left_subtract(endGap, cur_itv);
+ // this is a new Interval that is a gap in the current map
+ add_(endGap);
 
- // only for the first there can be a leftResid: a part of *it left of x
- interval_type leftResid; cur_itv.right_subtract(leftResid, x);
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; cur_itv.left_subtract(rightResid, x_itv);
 
- // handle special case for first
- interval_type interSec;
- cur_itv.intersect(interSec, x);
+ this->_set.erase(it);
+ add_(interSec);
+ add_(rightResid);
+ }
+ else
+ {
+ this->_set.erase(it);
+ add_(interSec);
+
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(cur_itv);
 
- iterator snd_it = fst_it; snd_it++;
- if(snd_it == end_it)
- {
- // first == last
- // only for the last there can be a rightResid: a part of *it right of x
- interval_type rightResid; (*cur_it).left_subtract(rightResid, x);
+ insert_rest(x_rest, nxt_it, end_it);
+ }
+}
 
- this->_set.erase(cur_it);
- add_(leftResid);
- add_(rightResid);
- }
- else
- {
- // first AND NOT last
- this->_set.erase(cur_it);
- add_(leftResid);
- subtract_rest(x, snd_it, end_it);
- }
+
+template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+void split_interval_set<DomainT,Compare,Interval,Alloc>::subtract_(const value_type& x)
+{
+ if(x.empty()) return;
+ if(this->_set.empty()) return;
+
+ iterator fst_it;
+ if(x.exclusive_less(*(this->_set.begin())))
         return;
+ if(x.lower() < this->_set.begin()->upper())
+ fst_it = this->_set.begin();
+ else
+ fst_it = this->_set.lower_bound(x);
+
+ if(fst_it==this->_set.end()) return;
+ iterator end_it = this->_set.upper_bound(x);
+ if(fst_it==end_it) return;
+
+ iterator cur_it = fst_it ;
+ interval_type cur_itv = *cur_it ;
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; cur_itv.right_subtract(leftResid, x);
+
+ // handle special case for first
+ interval_type interSec;
+ cur_itv.intersect(interSec, x);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // first == last
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*cur_it).left_subtract(rightResid, x);
+
+ this->_set.erase(cur_it);
+ add_(leftResid);
+ add_(rightResid);
     }
+ else
+ {
+ // first AND NOT last
+ this->_set.erase(cur_it);
+ add_(leftResid);
+ subtract_rest(x, snd_it, end_it);
+ }
+ return;
+}
 
 
 
- template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
- void split_interval_set<DomainT,Compare,Interval,Alloc>::subtract_rest(const interval_type& x_itv, iterator& snd_it, iterator& end_it)
- {
- iterator it=snd_it, nxt_it=snd_it; nxt_it++;
+template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
+void split_interval_set<DomainT,Compare,Interval,Alloc>::subtract_rest(const interval_type& x_itv, iterator& snd_it, iterator& end_it)
+{
+ iterator it=snd_it, nxt_it=snd_it; nxt_it++;
 
- while(nxt_it!=end_it)
- {
- { iterator victim; victim=it; it++; this->_set.erase(victim); }
- nxt_it=it; nxt_it++;
- }
+ while(nxt_it!=end_it)
+ {
+ { iterator victim; victim=it; it++; this->_set.erase(victim); }
+ nxt_it=it; nxt_it++;
+ }
 
- // it refers the last overlaying intervals of x_itv
- const interval_type& cur_itv = *it ;
+ // it refers the last overlaying intervals of x_itv
+ const interval_type& cur_itv = *it ;
 
- interval_type rightResid; cur_itv.left_subtract(rightResid, x_itv);
+ interval_type rightResid; cur_itv.left_subtract(rightResid, x_itv);
 
- if(rightResid.empty())
- this->_set.erase(it);
- else
- {
- interval_type interSec; cur_itv.intersect(interSec, x_itv);
- this->_set.erase(it);
- this->_set.insert(rightResid);
- }
+ if(rightResid.empty())
+ this->_set.erase(it);
+ else
+ {
+ interval_type interSec; cur_itv.intersect(interSec, x_itv);
+ this->_set.erase(it);
+ this->_set.insert(rightResid);
     }
+}
 
 
 
 
 
- /** 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 distiction between 'element equality' and 'lexicographical
- equality'. */
- template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class 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)
- {
- //MEMO PORT: This implemetation worked with stlport, sgi and gnu
- // implementations of the stl. But using MSVC-implementation
- // results in runtime error! So I had to provide an independent
- // safe implemetation.
- //return std::equal(lhs.begin(), lhs.end(), rhs.begin());
- return Set::lexicographical_equal(lhs, rhs);
- }
+//==============================================================================
+//= 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 distiction between 'element equality' and 'lexicographical
+ equality'. */
+template <typename DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class 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)
+{
+ //MEMO PORT: This implemetation worked with stlport, sgi and gnu
+ // implementations of the stl. But using MSVC-implementation
+ // results in runtime error! So I had to provide an independent
+ // safe implemetation.
+ //return std::equal(lhs.begin(), lhs.end(), rhs.begin());
+ return Set::lexicographical_equal(lhs, rhs);
+}
 
 //-----------------------------------------------------------------------------
 // type traits


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