Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65605 - in sandbox/itl: boost/itl boost/itl/concept boost/itl/concept/abstract boost/itl/concept/element boost/itl/concept/interval boost/itl/detail boost/itl/type_traits boost/itl_xt boost/validate/validater libs/itl/example/itvset_shell_ libs/itl/example/splititvmap_shell_ libs/itl/test libs/itl/test/fastest_itl_map_
From: afojgo_at_[hidden]
Date: 2010-09-26 10:11:15


Author: jofaber
Date: 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
New Revision: 65605
URL: http://svn.boost.org/trac/boost/changeset/65605

Log:
Refactoring: Extraction of helper functions on value types of associative containers. Reorganizing function families of concepts. Stable{msvc-9.0, gcc-3.4.4}
Added:
   sandbox/itl/boost/itl/concept/comparable.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/container.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/domain_comparable.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/element_associator.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/element_map.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/element_set.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/element_set_value.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/interval.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/interval_associator.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/interval_map.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/interval_set.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/interval_set_value.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/map_value.hpp (contents, props changed)
   sandbox/itl/boost/itl/concept/set_value.hpp (contents, props changed)
   sandbox/itl/boost/itl/type_traits/is_domain_comparable.hpp (contents, props changed)
Removed:
   sandbox/itl/boost/itl/concept/abstract/comparable.hpp
   sandbox/itl/boost/itl/concept/abstract/container.hpp
   sandbox/itl/boost/itl/concept/element/map.hpp
   sandbox/itl/boost/itl/concept/element/set.hpp
   sandbox/itl/boost/itl/concept/element/set_or_map.hpp
   sandbox/itl/boost/itl/concept/interval/map.hpp
   sandbox/itl/boost/itl/concept/interval/set.hpp
   sandbox/itl/boost/itl/concept/interval/set_or_map.hpp
   sandbox/itl/boost/itl/interval_functions.hpp
Text files modified:
   sandbox/itl/boost/itl/closed_interval.hpp | 2
   sandbox/itl/boost/itl/continuous_interval.hpp | 2
   sandbox/itl/boost/itl/detail/associated_value.hpp | 2
   sandbox/itl/boost/itl/detail/base_interval.hpp | 10 ++--
   sandbox/itl/boost/itl/detail/design_config.hpp | 3 -
   sandbox/itl/boost/itl/detail/element_comparer.hpp | 16 ++++----
   sandbox/itl/boost/itl/detail/interval_map_algo.hpp | 8 ++--
   sandbox/itl/boost/itl/detail/interval_morphism.hpp | 20 ++++++-----
   sandbox/itl/boost/itl/detail/interval_set_algo.hpp | 70 +++++++++++++--------------------------
   sandbox/itl/boost/itl/detail/interval_subset_comparer.hpp | 43 ++++++++++++------------
   sandbox/itl/boost/itl/detail/map_algo.hpp | 2
   sandbox/itl/boost/itl/detail/set_algo.hpp | 30 +++++++++--------
   sandbox/itl/boost/itl/detail/subset_comparer.hpp | 20 ++++++-----
   sandbox/itl/boost/itl/discrete_interval.hpp | 2
   sandbox/itl/boost/itl/interval.hpp | 2
   sandbox/itl/boost/itl/interval_base_map.hpp | 52 ++++++++---------------------
   sandbox/itl/boost/itl/interval_base_set.hpp | 29 ++-------------
   sandbox/itl/boost/itl/interval_set.hpp | 7 +--
   sandbox/itl/boost/itl/map.hpp | 46 ++-----------------------
   sandbox/itl/boost/itl/rightopen_interval.hpp | 12 ------
   sandbox/itl/boost/itl/set.hpp | 37 +++-----------------
   sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp | 2 +
   sandbox/itl/boost/itl_xt/tuple_computer.hpp | 7 +++
   sandbox/itl/boost/validate/validater/concept_validater.hpp | 1
   sandbox/itl/libs/itl/example/itvset_shell_/itvset_shell.cpp | 1
   sandbox/itl/libs/itl/example/splititvmap_shell_/splititvmap_shell.cpp | 1
   sandbox/itl/libs/itl/test/fastest_itl_map_/fastest_itl_map_cases.hpp | 2
   sandbox/itl/libs/itl/test/test_value_maker.hpp | 1
   28 files changed, 152 insertions(+), 278 deletions(-)

Modified: sandbox/itl/boost/itl/closed_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/closed_interval.hpp (original)
+++ sandbox/itl/boost/itl/closed_interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -11,7 +11,7 @@
 #include <boost/itl/type_traits/value_size.hpp>
 #include <boost/itl/type_traits/type_to_string.hpp>
 #include <boost/itl/detail/base_interval.hpp>
-#include <boost/itl/interval_functions.hpp>
+#include <boost/itl/concept/interval.hpp>
 
 namespace boost{namespace itl
 {

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

Deleted: sandbox/itl/boost/itl/concept/abstract/container.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/abstract/container.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,81 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_ABSTRACT_CONTAINER_HPP_JOFA_100923
-#define BOOST_ITL_CONCEPT_ABSTRACT_CONTAINER_HPP_JOFA_100923
-
-#include <boost/itl/type_traits/is_container.hpp>
-
-namespace boost{ namespace itl
-{
-
-//==============================================================================
-//= Emptieness
-//==============================================================================
-
-/** Tests if the container is empty.
- Complexity: constant. */
-template<class Type>
-typename enable_if<is_container<Type>, bool>::type
-is_empty(const Type& object)
-{
- return object.begin()==object.end();
-}
-
-
-/** All content of the container is dropped.
- Complexity: linear. */
-template<class Type>
-typename enable_if<is_container<Type>, void>::type
-clear(Type& object)
-{
- object.erase(object.begin(), object.end());
-}
-
-//==============================================================================
-//= Size
-//==============================================================================
-
-template<class Type>
-typename enable_if<is_container<Type>, typename Type::size_type>::type
-iterative_size(const Type& object)
-{
- return object.size();
-}
-
-//==============================================================================
-//= Swap
-//==============================================================================
-
-template<class Type>
-typename enable_if<is_container<Type>, void>::type
-swap(Type& left, Type& right)
-{
- left.swap(right); //JODO test
-}
-
-//==============================================================================
-//= Iteration
-//==============================================================================
-
-template<class Type>
-typename enable_if<is_container<Type>, typename Type::iterator>::type
-cyclic_prior(Type& object, typename Type::iterator it_)
-{ return it_ == object.begin() ? object.end() : --it_; }
-
-template<class Type>
-typename enable_if<is_container<Type>, typename Type::const_iterator>::type
-cyclic_prior(const Type& object, typename Type::const_iterator it_)
-{ return it_ == object.begin() ? object.end() : --it_; }
-
-
-
-}} // namespace boost itl
-
-#endif
-
-

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

Added: sandbox/itl/boost/itl/concept/container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/container.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,81 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_CONTAINER_HPP_JOFA_100923
+#define BOOST_ITL_CONCEPT_CONTAINER_HPP_JOFA_100923
+
+#include <boost/itl/type_traits/is_container.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= Emptieness
+//==============================================================================
+
+/** Tests if the container is empty.
+ Complexity: constant. */
+template<class Type>
+typename enable_if<is_container<Type>, bool>::type
+is_empty(const Type& object)
+{
+ return object.begin()==object.end();
+}
+
+
+/** All content of the container is dropped.
+ Complexity: linear. */
+template<class Type>
+typename enable_if<is_container<Type>, void>::type
+clear(Type& object)
+{
+ object.erase(object.begin(), object.end());
+}
+
+//==============================================================================
+//= Size
+//==============================================================================
+
+template<class Type>
+typename enable_if<is_container<Type>, typename Type::size_type>::type
+iterative_size(const Type& object)
+{
+ return object.size();
+}
+
+//==============================================================================
+//= Swap
+//==============================================================================
+
+template<class Type>
+typename enable_if<is_container<Type>, void>::type
+swap(Type& left, Type& right)
+{
+ left.swap(right); //JODO test
+}
+
+//==============================================================================
+//= Iteration
+//==============================================================================
+
+template<class Type>
+typename enable_if<is_container<Type>, typename Type::iterator>::type
+cyclic_prior(Type& object, typename Type::iterator it_)
+{ return it_ == object.begin() ? object.end() : --it_; }
+
+template<class Type>
+typename enable_if<is_container<Type>, typename Type::const_iterator>::type
+cyclic_prior(const Type& object, typename Type::const_iterator it_)
+{ return it_ == object.begin() ? object.end() : --it_; }
+
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/domain_comparable.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/domain_comparable.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,43 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_DOMAIN_COMPARABLE_HPP_JOFA_100925
+#define BOOST_ITL_CONCEPT_DOMAIN_COMPARABLE_HPP_JOFA_100925
+
+#include <boost/itl/type_traits/is_domain_comparable.hpp>
+
+namespace boost{ namespace itl
+{
+
+template<class Type>
+inline typename enable_if<is_domain_comparable<Type>, bool>::type
+domain_less(const typename Type::domain_param left, const typename Type::domain_param right)
+{
+ return typename Type::domain_compare()(left, right);
+}
+
+template<class Type>
+inline typename enable_if<is_domain_comparable<Type>, bool>::type
+domain_less_equal(const typename Type::domain_param left, const typename Type::domain_param right)
+{
+ return !(typename Type::domain_compare()(right, left));
+}
+
+template<class Type>
+inline typename enable_if<is_domain_comparable<Type>, bool>::type
+domain_equal(const typename Type::domain_param left, const typename Type::domain_param right)
+{
+ typedef typename Type::domain_compare domain_compare;
+ return !domain_compare()(left, right) && !domain_compare()(right, left);
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Deleted: sandbox/itl/boost/itl/concept/element/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/element/map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,446 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_ELEMENT_MAP_HPP_JOFA_100921
-#define BOOST_ITL_CONCEPT_ELEMENT_MAP_HPP_JOFA_100921
-
-#include <boost/mpl/and.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/itl/detail/map_algo.hpp>
-#include <boost/itl/type_traits/is_total.hpp>
-#include <boost/itl/type_traits/absorbs_neutrons.hpp>
-#include <boost/itl/type_traits/is_associative_element_container.hpp>
-#include <boost/itl/type_traits/is_combinable.hpp>
-
-namespace boost{ namespace itl
-{
-
-//NOTE: Some forward declarations are needed by some compilers.
-template<class Type, class Predicate>
-typename enable_if<is_associative_element_container<Type>, Type>::type&
-erase_if(const Predicate& pred, Type& object);
-
-
-//==============================================================================
-//= Containedness<ElementMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- bool within(c P&, c T&) T:{m} P:{b} fragment_types
-//------------------------------------------------------------------------------
-/** Checks if a key-value pair is in the map */
-template<class Type>
-typename enable_if<is_element_map<Type>, bool>::type
-within(const typename Type::element_type& value_pair, const Type& super)
-{
- typedef typename Type::const_iterator const_iterator;
- const_iterator found_ = super.find(value_pair.first);
- return found_ != super.end() && found_->second == value_pair.second;
-}
-
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{m} P:{b} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_element_map<Type>, bool>::type
-contains(const Type& super, const typename Type::element_type& value_pair)
-{
- return itl::within(value_pair, super);
-}
-
-//==============================================================================
-//= Equivalences and Orderings<ElementSet|ElementMap>
-//==============================================================================
-
-/** Protonic equality is equality on all elements that do not carry a neutron as content. */
-template<class Type>
-inline typename enable_if<is_element_map<Type>, bool>::type
-is_protonic_equal(const Type& lhs, const Type& rhs)
-{
- return Map::lexicographical_protonic_equal(lhs, rhs);
-}
-
-//==============================================================================
-//= Addition
-//==============================================================================
-/** \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. */
-template <class Type>
-typename enable_if<is_element_map<Type>, Type>::type&
-add(Type& object, const typename Type::value_type& value_pair)
-{
- return object.add(value_pair);
-}
-
-/** \c add add \c value_pair into the map using \c prior as a hint to
- insert \c value_pair after the position \c prior is pointing to. */
-template <class Type>
-typename enable_if<is_element_map<Type>, typename Type::iterator>::type
-add(Type& object, typename Type::iterator prior,
- const typename Type::value_type& value_pair)
-{
- return object.add(prior, value_pair);
-}
-
-//==============================================================================
-//= Erasure
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& erase(T&, c P&) T:{m} P:{b} fragment_type
-//------------------------------------------------------------------------------
-template <class Type>
-typename enable_if<is_element_map<Type>, typename Type::size_type>::type
-erase(Type& object, const typename Type::element_type& value_pair)
-{
- typedef typename Type::size_type size_type;
- typedef typename Type::iterator iterator;
- typedef typename Type::on_neutron_absorbtion on_neutron_absorbtion;
-
- if(on_neutron_absorbtion::is_absorbable(value_pair.second))
- return neutron<size_type>::value();
-
- iterator it_ = object.find(value_pair.first);
- if(it_ != object.end() && value_pair.second == it_->second)
- {
- object.erase(it_);
- return unon<size_type>::value();
- }
-
- return neutron<size_type>::value();
-}
-
-template<class Type>
-typename enable_if<is_element_map<Type>, Type>::type&
-erase(Type& object, const typename Type::set_type& erasure)
-{
- typedef typename Type::set_type set_type;
- ITL_const_FORALL(typename set_type, elem_, erasure)
- itl::erase(object, *elem_);
-
- return object;
-}
-
-//==============================================================================
-//= Subtraction
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{m} P:{b} fragment_type
-//------------------------------------------------------------------------------
-template <class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::element_type& operand)
-{
- return object.subtract(operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{m} P:{e} key_type
-//------------------------------------------------------------------------------
-template <class Type>
-typename enable_if<is_element_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::domain_type& key_value)
-{
- return itl::erase(object, key_value);
-}
-
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{m} P:{s} set key_type
-//------------------------------------------------------------------------------
-template <class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type&
-operator -= (Type& object, const typename Type::set_type& subtrahend)
-{
- return Set::erase(object, subtrahend); //JODO
-}
-
-template <class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
-operator - (Type object, const typename Type::set_type& subtrahend)
-{
- return object -= subtrahend;
-}
-
-//==============================================================================
-//= Intersection
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_element_map<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::element_type& operand)
-{
- object.add_intersection(section, operand);
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, void>::type
-add_intersection(Type& section, const Type& object, const Type& operand)
-{
- ITL_const_FORALL(typename Type, it_, operand)
- itl::add_intersection(section, object, *it_);
-}
-
-//------------------------------------------------------------------------------
-//- T& op &=(T&, c P&) T:{m} P:{b m} fragment_types
-//------------------------------------------------------------------------------
-
-template<class Type>
-inline typename enable_if<mpl::and_<is_element_map<Type>, is_total<Type> >, Type>::type&
-operator &=(Type& object, const typename Type::element_type& operand)
-{
- object.add(operand);
- return object;
-}
-
-template<class Type>
-inline typename enable_if<mpl::and_<is_element_map<Type>, mpl::not_<is_total<Type> > >, Type>::type&
-operator &=(Type& object, const typename Type::element_type& operand)
-{
- Type section;
- itl::add_intersection(section, object, operand);
- object.swap(section);
- return object;
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
-operator & (Type object, const typename Type::element_type& operand)
-{
- return object &= operand;
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
-operator & (const typename Type::element_type& operand, Type object)
-{
- return object &= operand;
-}
-
-
-template<class Type>
-inline typename enable_if<mpl::and_<is_element_map<Type>, is_total<Type> >, Type>::type&
-operator &=(Type& object, const Type& operand)
-{
- object += operand;
- return object;
-}
-
-template<class Type>
-inline typename enable_if<mpl::and_<is_element_map<Type>, mpl::not_<is_total<Type> > >, Type>::type&
-operator &=(Type& object, const Type& operand)
-{
- Type section;
- itl::add_intersection(section, object, operand);
- object.swap(section);
- return object;
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
-operator & (Type object, const Type& operand)
-{
- return object &= operand;
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
-operator & (Type object, const typename Type::key_object_type& operand)
-{
- return object &= operand; //JODO test a - (a & s) == a - s
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
-operator & (const typename Type::key_object_type& operand, Type object)
-{
- return object &= operand; //JODO test a - (s & a) == a - s
-}
-
-//==============================================================================
-//= Intersection<ElementMap> bool intersects(x,y)
-//==============================================================================
-template<class Type, class CoType>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , is_total<Type> >
- , bool>::type
-intersects(const Type&, const CoType&)
-{
- return true;
-}
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-intersects(const Type& object, const typename Type::domain_type& operand)
-{
- return itl::contains(object, operand);
-}
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-intersects(const Type& object, const typename Type::set_type& operand)
-{
- if(object.iterative_size() < operand.iterative_size())
- return Map::intersects(object, operand);
- else
- return Map::intersects(operand, object);
-}
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-intersects(const Type& object, const typename Type::element_type& operand)
-{
- Type intersection; //JODO opti
- itl::add_intersection(intersection, object, operand);
- return !intersection.empty();
-}
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-intersects(const Type& object, const Type& operand)
-{
- if(object.iterative_size() < operand.iterative_size())
- return Map::intersects(object, operand);
- else
- return Map::intersects(operand, object);
-}
-
-//==============================================================================
-//= Symmetric difference
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type&
-flip(Type& object, const typename Type::element_type& operand)
-{
- return object.flip(operand);
-}
-
-template<class Type, class CoType>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , is_total<Type>
- , absorbs_neutrons<Type> >
- , Type>::type&
-operator ^= (Type& object, const CoType&)
-{
- itl::clear(object);
- return object;
-}
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , is_total<Type>
- , mpl::not_<absorbs_neutrons<Type> > >
- , Type>::type&
-operator ^= (Type& object, const typename Type::element_type& operand)
-{
- return object.flip(operand);
-}
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , is_total<Type>
- , mpl::not_<absorbs_neutrons<Type> > >
- , Type>::type&
-operator ^= (Type& object, const Type& operand)
-{
- ITL_const_FORALL(typename Type, it_, operand)
- itl::flip(object, *it_);
-
- ITL_FORALL(typename Type, it2_, object)
- it2_->second = neutron<typename Type::codomain_type>::value();
-
- return object;
-}
-
-
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , mpl::not_<is_total<Type> > >
- , Type>::type&
-operator ^= (Type& object, const typename Type::element_type& operand)
-{
- return itl::flip(object, operand);
-}
-
-/** Symmetric subtract map \c x2 and \c *this.
- So \c *this becomes the symmetric difference of \c *this and \c x2 */
-template<class Type>
-inline typename enable_if< mpl::and_< is_element_map<Type>
- , mpl::not_<is_total<Type> > >
- , Type>::type&
-operator ^= (Type& object, const Type& operand)
-{
- typedef typename Type::const_iterator const_iterator;
- const_iterator it_ = operand.begin();
- while(it_ != operand.end())
- itl::flip(object, *it_++);
-
- return object;
-}
-
-
-//==============================================================================
-//= Set selection
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_element_map<Type>,
- typename Type::set_type>::type&
-domain(typename Type::set_type& domain_set, const Type& object)
-{
- typename Type::set_type::iterator prior_ = domain_set.end();
- typename Type::const_iterator it_ = object.begin();
- while(it_ != object.end())
- prior_ = domain_set.insert(prior_, (*it_++).first);
-
- return domain_set;
-}
-
-//==============================================================================
-//= Neutron absorbtion
-//==============================================================================
-template<class Type>
-inline typename enable_if<mpl::and_< is_element_map<Type>
- , absorbs_neutrons<Type> >, Type>::type&
-absorb_neutrons(Type& object)
-{
- typedef typename Type::element_type element_type;
- return itl::erase_if(content_is_neutron<element_type>(), object);
-}
-
-template<class Type>
-inline typename enable_if<mpl::and_< is_element_map<Type>
- , mpl::not_<absorbs_neutrons<Type> > >
- , Type>::type&
-absorb_neutrons(Type&){}
-
-//==============================================================================
-//= Streaming<ElementMap>
-//==============================================================================
-template<class CharType, class CharTraits, class Type>
-inline typename enable_if<is_element_map<Type>, std::basic_ostream<CharType, CharTraits> >::type&
-operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
-{
- stream << "{";
- ITL_const_FORALL(typename Type, it, object)
- stream << "(" << it->first << "->" << it->second << ")";
-
- return stream << "}";
-}
-
-
-}} // namespace boost itl
-
-#endif
-
-

Deleted: sandbox/itl/boost/itl/concept/element/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/element/set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,141 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_ELEMENT_SET_HPP_JOFA_100921
-#define BOOST_ITL_CONCEPT_ELEMENT_SET_HPP_JOFA_100921
-
-#include <boost/itl/type_traits/is_combinable.hpp>
-
-namespace boost{ namespace itl
-{
-
-//==============================================================================
-//= Addition
-//==============================================================================
-/** \c add inserts \c operand into the map if it's key does
- not exist in the map.
- If \c operands's key value exists in the map, it's data
- value is added to the data value already found in the map. */
-template <class Type>
-typename enable_if<is_element_set<Type>, Type>::type&
-add(Type& object, const typename Type::element_type& operand)
-{
- object.insert(operand);
- return object;
-}
-
-/** \c add add \c operand into the map using \c prior as a hint to
- insert \c operand after the position \c prior is pointing to. */
-template <class Type>
-typename enable_if<is_element_set<Type>, typename Type::iterator>::type
-add(Type& object, typename Type::iterator prior,
- const typename Type::element_type& operand)
-{
- return object.insert(prior, operand);
-}
-
-//==============================================================================
-//= Subtraction
-//==============================================================================
-/** If the \c operand's key value is in the map, it's data value is
- subtraced from the data value stored in the map. */
-template<class Type>
-typename enable_if<is_element_set<Type>, Type>::type&
-subtract(Type& object, const typename Type::element_type& operand)
-{
- typedef typename Type::iterator iterator;
- iterator it_ = object.find(operand);
- if(it_ != object.end())
- object.erase(it_);
-
- return object;
-}
-
-
-//==============================================================================
-//= Intersection
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_element_set<Type>, Type>::type
-operator & (Type object, const Type& operand)
-{
- return object &= operand;
-}
-
-template<class Type>
-inline typename enable_if<is_element_set<Type>, bool>::type
-intersects(const Type& object, const typename Type::domain_type& operand)
-{
- return itl::contains(object, operand);
-}
-
-template<class Type>
-inline typename enable_if<is_element_set<Type>, bool>::type
-intersects(const Type& object, const Type& operand)
-{
- if(iterative_size(object) < iterative_size(operand))
- return Set::intersects(object, operand);
- else
- return Set::intersects(operand, object);
-}
-
-//==============================================================================
-//= Symmetric difference
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_element_set<Type>, Type>::type&
-flip(Type& object, const typename Type::element_type& operand)
-{
- typedef typename Type::iterator iterator;
- std::pair<iterator,bool> insertion = object.insert(operand);
- if(!insertion.second)
- object.erase(insertion.first);
-
- return object;
-}
-
-template<class Type>
-inline typename enable_if<is_element_set<Type>, Type>::type&
-operator ^= (Type& object, const typename Type::element_tpye& operand)
-{
- return itl::flip(object, operand);
-}
-
-/** Symmetric subtract map \c x2 and \c *this.
- So \c *this becomes the symmetric difference of \c *this and \c x2 */
-template<class Type>
-inline typename enable_if<is_element_set<Type>, Type>::type&
-operator ^= (Type& object, const Type& operand)
-{
- typedef typename Type::const_iterator const_iterator;
- const_iterator it_ = operand.begin();
- while(it_ != operand.end())
- itl::flip(object, *it_++);
-
- return object;
-}
-
-//==============================================================================
-//= Streaming<ElementSet>
-//==============================================================================
-template<class CharType, class CharTraits, class Type>
-inline typename enable_if<is_element_set<Type>, std::basic_ostream<CharType, CharTraits> >::type&
-operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
-{
- stream << "{";
- ITL_const_FORALL(typename Type, it, object)
- stream << *it << " ";
-
- return stream << "}";
-}
-
-
-}} // namespace boost itl
-
-#endif
-
-

Deleted: sandbox/itl/boost/itl/concept/element/set_or_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/element/set_or_map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,477 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_ELEMENT_SET_OR_MAP_HPP_JOFA_100921
-#define BOOST_ITL_CONCEPT_ELEMENT_SET_OR_MAP_HPP_JOFA_100921
-
-#include <boost/itl/type_traits/is_associative_element_container.hpp>
-#include <boost/itl/type_traits/is_key_container_of.hpp>
-#include <boost/itl/type_traits/is_combinable.hpp>
-#include <boost/itl/concept/element/set.hpp>
-#include <boost/itl/concept/element/map.hpp>
-
-namespace boost{ namespace itl
-{
-//JODO Declaration forwarding for gcc-3.4.4
-template <class Type>
-typename enable_if<is_element_set<Type>, Type>::type&
-add(Type& object, const typename Type::element_type& operand);
-
-//==============================================================================
-//= Size
-//==============================================================================
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
-size(const Type& object)
-{
- return itl::iterative_size(object);
-}
-
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
-cardinality(const Type& object)
-{
- return itl::iterative_size(object);
-}
-
-
-//==============================================================================
-//= Containedness<ElementSet|ElementMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- bool within(c P&, c T&) T:{s}|{m} P:{e}|{i} fragment_types|key_types
-//------------------------------------------------------------------------------
-/** Checks if a key is in the associative container */
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, bool>::type
-within(const typename Type::domain_type& key, const Type& super)
-{
- return !(super.find(key) == super.end());
-}
-
-//------------------------------------------------------------------------------
-//- bool within(c P&, c T&) T:{s}|{m} P:{s'} fragment_types|key_types
-//------------------------------------------------------------------------------
-template<class SubT, class SuperT>
-typename enable_if<mpl::and_< is_associative_element_container<SuperT>
- , is_key_container_of<SubT, SuperT> >,
- bool>::type
-within(const SubT& sub, const SuperT& super)
-{
- if(itl::is_empty(sub)) return true;
- if(itl::is_empty(super)) return false;
- if(itl::size(super) < itl::size(sub)) return false;
-
- typename SubT::const_iterator common_lwb_;
- typename SubT::const_iterator common_upb_;
- if(!Set::common_range(common_lwb_, common_upb_, sub, super))
- return false;
-
- typename SubT::const_iterator sub_ = sub.begin();
- typename SuperT::const_iterator super_;
- while(sub_ != sub.end())
- {
- super_ = super.find(SubT::key_value(sub_));
- if(super_ == super.end())
- return false;
- else if(!co_equal(sub_, super_, &sub, &super))
- return false;
-
- ++sub_;
- }
- return true;
-}
-
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{s}|{m} P:{e}|{i} fragment_types|key_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, bool>::type
-contains(const Type& super, const typename Type::domain_type& key)
-{
- return itl::within(key, super);
-}
-
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{s}|{m} P:{s'} fragment_types|key_types
-//------------------------------------------------------------------------------
-template<class SubT, class SuperT>
-typename enable_if<mpl::and_< is_associative_element_container<SuperT>
- , is_key_container_of<SubT, SuperT> >,
- bool>::type
-contains(const SuperT& super, const SubT& sub)
-{
- return itl::within(sub, super);
-}
-
-//==============================================================================
-//= Equivalences and Orderings
-//==============================================================================
-
-#ifdef BOOST_MSVC
-#pragma warning(push)
-#pragma warning(disable:4996) //'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
-#endif // I do guarantee here that I am using the parameters correctly :)
-
-/** Standard equality, which is lexicographical equality of the sets
- as sequences, that are given by their Compare order. */
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, bool>::type
-operator == (const Type& left, const Type& right)
-{
- return left.size() == right.size()
- && std::equal(left.begin(), left.end(), right.begin());
-}
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, bool>::type
-is_element_equal(const Type& left, const Type& right)
-{ return left == right; }
-
-
-/* Strict weak less ordering which is given by the Compare order */
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, bool>::type
-operator < (const Type& left, const Type& right)
-{
- return std::lexicographical_compare(
- left.begin(), left.end(), right.begin(), right.end(),
- typename Type::element_compare()
- );
-}
-
-//==============================================================================
-//= Addition
-//==============================================================================
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator += (Type& object, const typename Type::element_type& operand)
-{
- return itl::add(object, operand);
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator + (Type object, const typename Type::element_type& operand)
-{
- return object += operand;
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator + (const typename Type::element_type& operand, Type object)
-{
- return object += operand;
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator += (Type& object, const Type& operand)
-{
- return Set::add(object, operand);
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator + (Type object, const Type& operand)
-{
- return object += operand;
-}
-
-//==============================================================================
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator |= (Type& object, const typename Type::element_type& operand)
-{
- return itl::add(object, operand);
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator | (Type object, const typename Type::element_type& operand)
-{
- return object += operand;
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator | (const typename Type::element_type& operand, Type object)
-{
- return object += operand;
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator |= (Type& object, const Type& operand)
-{
- return Set::add(object, operand);
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator | (Type object, const Type& operand)
-{
- return object += operand;
-}
-
-
-//==============================================================================
-//= Insertion
-//==============================================================================
-//------------------------------------------------------------------------------
-//- V insert(T&, c P&) T:{s}|{m} P:{e}|{b} fragment_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_associative_element_container<Type>,
- std::pair<typename Type::iterator,bool> >::type
-insert(Type& object, const typename Type::element_type& operand)
-{
- return object.insert(operand);
-}
-
-template<class Type>
-typename enable_if<is_associative_element_container<Type>,
- typename Type::iterator>::type
-insert(Type& object, typename Type::iterator prior,
- const typename Type::element_type& operand)
-{
- return object.insert(prior, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T insert(T&, c T&) T:{s m} map fragment_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, Type>::type&
-insert(Type& object, const Type& addend)
-{
- typedef typename Type::iterator iterator;
-
- iterator prior_ = object.end();
- ITL_const_FORALL(typename Type, elem_, addend)
- itl::insert(object, prior_, *elem_);
-
- return object;
-}
-
-
-//==============================================================================
-//= Erasure
-//==============================================================================
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
-erase(Type& object, const typename Type::domain_type& key_value)
-{
- typedef typename Type::size_type size_type;
- typename Type::iterator it_ = object.find(key_value);
- if(it_ != object.end())
- {
- object.erase(it_);
- return unon<size_type>::value();
- }
- return neutron<size_type>::value();
-}
-
-template<class Type>
-typename enable_if<is_associative_element_container<Type>, Type>::type&
-erase(Type& object, const Type& erasure)
-{
- ITL_const_FORALL(typename Type, elem_, erasure)
- itl::erase(object, *elem_);
-
- return object;
-}
-
-
-
-//==============================================================================
-//= Subtraction<ElementSet|ElementMap>
-//==============================================================================
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator -= (Type& object, const typename Type::element_type& operand)
-{
- return itl::subtract(object, operand);
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator - (Type object, const typename Type::element_type& operand)
-{
- return object -= operand;
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator -= (Type& object, const Type& subtrahend)
-{
- ITL_const_FORALL(typename Type, it_, subtrahend)
- itl::subtract(object, *it_);
-
- return object;
-}
-
-template <class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator - (Type object, const Type& subtrahend)
-{
- return object -= subtrahend;
-}
-
-
-//==============================================================================
-//= Intersection
-//==============================================================================
-//------------------------------------------------------------------------------
-//- void add_intersection(T&, c T&, c P&) T:{s}{m} P:{e}{e} key_type
-//------------------------------------------------------------------------------
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::domain_type& operand)
-{
- typedef typename Type::const_iterator const_iterator;
- const_iterator it_ = object.find(operand);
- if(it_ != object.end())
- itl::add(section, *it_);
-}
-
-//------------------------------------------------------------------------------
-//- void add_intersection(T&, c T&, c P&) T:{s}{m} P:{s}{s} set key_type
-//------------------------------------------------------------------------------
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::key_object_type& operand)
-{
- typedef typename Type::key_object_type key_object_type;
- typedef typename key_object_type::const_iterator const_iterator;
- const_iterator common_lwb_, common_upb_;
- if(!Set::common_range(common_lwb_, common_upb_, operand, object))
- return;
-
- const_iterator sec_ = common_lwb_;
- while(sec_ != common_upb_)
- add_intersection(section, object, *sec_++);
-}
-
-//------------------------------------------------------------------------------
-//- Intersection<ElementMap|ElementSet>
-//------------------------------------------------------------------------------
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator &= (Type& object, const typename Type::domain_type& operand)
-{
- Type section;
- add_intersection(section, object, operand);
- object.swap(section);
- return object;
-}
-
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator & (Type object, const typename Type::domain_type& operand)
-{
- return object &= operand;
-}
-
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator & (const typename Type::domain_type& operand, Type object)
-{
- return object &= operand;
-}
-
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-operator &= (Type& object, const typename Type::key_object_type& operand)
-{
- Type section;
- add_intersection(section, object, operand);
- object.swap(section);
- return object;
-}
-//------------------------------------------------------------------------------
-
-template<class Type, class CoType>
-inline typename enable_if<is_associative_element_container<Type>, bool>::type
-disjoint(const Type& left, const Type& right)
-{
- return !intersects(left, right);
-}
-
-//==============================================================================
-//= Symmetric difference<ElementSet|ElementMap>
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator ^ (Type object, const typename Type::element_type& operand)
-{
- return itl::flip(object, operand);
-}
-
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator ^ (const typename Type::element_type& operand, Type object)
-{
- return itl::flip(object, operand);
-}
-
-template<class Type>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type
-operator ^ (Type object, const Type& operand)
-{
- return object ^= operand;
-}
-
-
-//==============================================================================
-//= Manipulation by predicates
-//==============================================================================
-template<class Type, class Predicate>
-typename enable_if<is_associative_element_container<Type>, Type>::type&
-erase_if(const Predicate& pred, Type& object)
-{
- typename Type::iterator it_ = object.begin();
- while(it_ != object.end())
- if(pred(*it_))
- itl::erase(object, it_++);
- else ++it_;
- return object;
-}
-
-template<class Type, class Predicate>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-add_if(const Predicate& pred, Type& object, const Type& src)
-{
- typename Type::const_iterator it_ = src.begin();
- while(it_ != src.end())
- if(pred(*it_))
- itl::add(object, *it_++);
-
- return object;
-}
-
-template<class Type, class Predicate>
-inline typename enable_if<is_associative_element_container<Type>, Type>::type&
-assign_if(const Predicate& pred, Type& object, const Type& src)
-{
- itl::clear(object);
- return add_if(object, src, pred);
-}
-
-
-
-}} // namespace boost itl
-
-#endif
-
-

Added: sandbox/itl/boost/itl/concept/element_associator.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/element_associator.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,477 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_ELEMENT_ASSOCIATOR_HPP_JOFA_100921
+#define BOOST_ITL_CONCEPT_ELEMENT_ASSOCIATOR_HPP_JOFA_100921
+
+#include <boost/itl/type_traits/is_associative_element_container.hpp>
+#include <boost/itl/type_traits/is_key_container_of.hpp>
+#include <boost/itl/type_traits/is_combinable.hpp>
+#include <boost/itl/concept/element_set.hpp>
+#include <boost/itl/concept/element_map.hpp>
+
+namespace boost{ namespace itl
+{
+//JODO Declaration forwarding for gcc-3.4.4
+template <class Type>
+typename enable_if<is_element_set<Type>, Type>::type&
+add(Type& object, const typename Type::element_type& operand);
+
+//==============================================================================
+//= Size
+//==============================================================================
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
+size(const Type& object)
+{
+ return itl::iterative_size(object);
+}
+
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ return itl::iterative_size(object);
+}
+
+
+//==============================================================================
+//= Containedness<ElementSet|ElementMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- bool within(c P&, c T&) T:{s}|{m} P:{e}|{i} fragment_types|key_types
+//------------------------------------------------------------------------------
+/** Checks if a key is in the associative container */
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, bool>::type
+within(const typename Type::domain_type& key, const Type& super)
+{
+ return !(super.find(key) == super.end());
+}
+
+//------------------------------------------------------------------------------
+//- bool within(c P&, c T&) T:{s}|{m} P:{s'} fragment_types|key_types
+//------------------------------------------------------------------------------
+template<class SubT, class SuperT>
+typename enable_if<mpl::and_< is_associative_element_container<SuperT>
+ , is_key_container_of<SubT, SuperT> >,
+ bool>::type
+within(const SubT& sub, const SuperT& super)
+{
+ if(itl::is_empty(sub)) return true;
+ if(itl::is_empty(super)) return false;
+ if(itl::size(super) < itl::size(sub)) return false;
+
+ typename SubT::const_iterator common_lwb_;
+ typename SubT::const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, sub, super))
+ return false;
+
+ typename SubT::const_iterator sub_ = sub.begin();
+ typename SuperT::const_iterator super_;
+ while(sub_ != sub.end())
+ {
+ super_ = super.find(key_value<SubT>(sub_));
+ if(super_ == super.end())
+ return false;
+ else if(!co_equal(sub_, super_, &sub, &super))
+ return false;
+
+ ++sub_;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{s}|{m} P:{e}|{i} fragment_types|key_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, bool>::type
+contains(const Type& super, const typename Type::domain_type& key)
+{
+ return itl::within(key, super);
+}
+
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{s}|{m} P:{s'} fragment_types|key_types
+//------------------------------------------------------------------------------
+template<class SubT, class SuperT>
+typename enable_if<mpl::and_< is_associative_element_container<SuperT>
+ , is_key_container_of<SubT, SuperT> >,
+ bool>::type
+contains(const SuperT& super, const SubT& sub)
+{
+ return itl::within(sub, super);
+}
+
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4996) //'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
+#endif // I do guarantee here that I am using the parameters correctly :)
+
+/** Standard equality, which is lexicographical equality of the sets
+ as sequences, that are given by their Compare order. */
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+operator == (const Type& left, const Type& right)
+{
+ return left.size() == right.size()
+ && std::equal(left.begin(), left.end(), right.begin());
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+is_element_equal(const Type& left, const Type& right)
+{ return left == right; }
+
+
+/* Strict weak less ordering which is given by the Compare order */
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+operator < (const Type& left, const Type& right)
+{
+ return std::lexicographical_compare(
+ left.begin(), left.end(), right.begin(), right.end(),
+ typename Type::element_compare()
+ );
+}
+
+//==============================================================================
+//= Addition
+//==============================================================================
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator += (Type& object, const typename Type::element_type& operand)
+{
+ return itl::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator + (Type object, const typename Type::element_type& operand)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator + (const typename Type::element_type& operand, Type object)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator += (Type& object, const Type& operand)
+{
+ return Set::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator + (Type object, const Type& operand)
+{
+ return object += operand;
+}
+
+//==============================================================================
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator |= (Type& object, const typename Type::element_type& operand)
+{
+ return itl::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator | (Type object, const typename Type::element_type& operand)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator | (const typename Type::element_type& operand, Type object)
+{
+ return object += operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator |= (Type& object, const Type& operand)
+{
+ return Set::add(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator | (Type object, const Type& operand)
+{
+ return object += operand;
+}
+
+
+//==============================================================================
+//= Insertion
+//==============================================================================
+//------------------------------------------------------------------------------
+//- V insert(T&, c P&) T:{s}|{m} P:{e}|{b} fragment_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_associative_element_container<Type>,
+ std::pair<typename Type::iterator,bool> >::type
+insert(Type& object, const typename Type::element_type& operand)
+{
+ return object.insert(operand);
+}
+
+template<class Type>
+typename enable_if<is_associative_element_container<Type>,
+ typename Type::iterator>::type
+insert(Type& object, typename Type::iterator prior,
+ const typename Type::element_type& operand)
+{
+ return object.insert(prior, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T insert(T&, c T&) T:{s m} map fragment_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, Type>::type&
+insert(Type& object, const Type& addend)
+{
+ typedef typename Type::iterator iterator;
+
+ iterator prior_ = object.end();
+ ITL_const_FORALL(typename Type, elem_, addend)
+ itl::insert(object, prior_, *elem_);
+
+ return object;
+}
+
+
+//==============================================================================
+//= Erasure
+//==============================================================================
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
+erase(Type& object, const typename Type::domain_type& key_value)
+{
+ typedef typename Type::size_type size_type;
+ typename Type::iterator it_ = object.find(key_value);
+ if(it_ != object.end())
+ {
+ object.erase(it_);
+ return unon<size_type>::value();
+ }
+ return neutron<size_type>::value();
+}
+
+template<class Type>
+typename enable_if<is_associative_element_container<Type>, Type>::type&
+erase(Type& object, const Type& erasure)
+{
+ ITL_const_FORALL(typename Type, elem_, erasure)
+ itl::erase(object, *elem_);
+
+ return object;
+}
+
+
+
+//==============================================================================
+//= Subtraction<ElementSet|ElementMap>
+//==============================================================================
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator -= (Type& object, const typename Type::element_type& operand)
+{
+ return itl::subtract(object, operand);
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator - (Type object, const typename Type::element_type& operand)
+{
+ return object -= operand;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator -= (Type& object, const Type& subtrahend)
+{
+ ITL_const_FORALL(typename Type, it_, subtrahend)
+ itl::subtract(object, *it_);
+
+ return object;
+}
+
+template <class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator - (Type object, const Type& subtrahend)
+{
+ return object -= subtrahend;
+}
+
+
+//==============================================================================
+//= Intersection
+//==============================================================================
+//------------------------------------------------------------------------------
+//- void add_intersection(T&, c T&, c P&) T:{s}{m} P:{e}{e} key_type
+//------------------------------------------------------------------------------
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::domain_type& operand)
+{
+ typedef typename Type::const_iterator const_iterator;
+ const_iterator it_ = object.find(operand);
+ if(it_ != object.end())
+ itl::add(section, *it_);
+}
+
+//------------------------------------------------------------------------------
+//- void add_intersection(T&, c T&, c P&) T:{s}{m} P:{s}{s} set key_type
+//------------------------------------------------------------------------------
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::key_object_type& operand)
+{
+ typedef typename Type::key_object_type key_object_type;
+ typedef typename key_object_type::const_iterator const_iterator;
+ const_iterator common_lwb_, common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, operand, object))
+ return;
+
+ const_iterator sec_ = common_lwb_;
+ while(sec_ != common_upb_)
+ add_intersection(section, object, *sec_++);
+}
+
+//------------------------------------------------------------------------------
+//- Intersection<ElementMap|ElementSet>
+//------------------------------------------------------------------------------
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator &= (Type& object, const typename Type::domain_type& operand)
+{
+ Type section;
+ add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator & (Type object, const typename Type::domain_type& operand)
+{
+ return object &= operand;
+}
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator & (const typename Type::domain_type& operand, Type object)
+{
+ return object &= operand;
+}
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+operator &= (Type& object, const typename Type::key_object_type& operand)
+{
+ Type section;
+ add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+//------------------------------------------------------------------------------
+
+template<class Type, class CoType>
+inline typename enable_if<is_associative_element_container<Type>, bool>::type
+disjoint(const Type& left, const Type& right)
+{
+ return !intersects(left, right);
+}
+
+//==============================================================================
+//= Symmetric difference<ElementSet|ElementMap>
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator ^ (Type object, const typename Type::element_type& operand)
+{
+ return itl::flip(object, operand);
+}
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator ^ (const typename Type::element_type& operand, Type object)
+{
+ return itl::flip(object, operand);
+}
+
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator ^ (Type object, const Type& operand)
+{
+ return object ^= operand;
+}
+
+
+//==============================================================================
+//= Manipulation by predicates
+//==============================================================================
+template<class Type, class Predicate>
+typename enable_if<is_associative_element_container<Type>, Type>::type&
+erase_if(const Predicate& pred, Type& object)
+{
+ typename Type::iterator it_ = object.begin();
+ while(it_ != object.end())
+ if(pred(*it_))
+ itl::erase(object, it_++);
+ else ++it_;
+ return object;
+}
+
+template<class Type, class Predicate>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+add_if(const Predicate& pred, Type& object, const Type& src)
+{
+ typename Type::const_iterator it_ = src.begin();
+ while(it_ != src.end())
+ if(pred(*it_))
+ itl::add(object, *it_++);
+
+ return object;
+}
+
+template<class Type, class Predicate>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type&
+assign_if(const Predicate& pred, Type& object, const Type& src)
+{
+ itl::clear(object);
+ return add_if(object, src, pred);
+}
+
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/element_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/element_map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,449 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_ELEMENT_MAP_HPP_JOFA_100921
+#define BOOST_ITL_CONCEPT_ELEMENT_MAP_HPP_JOFA_100921
+
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/itl/type_traits/is_total.hpp>
+#include <boost/itl/type_traits/absorbs_neutrons.hpp>
+#include <boost/itl/type_traits/is_associative_element_container.hpp>
+#include <boost/itl/type_traits/is_combinable.hpp>
+
+#include <boost/itl/concept/map_value.hpp>
+#include <boost/itl/detail/map_algo.hpp>
+
+
+namespace boost{ namespace itl
+{
+
+//NOTE: Some forward declarations are needed by some compilers.
+template<class Type, class Predicate>
+typename enable_if<is_associative_element_container<Type>, Type>::type&
+erase_if(const Predicate& pred, Type& object);
+
+
+//==============================================================================
+//= Containedness<ElementMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- bool within(c P&, c T&) T:{m} P:{b} fragment_types
+//------------------------------------------------------------------------------
+/** Checks if a key-value pair is in the map */
+template<class Type>
+typename enable_if<is_element_map<Type>, bool>::type
+within(const typename Type::element_type& value_pair, const Type& super)
+{
+ typedef typename Type::const_iterator const_iterator;
+ const_iterator found_ = super.find(value_pair.first);
+ return found_ != super.end() && found_->second == value_pair.second;
+}
+
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{m} P:{b} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_element_map<Type>, bool>::type
+contains(const Type& super, const typename Type::element_type& value_pair)
+{
+ return itl::within(value_pair, super);
+}
+
+//==============================================================================
+//= Equivalences and Orderings<ElementMap>
+//==============================================================================
+
+/** Protonic equality is equality on all elements that do not carry a neutron as content. */
+template<class Type>
+inline typename enable_if<is_element_map<Type>, bool>::type
+is_protonic_equal(const Type& lhs, const Type& rhs)
+{
+ return Map::lexicographical_protonic_equal(lhs, rhs);
+}
+
+//==============================================================================
+//= Addition<ElementMap>
+//==============================================================================
+/** \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. */
+template <class Type>
+typename enable_if<is_element_map<Type>, Type>::type&
+add(Type& object, const typename Type::value_type& value_pair)
+{
+ return object.add(value_pair);
+}
+
+/** \c add add \c value_pair into the map using \c prior as a hint to
+ insert \c value_pair after the position \c prior is pointing to. */
+template <class Type>
+typename enable_if<is_element_map<Type>, typename Type::iterator>::type
+add(Type& object, typename Type::iterator prior,
+ const typename Type::value_type& value_pair)
+{
+ return object.add(prior, value_pair);
+}
+
+//==============================================================================
+//= Erasure
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& erase(T&, c P&) T:{m} P:{b} fragment_type
+//------------------------------------------------------------------------------
+template <class Type>
+typename enable_if<is_element_map<Type>, typename Type::size_type>::type
+erase(Type& object, const typename Type::element_type& value_pair)
+{
+ typedef typename Type::size_type size_type;
+ typedef typename Type::iterator iterator;
+ typedef typename Type::on_neutron_absorbtion on_neutron_absorbtion;
+
+ if(on_neutron_absorbtion::is_absorbable(value_pair.second))
+ return neutron<size_type>::value();
+
+ iterator it_ = object.find(value_pair.first);
+ if(it_ != object.end() && value_pair.second == it_->second)
+ {
+ object.erase(it_);
+ return unon<size_type>::value();
+ }
+
+ return neutron<size_type>::value();
+}
+
+template<class Type>
+typename enable_if<is_element_map<Type>, Type>::type&
+erase(Type& object, const typename Type::set_type& erasure)
+{
+ typedef typename Type::set_type set_type;
+ ITL_const_FORALL(typename set_type, elem_, erasure)
+ itl::erase(object, *elem_);
+
+ return object;
+}
+
+//==============================================================================
+//= Subtraction
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{m} P:{b} fragment_type
+//------------------------------------------------------------------------------
+template <class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::element_type& operand)
+{
+ return object.subtract(operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{m} P:{e} key_type
+//------------------------------------------------------------------------------
+template <class Type>
+typename enable_if<is_element_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::domain_type& key_value)
+{
+ return itl::erase(object, key_value);
+}
+
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{m} P:{s} set key_type
+//------------------------------------------------------------------------------
+template <class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type&
+operator -= (Type& object, const typename Type::set_type& subtrahend)
+{
+ return Set::erase(object, subtrahend); //JODO
+}
+
+template <class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type
+operator - (Type object, const typename Type::set_type& subtrahend)
+{
+ return object -= subtrahend;
+}
+
+//==============================================================================
+//= Intersection
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_element_map<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::element_type& operand)
+{
+ object.add_intersection(section, operand);
+}
+
+template<class Type>
+inline typename enable_if<is_element_map<Type>, void>::type
+add_intersection(Type& section, const Type& object, const Type& operand)
+{
+ ITL_const_FORALL(typename Type, it_, operand)
+ itl::add_intersection(section, object, *it_);
+}
+
+//------------------------------------------------------------------------------
+//- T& op &=(T&, c P&) T:{m} P:{b m} fragment_types
+//------------------------------------------------------------------------------
+
+template<class Type>
+inline typename enable_if<mpl::and_<is_element_map<Type>, is_total<Type> >, Type>::type&
+operator &=(Type& object, const typename Type::element_type& operand)
+{
+ object.add(operand);
+ return object;
+}
+
+template<class Type>
+inline typename enable_if<mpl::and_<is_element_map<Type>, mpl::not_<is_total<Type> > >, Type>::type&
+operator &=(Type& object, const typename Type::element_type& operand)
+{
+ Type section;
+ itl::add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+
+template<class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type
+operator & (Type object, const typename Type::element_type& operand)
+{
+ return object &= operand;
+}
+
+template<class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type
+operator & (const typename Type::element_type& operand, Type object)
+{
+ return object &= operand;
+}
+
+
+template<class Type>
+inline typename enable_if<mpl::and_<is_element_map<Type>, is_total<Type> >, Type>::type&
+operator &=(Type& object, const Type& operand)
+{
+ object += operand;
+ return object;
+}
+
+template<class Type>
+inline typename enable_if<mpl::and_<is_element_map<Type>, mpl::not_<is_total<Type> > >, Type>::type&
+operator &=(Type& object, const Type& operand)
+{
+ Type section;
+ itl::add_intersection(section, object, operand);
+ object.swap(section);
+ return object;
+}
+
+template<class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type
+operator & (Type object, const Type& operand)
+{
+ return object &= operand;
+}
+
+template<class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type
+operator & (Type object, const typename Type::key_object_type& operand)
+{
+ return object &= operand; //JODO test a - (a & s) == a - s
+}
+
+template<class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type
+operator & (const typename Type::key_object_type& operand, Type object)
+{
+ return object &= operand; //JODO test a - (s & a) == a - s
+}
+
+//==============================================================================
+//= Intersection<ElementMap> bool intersects(x,y)
+//==============================================================================
+template<class Type, class CoType>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , is_total<Type> >
+ , bool>::type
+intersects(const Type&, const CoType&)
+{
+ return true;
+}
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+intersects(const Type& object, const typename Type::domain_type& operand)
+{
+ return itl::contains(object, operand);
+}
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+intersects(const Type& object, const typename Type::set_type& operand)
+{
+ if(object.iterative_size() < operand.iterative_size())
+ return Map::intersects(object, operand);
+ else
+ return Map::intersects(operand, object);
+}
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+intersects(const Type& object, const typename Type::element_type& operand)
+{
+ Type intersection; //JODO opti
+ itl::add_intersection(intersection, object, operand);
+ return !intersection.empty();
+}
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+intersects(const Type& object, const Type& operand)
+{
+ if(object.iterative_size() < operand.iterative_size())
+ return Map::intersects(object, operand);
+ else
+ return Map::intersects(operand, object);
+}
+
+//==============================================================================
+//= Symmetric difference
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_element_map<Type>, Type>::type&
+flip(Type& object, const typename Type::element_type& operand)
+{
+ return object.flip(operand);
+}
+
+template<class Type, class CoType>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , is_total<Type>
+ , absorbs_neutrons<Type> >
+ , Type>::type&
+operator ^= (Type& object, const CoType&)
+{
+ itl::clear(object);
+ return object;
+}
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , is_total<Type>
+ , mpl::not_<absorbs_neutrons<Type> > >
+ , Type>::type&
+operator ^= (Type& object, const typename Type::element_type& operand)
+{
+ return object.flip(operand);
+}
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , is_total<Type>
+ , mpl::not_<absorbs_neutrons<Type> > >
+ , Type>::type&
+operator ^= (Type& object, const Type& operand)
+{
+ ITL_const_FORALL(typename Type, it_, operand)
+ itl::flip(object, *it_);
+
+ ITL_FORALL(typename Type, it2_, object)
+ it2_->second = neutron<typename Type::codomain_type>::value();
+
+ return object;
+}
+
+
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , Type>::type&
+operator ^= (Type& object, const typename Type::element_type& operand)
+{
+ return itl::flip(object, operand);
+}
+
+/** Symmetric subtract map \c x2 and \c *this.
+ So \c *this becomes the symmetric difference of \c *this and \c x2 */
+template<class Type>
+inline typename enable_if< mpl::and_< is_element_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , Type>::type&
+operator ^= (Type& object, const Type& operand)
+{
+ typedef typename Type::const_iterator const_iterator;
+ const_iterator it_ = operand.begin();
+ while(it_ != operand.end())
+ itl::flip(object, *it_++);
+
+ return object;
+}
+
+
+//==============================================================================
+//= Set selection
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_element_map<Type>,
+ typename Type::set_type>::type&
+domain(typename Type::set_type& domain_set, const Type& object)
+{
+ typename Type::set_type::iterator prior_ = domain_set.end();
+ typename Type::const_iterator it_ = object.begin();
+ while(it_ != object.end())
+ prior_ = domain_set.insert(prior_, (*it_++).first);
+
+ return domain_set;
+}
+
+//==============================================================================
+//= Neutron absorbtion
+//==============================================================================
+template<class Type>
+inline typename enable_if<mpl::and_< is_element_map<Type>
+ , absorbs_neutrons<Type> >, Type>::type&
+absorb_neutrons(Type& object)
+{
+ typedef typename Type::element_type element_type;
+ return itl::erase_if(content_is_neutron<element_type>(), object);
+}
+
+template<class Type>
+inline typename enable_if<mpl::and_< is_element_map<Type>
+ , mpl::not_<absorbs_neutrons<Type> > >
+ , Type>::type&
+absorb_neutrons(Type&){}
+
+//==============================================================================
+//= Streaming<ElementMap>
+//==============================================================================
+template<class CharType, class CharTraits, class Type>
+inline typename enable_if<is_element_map<Type>, std::basic_ostream<CharType, CharTraits> >::type&
+operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
+{
+ stream << "{";
+ ITL_const_FORALL(typename Type, it, object)
+ stream << "(" << it->first << "->" << it->second << ")";
+
+ return stream << "}";
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/element_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/element_set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,139 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_ELEMENT_SET_HPP_JOFA_100921
+#define BOOST_ITL_CONCEPT_ELEMENT_SET_HPP_JOFA_100921
+
+#include <boost/itl/type_traits/is_combinable.hpp>
+#include <boost/itl/concept/set_value.hpp>
+
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= Addition<ElementSet>
+//==============================================================================
+/** \c add inserts \c operand into the map if it's key does
+ not exist in the map.
+ If \c operands's key value exists in the map, it's data
+ value is added to the data value already found in the map. */
+template <class Type>
+typename enable_if<is_element_set<Type>, Type>::type&
+add(Type& object, const typename Type::element_type& operand)
+{
+ object.insert(operand);
+ return object;
+}
+
+/** \c add add \c operand into the map using \c prior as a hint to
+ insert \c operand after the position \c prior is pointing to. */
+template <class Type>
+typename enable_if<is_element_set<Type>, typename Type::iterator>::type
+add(Type& object, typename Type::iterator prior,
+ const typename Type::element_type& operand)
+{
+ return object.insert(prior, operand);
+}
+
+//==============================================================================
+//= Subtraction
+//==============================================================================
+/** If the \c operand's key value is in the map, it's data value is
+ subtraced from the data value stored in the map. */
+template<class Type>
+typename enable_if<is_element_set<Type>, Type>::type&
+subtract(Type& object, const typename Type::element_type& operand)
+{
+ object.erase(operand);
+ return object;
+}
+
+
+//==============================================================================
+//= Intersection
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_element_set<Type>, Type>::type
+operator & (Type object, const Type& operand)
+{
+ return object &= operand;
+}
+
+template<class Type>
+inline typename enable_if<is_element_set<Type>, bool>::type
+intersects(const Type& object, const typename Type::domain_type& operand)
+{
+ return itl::contains(object, operand);
+}
+
+template<class Type>
+inline typename enable_if<is_element_set<Type>, bool>::type
+intersects(const Type& object, const Type& operand)
+{
+ if(iterative_size(object) < iterative_size(operand))
+ return Set::intersects(object, operand);
+ else
+ return Set::intersects(operand, object);
+}
+
+//==============================================================================
+//= Symmetric difference
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_element_set<Type>, Type>::type&
+flip(Type& object, const typename Type::element_type& operand)
+{
+ typedef typename Type::iterator iterator;
+ std::pair<iterator,bool> insertion = object.insert(operand);
+ if(!insertion.second)
+ object.erase(insertion.first);
+
+ return object;
+}
+
+template<class Type>
+inline typename enable_if<is_element_set<Type>, Type>::type&
+operator ^= (Type& object, const typename Type::element_tpye& operand)
+{
+ return itl::flip(object, operand);
+}
+
+/** Symmetric subtract map \c x2 and \c *this.
+ So \c *this becomes the symmetric difference of \c *this and \c x2 */
+template<class Type>
+inline typename enable_if<is_element_set<Type>, Type>::type&
+operator ^= (Type& object, const Type& operand)
+{
+ typedef typename Type::const_iterator const_iterator;
+ const_iterator it_ = operand.begin();
+ while(it_ != operand.end())
+ itl::flip(object, *it_++);
+
+ return object;
+}
+
+//==============================================================================
+//= Streaming<ElementSet>
+//==============================================================================
+template<class CharType, class CharTraits, class Type>
+inline typename enable_if<is_element_set<Type>, std::basic_ostream<CharType, CharTraits> >::type&
+operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
+{
+ stream << "{";
+ ITL_const_FORALL(typename Type, it, object)
+ stream << *it << " ";
+
+ return stream << "}";
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/element_set_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/element_set_value.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,31 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_ELEMENT_SET_VALUE_HPP_JOFA_100924
+#define BOOST_ITL_CONCEPT_ELEMENT_SET_VALUE_HPP_JOFA_100924
+
+#include <boost/itl/type_traits/is_element_container.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= AlgoUnifiers<Set>
+//==============================================================================
+template<class Type, class Iterator>
+inline typename enable_if<is_element_set<Type>, const typename Type::key_type>::type&
+co_value(Iterator it_)
+{
+ return *it_;
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/interval.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,834 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_INTERVAL_HPP_JOFA_100323
+#define BOOST_ITL_CONCEPT_INTERVAL_HPP_JOFA_100323
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/type_traits/is_discrete.hpp>
+#include <boost/itl/type_traits/is_asymmetric_interval.hpp>
+#include <boost/itl/type_traits/is_universal_interval.hpp>
+#include <boost/itl/type_traits/is_discrete_interval.hpp>
+#include <boost/itl/type_traits/is_continuous_interval.hpp>
+#include <boost/itl/type_traits/has_dynamic_bounds.hpp>
+#include <boost/itl/concept/domain_comparable.hpp>
+
+
+namespace boost{namespace itl
+{
+
+typedef unsigned char bound_type; //JODO encapsulation in a small class
+
+//==============================================================================
+//= Construct
+//==============================================================================
+
+class interval_bounds; //JODO separate dynamically and statically bounded interval concepts
+template<class DomainT> class bounded_value;
+
+//------------------------------------------------------------------------------
+//- Adapter classes
+//------------------------------------------------------------------------------
+template<class Type>
+struct intervals
+{
+ typedef typename Type::domain_type domain_type;
+ typedef typename Type::domain_compare domain_compare;
+
+ static Type construct(const domain_type& lo, const domain_type& up);
+
+ static domain_type upper(const Type& inter_val);
+ static domain_type lower(const Type& inter_val);
+};
+
+
+template<class Type>
+struct dynamic_intervals
+{
+ typedef typename Type::domain_type domain_type;
+ typedef typename Type::domain_compare domain_compare;
+
+ static Type construct(const domain_type& lo, const domain_type& up, interval_bounds bounds);
+ static Type construct_bounded(const bounded_value<domain_type>& lo,
+ const bounded_value<domain_type>& up);
+};
+
+
+
+
+//==============================================================================
+//= Construct
+//==============================================================================
+
+template<class Type>
+typename enable_if<is_asymmetric_interval<Type>, Type>::type
+construct(const typename Type::domain_type& low, //JODO Parameter passing DomainP
+ const typename Type::domain_type& up,
+ interval_bounds bounds = interval_bounds::right_open()) //JODO separate static intervals to avoid dependency
+{
+ return intervals<Type>::construct(low, up);
+}
+
+
+template<class Type>
+typename enable_if<is_dynamic_bounded<Type>, Type>::type
+construct(const typename Type::domain_type& low,
+ const typename Type::domain_type& up,
+ interval_bounds bounds = interval_bounds::right_open())
+{
+ return dynamic_intervals<Type>::construct(low, up, bounds);
+}
+
+
+//- construct form bounded values ----------------------------------------------
+template<class Type>
+typename enable_if<is_dynamic_bounded<Type>, Type>::type
+construct(const typename Type::bounded_domain_type& low,
+ const typename Type::bounded_domain_type& up)
+{
+ return dynamic_intervals<Type>::construct_bounded(low, up);
+}
+
+template<class Type>
+typename enable_if<is_interval<Type>, Type>::type
+span(const typename Type::domain_type& lhs,
+ const typename Type::domain_type& rhs)
+{
+ if(Type::domain_compare(lhs,rhs))
+ return construct(lhs, rhs);
+ else
+ return construct(rhs, lhs);
+}
+
+
+//==============================================================================
+//= Selection
+//==============================================================================
+
+template<class Type>
+inline typename enable_if<is_interval<Type>,
+ typename Type::domain_type>::type
+lower(const Type& object)
+{
+ return intervals<Type>::lower(object);
+}
+
+template<class Type>
+inline typename enable_if<is_interval<Type>,
+ typename Type::domain_type>::type
+upper(const Type& object)
+{
+ return intervals<Type>::upper(object);
+}
+
+
+//- first ----------------------------------------------------------------------
+template<class Type>
+inline typename enable_if<is_static_rightopen<Type>,
+ typename Type::domain_type>::type
+first(const Type& object)
+{
+ return lower(object);
+}
+
+template<class Type>
+inline typename enable_if<is_discrete_interval<Type>,
+ typename Type::domain_type>::type
+first(const Type& object)
+{
+ return is_left_closed(object.bounds()) ?
+ lower(object) :
+ succ(lower(object));
+}
+
+//- last -----------------------------------------------------------------------
+template<class Type>
+inline typename enable_if<mpl::and_<is_static_rightopen<Type>,
+ is_discrete<typename Type::domain_type> >,
+ typename Type::domain_type>::type
+last(const Type& object)
+{
+ return pred(upper(object));
+}
+
+template<class Type>
+inline typename enable_if<is_discrete_interval<Type>,
+ typename Type::domain_type>::type
+last(const Type& object)
+{
+ return is_right_closed(object.bounds()) ?
+ upper(object) :
+ pred(upper(object));
+}
+
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_dynamic_bounded<Type>,
+ typename Type::bounded_domain_type>::type
+bounded_lower(const Type& object)
+{
+ return typename
+ Type::bounded_domain_type(lower(object),
+ object.bounds().left());
+}
+
+template<class Type>
+typename enable_if<is_dynamic_bounded<Type>,
+ typename Type::bounded_domain_type>::type
+reverse_bounded_lower(const Type& object)
+{
+ return typename
+ Type::bounded_domain_type(lower(object),
+ object.bounds().reverse_left());
+}
+
+template<class Type>
+typename enable_if<is_dynamic_bounded<Type>,
+ typename Type::bounded_domain_type>::type
+bounded_upper(const Type& object)
+{
+ return typename
+ Type::bounded_domain_type(upper(object),
+ object.bounds().right());
+}
+
+template<class Type>
+typename enable_if<is_dynamic_bounded<Type>,
+ typename Type::bounded_domain_type>::type
+reverse_bounded_upper(const Type& object)
+{
+ return typename
+ Type::bounded_domain_type(upper(object),
+ object.bounds().reverse_right());
+}
+
+
+//==============================================================================
+//= Containedness
+//==============================================================================
+//- is_empty -------------------------------------------------------------------
+/** Is the interval empty? */
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+is_empty(const Type& object)
+{
+ return domain_less_equal<Type>(upper(object), lower(object));
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+is_empty(const Type& object)
+{
+ return object.empty();
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+is_empty(const Type& object)
+{
+ if(object.bounds() == interval_bounds::closed())
+ return domain_less<Type>(upper(object), lower(object));
+ else if(object.bounds() == interval_bounds::open())
+ return domain_less_equal<Type>(upper(object), succ(lower(object)));
+ else
+ return domain_less_equal<Type>(upper(object), lower(object));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+is_empty(const Type& object)
+{
+ return domain_less<Type>(upper(object), lower(object))
+ || ( domain_equal<Type>(upper(object), lower(object))
+ && object.bounds() != interval_bounds::closed() );
+}
+
+//- contains -------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+contains(const Type& super, const Type& sub)
+{
+ return lower_less_equal(super,sub) && upper_less_equal(sub,super);
+}
+
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+contains(const Type& super, const typename Type::domain_type& element)
+{
+ return contains(super,Type(element));
+}
+
+//- within ---------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+within(const Type& sub, const Type& super)
+{
+ return contains(super,sub);
+}
+
+
+//==============================================================================
+//= Equivalences and Orderings
+//==============================================================================
+//- exclusive_less -------------------------------------------------------------
+/** Maximal element of <tt>left</tt> is less than the minimal element of
+ <tt>right</tt> */
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+exclusive_less(const Type& left, const Type& right)
+{
+ return domain_less_equal<Type>(left.upper(), right.lower());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+exclusive_less(const Type& left, const Type& right)
+{
+ return left.exclusive_less(right);
+}
+
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+exclusive_less(const Type& left, const Type& right)
+{
+ return domain_less<Type>(last(left), first(right));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+exclusive_less(const Type& left, const Type& right)
+{
+ return domain_less<Type>(left.upper(), right.lower())
+ || ( domain_equal<Type>(left.upper(), right.lower())
+ && inner_bounds(left,right) != interval_bounds::open() );
+}
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+lower_less(const Type& left, const Type& right)
+{
+ return domain_less<Type>(left.lower(), right.lower());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+lower_less(const Type& left, const Type& right)
+{
+ return left.lower_less(right);
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+lower_less(const Type& left, const Type& right)
+{
+ return domain_less<Type>(first(left), first(right));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+lower_less(const Type& left, const Type& right)
+{
+ if(left_bounds(left,right) == interval_bounds::right_open()) //'[(' == 10
+ return domain_less_equal<Type>(left.lower(), right.lower());
+ else
+ return domain_less<Type>(left.lower(), right.lower());
+}
+
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+upper_less(const Type& left, const Type& right)
+{
+ return domain_less<Type>(left.upper(), right.upper());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+upper_less(const Type& left, const Type& right)
+{
+ return left.upper_less(right);
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+upper_less(const Type& left, const Type& right)
+{
+ return domain_less<Type>(last(left), last(right));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+upper_less(const Type& left, const Type& right)
+{
+ if(right_bounds(left,right) == interval_bounds::left_open())
+ return domain_less_equal<Type>(left.upper(), right.upper());
+ else
+ return domain_less<Type>(left.upper(), right.upper());
+}
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>,
+ typename Type::bounded_domain_type >::type
+lower_min(const Type& left, const Type& right)
+{
+ return lower_less(left, right) ? bounded_lower(left) : bounded_lower(right);
+}
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>,
+ typename Type::bounded_domain_type >::type
+lower_max(const Type& left, const Type& right)
+{
+ return lower_less(left, right) ? bounded_lower(right) : bounded_lower(left);
+}
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>,
+ typename Type::bounded_domain_type >::type
+upper_max(const Type& left, const Type& right)
+{
+ return upper_less(left, right) ? bounded_upper(right) : bounded_upper(left);
+}
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>,
+ typename Type::bounded_domain_type >::type
+upper_min(const Type& left, const Type& right)
+{
+ return upper_less(left, right) ? bounded_upper(left) : bounded_upper(right);
+}
+
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+lower_equal(const Type& left, const Type& right)
+{
+ return domain_equal<Type>(left.lower(), right.lower());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+lower_equal(const Type& left, const Type& right)
+{
+ return left.lower_equal(right);
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+lower_equal(const Type& left, const Type& right)
+{
+ return domain_equal<Type>(first(left), first(right));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+lower_equal(const Type& left, const Type& right)
+{
+ return (left.bounds().left()==right.bounds().left())
+ && domain_equal<Type>(left.lower(), right.lower());
+}
+
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+upper_equal(const Type& left, const Type& right)
+{
+ return domain_equal<Type>(left.upper(), right.upper());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+upper_equal(const Type& left, const Type& right)
+{
+ return left.upper_equal(right);
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+upper_equal(const Type& left, const Type& right)
+{
+ return domain_equal<Type>(last(left), last(right));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+upper_equal(const Type& left, const Type& right)
+{
+ return (left.bounds().right()==right.bounds().right())
+ && domain_equal<Type>(left.upper(), right.upper());
+}
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+lower_less_equal(const Type& left, const Type& right)
+{
+ return lower_less(left,right) || lower_equal(left,right);
+}
+
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+upper_less_equal(const Type& left, const Type& right)
+{
+ return upper_less(left,right) || upper_equal(left,right);
+}
+
+
+//- operator == ----------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+operator == (const Type& lhs, const Type& rhs)
+{
+ return (itl::is_empty(lhs) && itl::is_empty(rhs))
+ || (lower_equal(lhs,rhs) && upper_equal(lhs,rhs));
+}
+
+//- operator < -----------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+operator < (const Type& lhs, const Type& rhs)
+{
+ if(itl::is_empty(lhs))
+ return !itl::is_empty(rhs);
+ else
+ return lower_less(lhs,rhs)
+ || (lower_equal(lhs,rhs) && upper_less(lhs,rhs));
+}
+
+
+
+//------------------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, bool>::type
+touches(const Type& left, const Type& right)
+{
+ return domain_equal<Type>(left.upper(), right.lower());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, bool>::type
+touches(const Type& left, const Type& right)
+{
+ return left.touches(right);
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>, bool>::type
+touches(const Type& left, const Type& right)
+{
+ return domain_equal<Type>(succ(last(left)), first(right));
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>, bool>::type
+touches(const Type& left, const Type& right)
+{
+ return is_complementary(inner_bounds(left,right))
+ && domain_equal<Type>(left.upper(), right.lower());
+}
+
+
+//==============================================================================
+//= Size
+//==============================================================================
+//- cardinality ----------------------------------------------------------------
+
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>,
+ typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ typedef typename Type::size_type SizeT;
+ if(itl::is_empty(object))
+ return itl::neutron<SizeT>::value();
+ else if( object.bounds() == interval_bounds::closed()
+ && domain_equal<Type>(lower(object), upper(object)))
+ return itl::unon<SizeT>::value();
+ else
+ return infinity<SizeT>::value();
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_interval<Type>,
+ typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ return (last(object) + itl::unon<typename Type::size_type>::value()) - first(object);
+}
+
+
+template<class Type>
+typename boost::enable_if<is_continuous_asymmetric<Type>,
+ typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ typedef typename Type::size_type SizeT;
+ if(itl::is_empty(object))
+ return itl::neutron<SizeT>::value();
+ else
+ return infinity<SizeT>::value();
+}
+
+template<class Type>
+typename boost::enable_if<is_discrete_asymmetric<Type>,
+ typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ return (last(object) + itl::unon<typename Type::size_type>::value()) - first(object);
+}
+
+
+
+
+
+//- size -----------------------------------------------------------------------
+template<class Type>
+inline typename enable_if<is_interval<Type>,
+ typename Type::size_type>::type
+size(const Type& object)
+{
+ return cardinality(object);
+}
+
+//- length ---------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_continuous_interval<Type>,
+ typename Type::difference_type>::type
+length(const Type& object)
+{
+ return upper(object) - lower(object);
+}
+
+template<class Type>
+inline typename boost::enable_if<is_discrete_interval<Type>,
+ typename Type::difference_type>::type
+length(const Type& object)
+{
+ return (last(object) + itl::unon<typename Type::difference_type>::value())
+ - first(object);
+}
+
+template<class Type>
+typename boost::enable_if<is_continuous_asymmetric<Type>,
+ typename Type::difference_type>::type
+length(const Type& object)
+{
+ return upper(object) - lower(object);
+}
+
+template<class Type>
+inline typename boost::enable_if<is_discrete_asymmetric<Type>,
+ typename Type::difference_type>::type
+length(const Type& object)
+{
+ return (last(object) + itl::unon<typename Type::difference_type>::value())
+ - first(object);
+}
+
+//==============================================================================
+//= Addition
+//==============================================================================
+//- hull -----------------------------------------------------------------------
+/** \c hull returns the smallest interval containing \c left and \c right. */
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, Type>::type
+hull(Type left, const Type& right)
+{
+ if(itl::is_empty(right))
+ return left;
+ else if(itl::is_empty(left))
+ return right;
+
+ //JODO return construct
+ return
+ Type
+ (
+ (std::min)(left.lower(), right.lower(), Type::domain_compare()),
+ (std::max)(left.upper(), right.upper(), Type::domain_compare())
+ );
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, Type>::type
+hull(Type left, const Type& right)
+{
+ return left.extend(right);
+}
+
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
+hull(Type left, const Type& right)
+{
+ if(itl::is_empty(right))
+ return left;
+ else if(itl::is_empty(left))
+ return right;
+
+ //JODO return construct<Type,std::less>
+ return dynamic_intervals<Type>::construct_bounded
+ (
+ lower_min(left, right),
+ upper_max(left, right)
+ );
+}
+
+//==============================================================================
+//= Subtraction
+//==============================================================================
+//- left_subtract --------------------------------------------------------------
+/** subtract \c left_minuend from the \c right interval on it's left side.
+ Return the difference: The part of \c right right of \c left_minuend.
+\code
+right_over = right - left_minuend; //on the left.
+... d) : right
+... c) : left_minuend
+ [c d) : right_over
+\endcode
+*/
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, Type>::type
+left_subtract(Type right, const Type& left_minuend)
+{
+ if(exclusive_less(left_minuend, right))
+ return right;
+ //JODO return construct(left_minuend.upper(), right.upper());
+ return Type(left_minuend.upper(), right.upper());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, Type>::type
+left_subtract(Type right, const Type& left_minuend)
+{
+ return right.left_subtract(left_minuend);
+}
+
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
+left_subtract(Type right, const Type& left_minuend)
+{
+ if(exclusive_less(left_minuend, right))
+ return right;
+ return dynamic_intervals<Type>::construct_bounded
+ ( reverse_bounded_upper(left_minuend), bounded_upper(right) );
+}
+
+
+//- right_subtract -------------------------------------------------------------
+/** subtract \c right_minuend from the \c left interval on it's right side.
+ Return the difference: The part of \c left right of \c right_minuend.
+\code
+left_over = left - right_minuend; //on the right side.
+[a ... : left
+ [b ... : right_minuend
+[a b) : left_over
+\endcode
+*/
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, Type>::type
+right_subtract(Type left, const Type& right_minuend)
+{
+ if(exclusive_less(left, right_minuend))
+ return left;
+ return Type(left.lower(), right_minuend.lower());
+ //JODO return construct(left.lower(), right_minuend.lower());
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, Type>::type
+right_subtract(Type left, const Type& right_minuend)
+{
+ return left.right_subtract(right_minuend);
+}
+
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
+right_subtract(Type left, const Type& right_minuend)
+{
+ //JODO s.o.
+ if(exclusive_less(left, right_minuend))
+ return left;
+ //JODO return construct<Type,std::less>(left.lower(), right_minuend.lower(),
+ return dynamic_intervals<Type>::construct_bounded
+ ( bounded_lower(left), reverse_bounded_lower(right_minuend) );
+}
+
+//==============================================================================
+//= Intersection
+//==============================================================================
+//- operator & -----------------------------------------------------------------
+/** Returns the intersection of \c left and \c right interval. */
+template<class Type>
+typename boost::enable_if<is_asymmetric_interval<Type>, Type>::type
+operator & (Type left, const Type& right)
+{
+ if(itl::is_empty(left) || itl::is_empty(right))
+ return Type(); //JODO return neutron<Type>::value; neutron for new interval_types.
+ else
+ return
+ Type((std::max)(left.lower(), right.lower(), Type::domain_compare()),
+ (std::min)(left.upper(), right.upper(), Type::domain_compare()));
+}
+
+template<class Type>
+typename boost::enable_if<is_universal_interval<Type>, Type>::type
+operator & (Type left, const Type& right)
+{
+ return left &= right;
+}
+
+template<class Type>
+typename boost::enable_if<has_dynamic_bounds<Type>, Type>::type
+operator & (Type left, const Type& right)
+{
+ if(itl::is_empty(left) || itl::is_empty(right))
+ return Type(); //JODO return neutron<Type>::value; neutron for new interval_types.
+ else
+ //JODO return construct<Type,std::less>
+ return dynamic_intervals<Type>::construct_bounded
+ (
+ lower_max(left, right),
+ upper_min(left, right)
+ );
+}
+
+
+//- intersects -----------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+intersects(const Type& left, const Type& right)
+{
+ return !(exclusive_less(left,right) || exclusive_less(right,left));
+}
+
+//- disjoint -------------------------------------------------------------------
+template<class Type>
+typename boost::enable_if<is_interval<Type>, bool>::type
+disjoint(const Type& left, const Type& right)
+{
+ return exclusive_less(left,right) || exclusive_less(right,left);
+}
+
+//------------------------------------------------------------------------------
+
+
+
+}} // namespace itl boost
+
+#endif
+

Deleted: sandbox/itl/boost/itl/concept/interval/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/interval/map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,630 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_INTERVAL_MAP_HPP_JOFA_100920
-#define BOOST_ITL_CONCEPT_INTERVAL_MAP_HPP_JOFA_100920
-
-#include <boost/itl/type_traits/element_type_of.hpp>
-#include <boost/itl/type_traits/segment_type_of.hpp>
-#include <boost/itl/type_traits/absorbs_neutrons.hpp>
-#include <boost/itl/type_traits/is_combinable.hpp>
-#include <boost/itl/detail/interval_map_algo.hpp>
-
-namespace boost{ namespace itl
-{
-
-//==============================================================================
-//= Containedness<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{M} P:{b p M} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, bool>::type
-contains(const Type& super, const typename Type::element_type& key_value_pair)
-{
- typedef typename Type::const_iterator const_iterator;
- const_iterator it_ = super.find(key_value_pair.key);
- return it_ != super.end() && it_->second == key_value_pair.data;
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, bool>::type
-contains(const Type& super, const typename Type::segment_type& sub_segment)
-{
- typedef typename Type::interval_type interval_type;
- typedef typename Type::const_iterator const_iterator;
-
- interval_type sub_interval = sub_segment.first;
- if(itl::is_empty(sub_interval))
- return true;
-
- std::pair<const_iterator, const_iterator> exterior = super.equal_range(sub_interval);
- if(exterior.first == exterior.second)
- return false;
-
- const_iterator last_overlap = prior(exterior.second);
-
- if(!(sub_segment.second == exterior.first->second) )
- return false;
-
- return
- itl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
- && Interval_Map::is_joinable(super, exterior.first, last_overlap);
-}
-
-template<class Type, class CoType>
-typename enable_if<is_concept_compatible<is_interval_map, Type, CoType>, bool>::type
-contains(const Type& super, const CoType& sub)
-{
- return Interval_Set::within(sub, super);
-}
-
-
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{M} P:{e i S} key_types : total
-//------------------------------------------------------------------------------
-template<class Type, class CoType>
-typename enable_if< mpl::and_< is_interval_map<Type>
- , is_total<Type>
- , is_cross_derivative<Type, CoType> >
- , bool>::type
-contains(const Type& super, const CoType& sub)
-{
- return true;
-}
-
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{M} P:{e i S} key_types : partial
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if< mpl::and_< is_interval_map<Type>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-contains(const Type& super, const typename Type::domain_type& key)
-{
- return super.find(key) != super.end();
-}
-
-template<class Type>
-typename enable_if< mpl::and_< is_interval_map<Type>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-contains(const Type& super, const typename Type::interval_type& sub_interval)
-{
- typedef typename Type::const_iterator const_iterator;
-
- if(itl::is_empty(sub_interval))
- return true;
-
- std::pair<const_iterator, const_iterator> exterior = super.equal_range(sub_interval);
- if(exterior.first == exterior.second)
- return false;
-
- const_iterator last_overlap = prior(exterior.second);
-
- return
- itl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
- && Interval_Set::is_joinable(super, exterior.first, last_overlap);
-}
-
-template<class Type, class KeyT>
-typename enable_if< mpl::and_< is_concept_combinable<is_interval_map, is_interval_set, Type, KeyT>
- , mpl::not_<is_total<Type> > >
- , bool>::type
-contains(const Type& super, const KeyT& sub)
-{
- return Interval_Set::within(sub, super);
-}
-
-
-//==============================================================================
-//= Addition<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& add(T&, c P&) T:{M} P:{b p} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-add(Type& object, const typename Type::element_type& operand)
-{
- return object.add(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-add(Type& object, const typename Type::segment_type& operand)
-{
- return object.add(operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& add(T&, J, c P&) T:{M} P:{p} segment_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, typename Type::iterator >::type
-add(Type& object, typename Type::iterator prior_,
- const typename Type::segment_type& operand)
-{
- return object.add(prior_, operand);
-}
-
-//==============================================================================
-//= Insertion<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& insert(T&, c P&) T:{M} P:{b p} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-insert(Type& object, const typename Type::element_type& operand)
-{
- return object.insert(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-insert(Type& object, const typename Type::segment_type& operand)
-{
- return object.insert(operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& insert(T&, J, c P&) T:{M} P:{p} with hint
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, typename Type::iterator>::type
-insert(Type& object, typename Type::iterator prior,
- const typename Type::segment_type& operand)
-{
- return object.insert(prior, operand);
-}
-
-
-//==============================================================================
-//= Erasure<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& erase(T&, c P&) T:{M} P:{e i} key_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-erase(Type& object, const typename Type::domain_type& minuend)
-{
- return object.erase(minuend);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-erase(Type& object, const typename Type::interval_type& minuend)
-{
- return object.erase(minuend);
-}
-
-//------------------------------------------------------------------------------
-//- T& erase(T&, c P&) T:{M} P:{b p} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-erase(Type& object, const typename Type::element_type& minuend)
-{
- return object.erase(minuend);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-erase(Type& object, const typename Type::segment_type& minuend)
-{
- return object.erase(minuend);
-}
-
-//==============================================================================
-//= Subtraction<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{M} P:{b p} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::element_type& operand)
-{
- return object.subtract(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::segment_type& operand)
-{
- return object.subtract(operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{M} P:{e i} key_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::domain_type& operand)
-{
- return object.erase(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-subtract(Type& object, const typename Type::interval_type& operand)
-{
- return object.erase(operand);
-}
-
-//==============================================================================
-//= Selective Update<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& set_at(T&, c P&) T:{M} P:{e i}
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-set_at(Type& object, const typename Type::segment_type& operand)
-{
- itl::erase(object, operand.first);
- return itl::insert(object, operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-set_at(Type& object, const typename Type::element_type& operand)
-{
- return itl::set_at(object, make_segment<Type>(operand));
-}
-
-//==============================================================================
-//= Intersection<IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{M} P:{b p} fragment_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::element_type& operand)
-{
- object.add_intersection(section, operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::segment_type& operand)
-{
- object.add_intersection(section, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{M} P:{M'} map fragment_type total
-//------------------------------------------------------------------------------
-template<class Type, class MapT>
-typename enable_if
-<
- mpl::and_< is_total<Type>
- , is_concept_compatible<is_interval_map, Type, MapT> >
- , void
->::type
-add_intersection(Type& section, const Type& object, const MapT& operand)
-{
- section += object;
- section += operand;
-}
-
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{M} P:{M'} map fragment_type partial
-//------------------------------------------------------------------------------
-template<class Type, class MapT>
-typename enable_if
-<
- mpl::and_< mpl::not_<is_total<Type> >
- , is_concept_compatible<is_interval_map, Type, MapT> >
- , void
->::type
-add_intersection(Type& section, const Type& object, const MapT& operand)
-{
- typedef typename Type::segment_type segment_type;
- typedef typename Type::interval_type interval_type;
- typedef typename MapT::const_iterator const_iterator;
-
- if(operand.empty())
- return;
- const_iterator common_lwb, common_upb;
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return;
- const_iterator it_ = common_lwb;
- while(it_ != common_upb)
- add_intersection(section, object, *it_++);
-}
-
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{M} P:{e i S} key_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::domain_type& key_value)
-{
- typedef typename Type::interval_type interval_type;
- typedef typename Type::segment_type segment_type;
- typedef typename Type::const_iterator const_iterator;
-
- const_iterator it_ = object.find(key_value);
- if(it_ != object.end())
- add(section, segment_type(interval_type(key_value),it_->second));
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::interval_type& inter_val)
-{
- typedef typename Type::interval_type interval_type;
- typedef typename Type::value_type value_type;
- typedef typename Type::const_iterator const_iterator;
- typedef typename Type::iterator iterator;
-
- if(itl::is_empty(inter_val))
- return;
-
- std::pair<const_iterator, const_iterator> exterior
- = object.equal_range(inter_val);
- if(exterior.first == exterior.second)
- return;
-
- iterator prior_ = section.end();
- for(const_iterator it_=exterior.first; it_ != exterior.second; it_++)
- {
- interval_type common_interval = it_->first & inter_val;
- if(!itl::is_empty(common_interval))
- prior_ = add(section, prior_,
- value_type(common_interval, it_->second) );
- }
-}
-
-template<class Type, class KeySetT>
-typename enable_if<is_concept_combinable<is_interval_map, is_interval_set, Type, KeySetT>, void>::type
-add_intersection(Type& section, const Type& object, const KeySetT& key_set)
-{
- typedef typename KeySetT::const_iterator const_iterator;
-
- if(itl::is_empty(key_set))
- return;
-
- const_iterator common_lwb, common_upb;
- if(!Set::common_range(common_lwb, common_upb, key_set, object))
- return;
-
- const_iterator it_ = common_lwb;
- while(it_ != common_upb)
- add_intersection(section, object, *it_++);
-}
-
-//------------------------------------------------------------------------------
-//- intersects<IntervalMaps> fragment_types
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<mpl::and_< is_interval_map<Type>
- , is_total<Type>
- , is_same<OperandT, segment_type_of<Type> > >,
- bool>::type
-intersects(const Type&, const OperandT&)
-{
- return true;
-}
-
-template<class Type, class OperandT>
-typename enable_if<mpl::and_< is_interval_map<Type>
- , mpl::not_<is_total<Type> >
- , is_same<OperandT, segment_type_of<Type> > >,
- bool>::type
-intersects(const Type& object, const OperandT& operand)
-{
- Type intersection; //JODO
- itl::add_intersection(intersection, left, operand);
- return !itl::is_empty(intersection);
-}
-
-template<class Type, class OperandT>
-typename enable_if<mpl::and_< is_interval_map<Type>
- , is_same<OperandT, element_type_of<Type> > >,
- bool>::type
-intersects(const Type& object, const OperandT& operand)
-{
- return itl::intersects(object, make_segment<Type>(operand));
-}
-
-//------------------------------------------------------------------------------
-//- Symmetric difference flip<Interval_Map> fragment_types
-//------------------------------------------------------------------------------
-//JODO NOTE: typename enable_if< mpl::and_< is_interval_map_right_intra_combinable<Type, OperandT> //JODO =^= fragment_type_of
-//------------------------------------------------------------------------------
-//- T& flip(T&, c P&) T:{M} P:{b p} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-flip(Type& object, const typename Type::element_type& operand)
-{
- return object.flip(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_map<Type>, Type>::type&
-flip(Type& object, const typename Type::segment_type& operand)
-{
- return object.flip(operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& flip(T&, c P&) T:{M} P:{M'} total absorber
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if< mpl::and_< is_total<Type>
- , absorbs_neutrons<Type>
- , is_concept_compatible<is_interval_map,
- Type, OperandT >
- >
- , Type>::type&
-flip(Type& object, const OperandT&)
-{
- object.clear();
- return object;
-}
-
-//------------------------------------------------------------------------------
-//- T& flip(T&, c P&) T:{M} P:{M'} total enricher
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if< mpl::and_< is_total<Type>
- , mpl::not_<absorbs_neutrons<Type> >
- , is_concept_compatible<is_interval_map,
- Type, OperandT >
- >
- , Type>::type&
-flip(Type& object, const OperandT& operand)
-{
- typedef typename Type::codomain_type codomain_type;
-
- object += operand;
- ITL_FORALL(typename Type, it_, object) //JODO: neutralisierendes add.
- it_->second = neutron<codomain_type>::value();
-
- if(mpl::not_<is_interval_splitter<Type> >::value) //JODO
- itl::join(object);
-
- return object;
-}
-
-//------------------------------------------------------------------------------
-//- T& flip(T&, c P&) T:{M} P:{M'} partial
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if< mpl::and_< mpl::not_<is_total<Type> >
- , is_concept_compatible<is_interval_map,
- Type, OperandT >
- >
- , Type>::type&
-flip(Type& object, const OperandT& operand)
-{
- typedef typename OperandT::const_iterator const_iterator;
- typedef typename Type::codomain_type codomain_type;
-
- const_iterator common_lwb, common_upb;
-
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return object += operand;
-
- const_iterator it_ = operand.begin();
-
- // All elements of operand left of the common range are added
- while(it_ != common_lwb)
- itl::add(object, *it_++);
- // All elements of operand in the common range are symmetrically subtracted
- while(it_ != common_upb)
- itl::flip(object, *it_++);
- // All elements of operand right of the common range are added
- while(it_ != operand.end())
- itl::add(object, *it_++);
-
- return object;
-}
-
-//==============================================================================
-//= Domain
-//==============================================================================
-template<class Type, class SetT>
-typename enable_if<is_concept_combinable<is_interval_set, is_interval_map,
- SetT, Type>, SetT>::type&
-domain(SetT& result, const Type& object)
-{
- result.clear();
- ITL_const_FORALL(typename Type, it_, object)
- result += it_->first;
-
- return result;
-}
-
-//==============================================================================
-//= Manipulation by predicates
-//==============================================================================
-template<class MapT, class Predicate> //JODO unify with element_map . . .
-typename enable_if<is_interval_map<MapT>, MapT>::type&
-erase_if(const Predicate& pred, MapT& object)
-{
- typename MapT::iterator it_ = object.begin();
- while(it_ != object.end())
- if(pred(*it_))
- object.erase(it_++);
- else ++it_;
- return object;
-}
-
-template<class MapT, class Predicate>
-inline typename enable_if<is_interval_map<MapT>, MapT>::type&
-add_if(const Predicate& pred, MapT& object, const MapT& src)
-{
- typename MapT::const_iterator it_ = src.begin();
- while(it_ != src.end())
- if(pred(*it_))
- itl::add(object, *it_++);
-
- return object;
-}
-
-template<class MapT, class Predicate>
-inline typename enable_if<is_interval_map<MapT>, MapT>::type&
-assign_if(const Predicate& pred, MapT& object, const MapT& src)
-{
- itl::clear(object);
- return add_if(object, src, pred);
-}
-
-
-//==============================================================================
-//= Morphisms
-//==============================================================================
-template<class Type>
-typename enable_if<mpl::and_< is_interval_map<Type>
- , absorbs_neutrons<Type> >, Type>::type&
-absorb_neutrons(Type& object)
-{
- return object;
-}
-
-template<class Type>
-typename enable_if<mpl::and_< is_interval_map<Type>
- , mpl::not_<absorbs_neutrons<Type> > >, Type>::type&
-absorb_neutrons(Type& object)
-{
- typedef typename Type::segment_type segment_type;
- return itl::erase_if(content_is_neutron<segment_type>(), object);
-}
-
-//==============================================================================
-//= Streaming
-//==============================================================================
-template<class CharType, class CharTraits, class Type>
-typename enable_if<is_interval_map<Type>,
- std::basic_ostream<CharType, CharTraits> >::type&
-operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
-{
- stream << "{";
- ITL_const_FORALL(typename Type, it_, object)
- stream << "(" << it_->first << "->" << it_->second << ")";
-
- return stream << "}";
-}
-
-
-}} // namespace boost itl
-
-#endif
-
-

Deleted: sandbox/itl/boost/itl/concept/interval/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/interval/set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,308 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_INTERVAL_SET_HPP_JOFA_100920
-#define BOOST_ITL_CONCEPT_INTERVAL_SET_HPP_JOFA_100920
-
-#include <boost/itl/type_traits/is_combinable.hpp>
-
-namespace boost{ namespace itl
-{
-
-//==============================================================================
-//= Containedness<IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- bool contains(c T&, c P&) T:{S} P:{e i S} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, bool>::type
-contains(const Type& super, const typename Type::element_type& element)
-{
- return !(super.find(element) == super.end());
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, bool>::type
-contains(const Type& super, const typename Type::segment_type& inter_val)
-{
- typedef typename Type::const_iterator const_iterator;
- if(itl::is_empty(inter_val))
- return true;
-
- std::pair<const_iterator, const_iterator> exterior
- = super.equal_range(inter_val);
- if(exterior.first == exterior.second)
- return false;
-
- const_iterator last_overlap = cyclic_prior(super, exterior.second);
-
- return
- itl::contains(hull(*(exterior.first), *last_overlap), inter_val)
- && Interval_Set::is_joinable(super, exterior.first, last_overlap);
-}
-
-template<class Type, class OperandT>
-typename enable_if<has_same_concept<is_interval_set, Type, OperandT>,
- bool>::type
-contains(const Type& super, const OperandT& sub)
-{
- return Interval_Set::contains(super, sub);
-}
-
-//==============================================================================
-//= Addition<IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& add(T&, c P&) T:{S} P:{e i} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-add(Type& object, const typename Type::element_type& operand)
-{
- return object.add(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-add(Type& object, const typename Type::segment_type& operand)
-{
- return object.add(operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& add(T&, J, c P&) T:{S} P:{i} interval_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, typename Type::iterator>::type
-add(Type& object, typename Type::iterator prior,
- const typename Type::segment_type& operand)
-{
- return object.add(prior, operand);
-}
-
-//==============================================================================
-//= Insertion<IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& insert(T&, c P&) T:{S} P:{e i} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-insert(Type& object, const typename Type::element_type& operand)
-{
- return itl::add(object, operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-insert(Type& object, const typename Type::segment_type& operand)
-{
- return itl::add(object, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& insert(T&, J, c P&) T:{S} P:{i} with hint
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-insert(Type& object, const typename Type::iterator prior,
- const typename Type::segment_type& operand)
-{
- return itl::add(object, prior, operand);
-}
-
-//==============================================================================
-//= Erasure<IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& erase(T&, c P&) T:{S} P:{e i} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-erase(Type& object, const typename Type::segment_type& minuend)
-{
- return itl::subtract(object, minuend);
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-erase(Type& object, const typename Type::element_type& minuend)
-{
- return itl::subtract(object, minuend);
-}
-
-//==============================================================================
-//= Subtraction<IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& subtract(T&, c P&) T:{S} P:{e i} fragment_type
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-subtract(Type& object, const typename Type::element_type& operand)
-{
- return object.subtract(operand);
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-subtract(Type& object, const typename Type::segment_type& operand)
-{
- return object.subtract(operand);
-}
-
-//==============================================================================
-//= Intersection
-//==============================================================================
-//------------------------------------------------------------------------------
-//- void add_intersection(T&, c T&, c P&) T:{S} P:{e i} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::element_type& operand)
-{
- typedef typename Type::const_iterator const_iterator;
- const_iterator found = object.find(operand);
- if(found != object.end())
- itl::add(section, operand);
-}
-
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, void>::type
-add_intersection(Type& section, const Type& object,
- const typename Type::segment_type& segment)
-{
- typedef typename Type::const_iterator const_iterator;
- typedef typename Type::iterator iterator;
- typedef typename Type::interval_type interval_type;
-
- if(itl::is_empty(segment))
- return;
-
- std::pair<const_iterator, const_iterator> exterior
- = object.equal_range(segment);
- if(exterior.first == exterior.second)
- return;
-
- iterator prior_ = section.end();
- for(const_iterator it_=exterior.first; it_ != exterior.second; it_++)
- {
- interval_type common_interval = Type::key_value(it_) & segment;
- if(!itl::is_empty(common_interval))
- prior_ = section.insert(prior_, common_interval);
- }
-}
-
-//==============================================================================
-//= Symmetric difference<IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& flip(T&, c P&) T:{S} P:{e i S'} fragment_types
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-flip(Type& object, const typename Type::element_type& operand)
-{
- if(itl::contains(object, operand))
- return object -= operand;
- else
- return object += operand;
-}
-
-template<class Type>
-typename enable_if<is_interval_set<Type>, Type>::type&
-flip(Type& object, const typename Type::segment_type& segment)
-{
- typedef typename Type::const_iterator const_iterator;
- typedef typename Type::interval_type interval_type;
- // That which is common shall be subtracted
- // That which is not shall be added
- // So x has to be 'complementary added' or flipped
- interval_type span = segment;
- std::pair<const_iterator, const_iterator> exterior
- = object.equal_range(span);
-
- const_iterator fst_ = exterior.first;
- const_iterator end_ = exterior.second;
-
- interval_type covered, left_over;
- const_iterator it_ = fst_;
- while(it_ != end_)
- {
- covered = *it_++;
- //[a ... : span
- // [b ... : covered
- //[a b) : left_over
- left_over = right_subtract(span, covered);
- itl::subtract(object, span & covered); //That which is common shall be subtracted
- itl::add(object, left_over); //That which is not shall be added
-
- //... d) : span
- //... c) : covered
- // [c d) : span'
- span = left_subtract(span, covered);
- }
-
- //If span is not empty here, it_ is not in the set so it_ shall be added
- itl::add(object, span);
- return object;
-}
-
-
-template<class Type, class OperandT>
-typename enable_if<is_concept_compatible<is_interval_set, Type, OperandT>, Type>::type&
-flip(Type& object, const OperandT& operand)
-{
- typedef typename OperandT::const_iterator const_iterator;
-
- if(operand.empty())
- return object;
-
- const_iterator common_lwb, common_upb;
-
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return object += operand;
-
- const_iterator it_ = operand.begin();
-
- // All elements of operand left of the common range are added
- while(it_ != common_lwb)
- itl::add(object, *it_++);
- // All elements of operand in the common range are symmertrically subtracted
- while(it_ != common_upb)
- itl::flip(object, *it_++);
- // All elements of operand right of the common range are added
- while(it_ != operand.end())
- itl::add(object, *it_++);
-
- return object;
-}
-
-//==============================================================================
-//= Streaming
-//==============================================================================
-template<class CharType, class CharTraits, class Type>
-typename enable_if<is_interval_set<Type>,
- std::basic_ostream<CharType, CharTraits> >::type&
-operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
-{
- stream << "{";
- ITL_const_FORALL(typename Type, it_, object)
- stream << (*it_);
-
- return stream << "}";
-}
-
-
-}} // namespace boost itl
-
-#endif
-
-

Deleted: sandbox/itl/boost/itl/concept/interval/set_or_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/concept/interval/set_or_map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,838 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2010-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_CONCEPT_INTERVAL_SET_OR_MAP_HPP_JOFA_100920
-#define BOOST_ITL_CONCEPT_INTERVAL_SET_OR_MAP_HPP_JOFA_100920
-
-#include <boost/itl/type_traits/domain_type_of.hpp>
-#include <boost/itl/type_traits/interval_type_of.hpp>
-#include <boost/itl/type_traits/is_combinable.hpp>
-
-namespace boost{ namespace itl
-{
-
-//==============================================================================
-//= Containedness<IntervalSet|IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- bool within(c T&, c P&) T={Set,Map} P={e i b p S M}
-//------------------------------------------------------------------------------
-template<class SubT, class SuperT>
-typename enable_if<is_interval_container<SuperT>, bool>::type
-within(const SubT& sub, const SuperT& super)
-{
- return itl::contains(super, sub);
-}
-
-//==============================================================================
-//= Equivalences and Orderings<IntervalSet|IntervalMap>
-//==============================================================================
-template<class Type>
-inline typename enable_if<is_interval_container<Type>, bool>::type
-operator == (const Type& left, const Type& right)
-{
- return Set::lexicographical_equal(left, right);
-}
-
-template<class Type>
-inline typename enable_if<is_interval_container<Type>, bool>::type
-operator < (const Type& left, const Type& right)
-{
- typedef typename Type::segment_compare segment_compare;
- return std::lexicographical_compare(
- left.begin(), left.end(), right.begin(), right.end(),
- segment_compare()
- );
-}
-
-/** Returns true, if \c left and \c right contain the same elements.
- Complexity: linear. */
-template<class LeftT, class RightT>
-typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
-is_element_equal(const LeftT& left, const RightT& right)
-{
- return Interval_Set::is_element_equal(left, right);
-}
-
-/** Returns true, if \c left is lexicographically less than \c right.
- Intervals are interpreted as sequence of elements.
- Complexity: linear. */
-template<class LeftT, class RightT>
-typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
-is_element_less(const LeftT& left, const RightT& right)
-{
- return Interval_Set::is_element_less(left, right);
-}
-
-/** Returns true, if \c left is lexicographically greater than \c right.
- Intervals are interpreted as sequence of elements.
- Complexity: linear. */
-template<class LeftT, class RightT>
-typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
-is_element_greater(const LeftT& left, const RightT& right)
-{
- return Interval_Set::is_element_greater(left, right);
-}
-
-//------------------------------------------------------------------------------
-template<class LeftT, class RightT>
-typename enable_if<is_inter_combinable<LeftT, RightT>, int>::type
-inclusion_compare(const LeftT& left, const RightT& right)
-{
- return Interval_Set::subset_compare(left, right,
- left.begin(), left.end(),
- right.begin(), right.end());
-}
-
-template<class LeftT, class RightT>
-typename enable_if<is_concept_equivalent<is_element_container,LeftT, RightT>,
- int>::type
-inclusion_compare(const LeftT& left, const RightT& right)
-{
- return Set::subset_compare(left, right,
- left.begin(), left.end(),
- right.begin(), right.end());
-}
-//------------------------------------------------------------------------------
-
-template<class LeftT, class RightT>
-typename enable_if< is_concept_compatible<is_interval_map, LeftT, RightT>,
- bool >::type
-is_protonic_equal(const LeftT& left, const RightT& right)
-{
- return Map::lexicographical_protonic_equal(left, right);
-}
-
-//==============================================================================
-//= Size<IntervalSet|IntervalMap>
-//==============================================================================
-template<class Type>
-typename enable_if<is_interval_container<Type>, typename Type::size_type>::type
-cardinality(const Type& object)
-{
- using namespace boost::mpl;
- typedef typename Type::domain_type domain_type;
-
- return if_<
- bool_<is_continuous<domain_type>::value>,
- continuous_interval_container,
- discrete_interval_container
- >
- ::type::cardinality(object);
-}
-
-template<class Type>
-typename enable_if<is_interval_container<Type>, typename Type::difference_type>::type
-length(const Type& object)
-{
- typedef typename Type::difference_type difference_type;
- typedef typename Type::const_iterator const_iterator;
- difference_type length = neutron<difference_type>::value();
- const_iterator it_ = object.begin();
-
- while(it_ != object.end())
- length += itl::length(Type::key_value(it_++));
- return length;
-}
-
-template<class Type>
-typename enable_if<is_interval_container<Type>, std::size_t>::type
-interval_count(const Type& object)
-{
- return itl::iterative_size(object);
-}
-
-//==============================================================================
-//= Range<IntervalSet|IntervalMap>
-//==============================================================================
-template<class ObjectT>
-typename enable_if<is_interval_container<ObjectT>,
- typename ObjectT::interval_type>::type
-hull(const ObjectT& object)
-{
- return
- itl::is_empty(object) ? neutron<typename ObjectT::interval_type>::value()
- : hull((ObjectT::key_value(object.begin())), ObjectT::key_value(object.rbegin()));
-}
-
-//==============================================================================
-//= Addition<IntervalSet|IntervalMap>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& op +=(T&, c P&) T:{S}|{M} P:{e i}|{b p}
-//------------------------------------------------------------------------------
-/* \par \b Requires: \c OperandT is an addable derivative type of \c Type.
- \b Effects: \c operand is added to \c object.
- \par \b Returns: A reference to \c object.
- \b Complexity:
-\code
- \ OperandT:
- \ element segment
-Type:
- interval container O(log n) O(n)
-
- interval_set amortized
- spearate_interval_set O(log n)
-
-n = object.interval_count()
-\endcode
-
-For the addition of \b elements or \b segments
-complexity is \b logarithmic or \b linear respectively.
-For \c interval_sets and \c separate_interval_sets addition of segments
-is \b amortized \b logarithmic.
-*/
-template<class Type, class OperandT>
-typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
-operator += (Type& object, const OperandT& operand)
-{
- return itl::add(object, operand);
-}
-
-
-//------------------------------------------------------------------------------
-//- T& op +=(T&, c P&) T:{S}|{M} P:{S'}|{M'}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c OperandT is an interval container addable to \c Type.
- \b Effects: \c operand is added to \c object.
- \par \b Returns: A reference to \c object.
- \b Complexity: loglinear */
-template<class Type, class OperandT>
-typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
-operator += (Type& object, const OperandT& operand)
-{
- typename Type::iterator prior_ = object.end();
- ITL_const_FORALL(typename OperandT, elem_, operand)
- prior_ = itl::add(object, prior_, *elem_);
-
- return object;
-}
-
-
-//------------------------------------------------------------------------------
-//- T op + (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c object and \c operand are addable.
- \b Effects: \c operand is added to \c object.
- \par \b Efficieny: There is one additional copy of
- \c Type \c object compared to inplace \c operator \c += */
-template<class Type, class OperandT>
-typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
-operator + (Type object, const OperandT& operand)
-{
- return object += operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op + (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c object and \c operand are addable.
- \b Effects: \c operand is added to \c object.
- \par \b Efficieny: There is one additional copy of
- \c Type \c object compared to inplace \c operator \c += */
-template<class Type, class OperandT>
-typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
-operator + (const OperandT& operand, Type object)
-{
- return object += operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op + (T, c P&) T:{S}|{M} P:{S}|{M}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c object and \c operand are addable.
- \b Effects: \c operand is added to \c object.
- \par \b Efficieny: There is one additional copy of
- \c Type \c object compared to inplace \c operator \c += */
-template<class Type>
-typename enable_if<is_interval_container<Type>, Type>::type
-operator + (Type object, const Type& operand)
-{
- return object += operand;
-}
-
-
-//------------------------------------------------------------------------------
-//- Addition |=, |
-//------------------------------------------------------------------------------
-
-//------------------------------------------------------------------------------
-//- T& op |=(c P&) T:{S}|{M} P:{e i}|{b p}
-//------------------------------------------------------------------------------
-/** \par \b Requires: Types \c Type and \c OperandT are addable.
- \par \b Effects: \c operand is added to \c object.
- \par \b Returns: A reference to \c object.
- \b Complexity:
-\code
- \ OperandT: interval
- \ element segment container
-Type:
- interval container O(log n) O(n) O(m log(n+m))
-
- interval_set amortized
- spearate_interval_set O(log n)
-
-n = object.interval_count()
-m = operand.interval_count()
-\endcode
-
-For the addition of \b elements, \b segments and \b interval \b containers
-complexity is \b logarithmic, \b linear and \b loglinear respectively.
-For \c interval_sets and \c separate_interval_sets addition of segments
-is \b amortized \b logarithmic.
-*/
-template<class Type, class OperandT>
-typename enable_if<is_right_intra_combinable<Type, OperandT>, Type>::type&
-operator |= (Type& object, const OperandT& operand)
-{
- return object += operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op | (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c object and \c operand are addable.
- \b Effects: \c operand is added to \c object.
- \par \b Efficieny: There is one additional copy of
- \c Type \c object compared to inplace \c operator \c |= */
-template<class Type, class OperandT>
-typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
-operator | (Type object, const OperandT& operand)
-{
- return object += operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c object and \c operand are addable.
- \b Effects: \c operand is added to \c object.
- \par \b Efficieny: There is one additional copy of
- \c Type \c object compared to inplace \c operator \c |= */
-template<class Type, class OperandT>
-typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
-operator | (const OperandT& operand, Type object)
-{
- return object += operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
-//------------------------------------------------------------------------------
-/** \par \b Requires: \c object and \c operand are addable.
- \b Effects: \c operand is added to \c object.
- \par \b Efficieny: There is one additional copy of
- \c Type \c object compared to inplace \c operator \c |= */
-template<class Type>
-typename enable_if<is_interval_container<Type>, Type>::type
-operator | (Type object, const Type& operand)
-{
- return object += operand;
-}
-
-//==============================================================================
-//= Insertion<IntervalSet|IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& insert(T&, c P&) T:{S}|{M} P:{S'}|{M'}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
-insert(Type& object, const OperandT& operand)
-{
- typename Type::iterator prior_ = object.end();
- ITL_const_FORALL(typename OperandT, elem_, operand)
- insert(object, *elem_);
-
- return object;
-}
-
-//==============================================================================
-//= Erasure<IntervalSet|IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& erase(T&, c P&) T:{S}|{M} P:{S'}|{S' M'}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<combines_right_to_interval_container<Type, OperandT>,
- Type>::type&
-erase(Type& object, const OperandT& operand)
-{
- typedef typename OperandT::const_iterator const_iterator;
-
- if(itl::is_empty(operand))
- return object;
-
- const_iterator common_lwb, common_upb;
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return object;
-
- const_iterator it_ = common_lwb;
- while(it_ != common_upb)
- itl::erase(object, *it_++);
-
- return object;
-}
-
-//==============================================================================
-//= Subtraction<IntervalSet|IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- T& op -= (c P&) T:{M} P:{M'}
-//------------------------------------------------------------------------------
-/** \par \b Requires: Types \c Type and \c OperandT are subtractable.
- \par \b Effects: \c operand is subtracted from \c object.
- \par \b Returns: A reference to \c object.
- \b Complexity:
-\code
- \ OperandT: interval
- \ element segment container
-Type:
- interval container O(log n) O(n) O(m log(n+m))
-
- amortized
- interval_sets O(log n)
-
-n = object.interval_count()
-m = operand.interval_count()
-\endcode
-
-For the subtraction of \em elements, \b segments and \b interval \b containers
-complexity is \b logarithmic, \b linear and \b loglinear respectively.
-For interval sets subtraction of segments
-is \b amortized \b logarithmic.
-*/
-template<class Type, class OperandT>
-typename enable_if<is_concept_compatible<is_interval_map, Type, OperandT>,
- Type>::type&
-operator -=(Type& object, const OperandT& operand)
-{
- ITL_const_FORALL(typename OperandT, elem_, operand)
- itl::subtract(object, *elem_);
-
- return object;
-}
-
-//------------------------------------------------------------------------------
-//- T& op -= (c P&) T:{S}|{M} P:{e i}|{b p}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
-operator -= (Type& object, const OperandT& operand)
-{
- return itl::subtract(object, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& op -= (c P&) T:{M} P:{e i}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_cross_derivative<Type, OperandT>, Type>::type&
-operator -= (Type& object, const OperandT& operand)
-{
- return itl::erase(object, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& op -= (c P&) T:{S M} P:{S'}
-//------------------------------------------------------------------------------
-template<class Type, class IntervalSetT>
-typename enable_if<combines_right_to_interval_set<Type, IntervalSetT>,
- Type>::type&
-operator -= (Type& object, const IntervalSetT& operand)
-{
- return erase(object, operand);
-}
-
-
-//------------------------------------------------------------------------------
-//- T op - (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
-operator - (Type object, const OperandT& operand)
-{
- return object -= operand;
-}
-
-
-//==============================================================================
-//= Intersection<IntervalSet|IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- void add_intersection(T&, c T&, c P&) T:{S M} P:{S'}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<mpl::and_<is_interval_set<Type>,
- combines_right_to_interval_set<Type, OperandT> >,
- void>::type
-add_intersection(Type& section, const Type& object, const OperandT& operand)
-{
- typedef typename OperandT::const_iterator const_iterator;
-
- if(operand.empty())
- return;
-
- const_iterator common_lwb, common_upb;
- if(!Set::common_range(common_lwb, common_upb, operand, object))
- return;
-
- const_iterator it_ = common_lwb;
- while(it_ != common_upb)
- itl::add_intersection(section, object, OperandT::key_value(it_++));
-}
-
-//------------------------------------------------------------------------------
-//- T& op &=(T&, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type&
-operator &= (Type& object, const OperandT& operand)
-{
- Type intersection;
- add_intersection(intersection, object, operand);
- object.swap(intersection);
- return object;
-}
-
-//------------------------------------------------------------------------------
-//- T op & (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
-operator & (Type object, const OperandT& operand)
-{
- return object &= operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op & (c P&, T) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
-operator & (const OperandT& operand, Type object)
-{
- return object &= operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op & (T, c T&) T:{S M}
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_container<Type>, Type>::type
-operator & (Type object, const Type& operand)
-{
- return object &= operand;
-}
-
-//------------------------------------------------------------------------------
-//- intersects<IntervalSet|IntervalMap>
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//- bool intersects(c T&, c P&) T:{S}|{M} P:{e i}
-//------------------------------------------------------------------------------
-template<class Type, class CoType>
-typename enable_if<mpl::and_< is_interval_container<Type>
- , is_same<CoType, domain_type_of<Type> > >,
- bool>::type
-intersects(const Type& left, const CoType& right)
-{
- return itl::contains(left, right);
-}
-
-template<class Type, class CoType>
-typename enable_if<mpl::and_< is_interval_container<Type>
- , is_same<CoType, interval_type_of<Type> > >,
- bool>::type
-intersects(const Type& left, const CoType& right)
-{
- return left.find(right) != left.end();
-}
-
-template<class LeftT, class RightT>
-typename enable_if< mpl::and_< is_intra_combinable<LeftT, RightT>
- , mpl::or_<is_total<LeftT>, is_total<RightT> > >
- , bool>::type
-intersects(const LeftT& left, const RightT& right)
-{
- return true;
-}
-
-template<class LeftT, class RightT>
-typename enable_if< mpl::and_< is_intra_combinable<LeftT, RightT>
- , mpl::not_<mpl::or_< is_total<LeftT>
- , is_total<RightT> > > >
- , bool>::type
-intersects(const LeftT& left, const RightT& right)
-{
- typedef typename RightT::const_iterator const_iterator;
- LeftT intersection;
-
- const_iterator right_common_lower_, right_common_upper_;
- if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
- return false;
-
- const_iterator it_ = right_common_lower_;
- while(it_ != right_common_upper_)
- {
- itl::add_intersection(intersection, left, *it_++);
- if(!itl::is_empty(intersection))
- return true;
- }
- return false;
-}
-
-template<class LeftT, class RightT>
-typename enable_if<is_cross_combinable<LeftT, RightT>, bool>::type
-intersects(const LeftT& left, const RightT& right)
-{
- typedef typename RightT::const_iterator const_iterator;
- LeftT intersection;
-
- if(itl::is_empty(left) || itl::is_empty(right))
- return false;
-
- const_iterator right_common_lower_, right_common_upper_;
- if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
- return false;
-
- typename RightT::const_iterator it_ = right_common_lower_;
- while(it_ != right_common_upper_)
- {
- itl::add_intersection(intersection, left, RightT::key_value(it_++));
- if(!itl::is_empty(intersection))
- return true;
- }
-
- return false;
-}
-
-template<class Type, class AssociateT>
-typename enable_if<mpl::and_< is_interval_map<Type>
- , is_inter_derivative<Type, AssociateT> >,
- bool>::type
-intersects(const Type& left, const AssociateT& right)
-{
- return itl::intersects(left, right);
-}
-
-/** \b Returns true, if \c left and \c right have no common elements.
- Intervals are interpreted as sequence of elements.
- \b Complexity: loglinear, if \c left and \c right are interval containers. */
-template<class LeftT, class RightT>
-typename enable_if<is_inter_combinable<LeftT, RightT>, bool>::type
-disjoint(const LeftT& left, const RightT& right)
-{
- return !intersects(left, right);
-}
-
-/** \b Returns true, if \c left and \c right have no common elements.
- Intervals are interpreted as sequence of elements.
- \b Complexity: logarithmic, if \c AssociateT is an element type \c Type::element_type.
- linear, if \c AssociateT is a segment type \c Type::segment_type. */
-template<class Type, class AssociateT>
-typename enable_if<is_inter_derivative<Type, AssociateT>, bool>::type
-disjoint(const Type& left, const AssociateT& right)
-{
- return !intersects(left,right);
-}
-
-//==============================================================================
-//= Symmetric difference<IntervalSet|IntervalSet>
-//==============================================================================
-//------------------------------------------------------------------------------
-//- Symmetric difference ^=, ^
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//- T& op ^=(T&, c P&) T:{S}|{M} P:{S'}|{M'}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
-operator ^= (Type& object, const OperandT& operand)
-{
- return itl::flip(object, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T& op ^=(T&, c P&) T:{S}|{M} P:{e i}|{b p}
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
-operator ^= (Type& object, const OperandT& operand)
-{
- return itl::flip(object, operand);
-}
-
-//------------------------------------------------------------------------------
-//- T op ^ (T, c P&) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
-operator ^ (Type object, const OperandT& operand)
-{
- return object ^= operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op ^ (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
-//------------------------------------------------------------------------------
-template<class Type, class OperandT>
-typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
-operator ^ (const OperandT& operand, Type object)
-{
- return object ^= operand;
-}
-
-//------------------------------------------------------------------------------
-//- T op ^ (T, c T&) T:{S M}
-//------------------------------------------------------------------------------
-template<class Type>
-typename enable_if<is_interval_container<Type>, Type>::type
-operator ^ (typename Type::overloadable_type object, const Type& operand)
-{
- return object ^= operand;
-}
-
-//==========================================================================
-//= Element Iteration <IntervalSet|IntervalMap>
-//==========================================================================
-//--------------------------------------------------------------------------
-//- Forward
-//--------------------------------------------------------------------------
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_iterator>::type
-elements_begin(Type& object)
-{
- return typename Type::element_iterator(object.begin());
-}
-
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_iterator>::type
-elements_end(Type& object)
-{
- return typename Type::element_iterator(object.end());
-}
-
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_const_iterator>::type
-elements_begin(const Type& object)
-{
- return typename Type::element_const_iterator(object.begin());
-}
-
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_const_iterator>::type
-elements_end(const Type& object)
-{
- return typename Type::element_const_iterator(object.end());
-}
-
-//--------------------------------------------------------------------------
-//- Reverse
-//--------------------------------------------------------------------------
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_reverse_iterator>::type
-elements_rbegin(Type& object)
-{
- return typename Type::element_reverse_iterator(object.rbegin());
-}
-
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_reverse_iterator>::type
-elements_rend(Type& object)
-{
- return typename Type::element_reverse_iterator(object.rend());
-}
-
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_const_reverse_iterator>::type
-elements_rbegin(const Type& object)
-{
- return typename Type::element_const_reverse_iterator(object.rbegin());
-}
-
-template<class Type>
-typename enable_if
-<mpl::and_< is_interval_container<Type>
- , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
-typename Type::element_const_reverse_iterator>::type
-elements_rend(const Type& object)
-{
- return typename Type::element_const_reverse_iterator(object.rend());
-}
-
-//==============================================================================
-//= Morphisms
-//==============================================================================
-template<class Type>
-typename enable_if<is_interval_container<Type>, Type>::type&
-join(Type& object)
-{
- typedef typename Type::interval_type interval_type;
- typedef typename Type::iterator iterator;
-
- iterator it_ = object.begin();
- if(it_ == object.end())
- return object;
-
- iterator next_ = it_; next_++;
-
- while(next_ != object.end())
- {
- if( segmental::is_joinable<Type>(it_, next_) )
- {
- iterator fst_mem = it_; // hold the first member
-
- // Go on while touching members are found
- it_++; next_++;
- while( next_ != object.end()
- && segmental::is_joinable<Type>(it_, next_) )
- { it_++; next_++; }
-
- // finally we arrive at the end of a sequence of joinable intervals
- // and it points to the last member of that sequence
- const_cast<interval_type&>(Type::key_value(it_))
- = hull(Type::key_value(it_), Type::key_value(fst_mem));
- object.erase(fst_mem, it_);
-
- it_++; next_=it_;
- if(next_!=object.end())
- next_++;
- }
- else { it_++; next_++; }
- }
- return object;
-}
-
-
-
-}} // namespace boost itl
-
-#endif
-
-

Added: sandbox/itl/boost/itl/concept/interval_associator.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/interval_associator.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,838 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_INTERVAL_ASSOCIATOR_HPP_JOFA_100920
+#define BOOST_ITL_CONCEPT_INTERVAL_ASSOCIATOR_HPP_JOFA_100920
+
+#include <boost/itl/type_traits/domain_type_of.hpp>
+#include <boost/itl/type_traits/interval_type_of.hpp>
+#include <boost/itl/type_traits/is_combinable.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= Containedness<IntervalSet|IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- bool within(c T&, c P&) T={Set,Map} P={e i b p S M}
+//------------------------------------------------------------------------------
+template<class SubT, class SuperT>
+typename enable_if<is_interval_container<SuperT>, bool>::type
+within(const SubT& sub, const SuperT& super)
+{
+ return itl::contains(super, sub);
+}
+
+//==============================================================================
+//= Equivalences and Orderings<IntervalSet|IntervalMap>
+//==============================================================================
+template<class Type>
+inline typename enable_if<is_interval_container<Type>, bool>::type
+operator == (const Type& left, const Type& right)
+{
+ return Set::lexicographical_equal(left, right);
+}
+
+template<class Type>
+inline typename enable_if<is_interval_container<Type>, bool>::type
+operator < (const Type& left, const Type& right)
+{
+ typedef typename Type::segment_compare segment_compare;
+ return std::lexicographical_compare(
+ left.begin(), left.end(), right.begin(), right.end(),
+ segment_compare()
+ );
+}
+
+/** Returns true, if \c left and \c right contain the same elements.
+ Complexity: linear. */
+template<class LeftT, class RightT>
+typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
+is_element_equal(const LeftT& left, const RightT& right)
+{
+ return Interval_Set::is_element_equal(left, right);
+}
+
+/** Returns true, if \c left is lexicographically less than \c right.
+ Intervals are interpreted as sequence of elements.
+ Complexity: linear. */
+template<class LeftT, class RightT>
+typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
+is_element_less(const LeftT& left, const RightT& right)
+{
+ return Interval_Set::is_element_less(left, right);
+}
+
+/** Returns true, if \c left is lexicographically greater than \c right.
+ Intervals are interpreted as sequence of elements.
+ Complexity: linear. */
+template<class LeftT, class RightT>
+typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
+is_element_greater(const LeftT& left, const RightT& right)
+{
+ return Interval_Set::is_element_greater(left, right);
+}
+
+//------------------------------------------------------------------------------
+template<class LeftT, class RightT>
+typename enable_if<is_inter_combinable<LeftT, RightT>, int>::type
+inclusion_compare(const LeftT& left, const RightT& right)
+{
+ return Interval_Set::subset_compare(left, right,
+ left.begin(), left.end(),
+ right.begin(), right.end());
+}
+
+template<class LeftT, class RightT>
+typename enable_if<is_concept_equivalent<is_element_container,LeftT, RightT>,
+ int>::type
+inclusion_compare(const LeftT& left, const RightT& right)
+{
+ return Set::subset_compare(left, right,
+ left.begin(), left.end(),
+ right.begin(), right.end());
+}
+//------------------------------------------------------------------------------
+
+template<class LeftT, class RightT>
+typename enable_if< is_concept_compatible<is_interval_map, LeftT, RightT>,
+ bool >::type
+is_protonic_equal(const LeftT& left, const RightT& right)
+{
+ return Map::lexicographical_protonic_equal(left, right);
+}
+
+//==============================================================================
+//= Size<IntervalSet|IntervalMap>
+//==============================================================================
+template<class Type>
+typename enable_if<is_interval_container<Type>, typename Type::size_type>::type
+cardinality(const Type& object)
+{
+ using namespace boost::mpl;
+ typedef typename Type::domain_type domain_type;
+
+ return if_<
+ bool_<is_continuous<domain_type>::value>,
+ continuous_interval_container,
+ discrete_interval_container
+ >
+ ::type::cardinality(object);
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, typename Type::difference_type>::type
+length(const Type& object)
+{
+ typedef typename Type::difference_type difference_type;
+ typedef typename Type::const_iterator const_iterator;
+ difference_type length = neutron<difference_type>::value();
+ const_iterator it_ = object.begin();
+
+ while(it_ != object.end())
+ length += itl::length(key_value<Type>(it_++));
+ return length;
+}
+
+template<class Type>
+typename enable_if<is_interval_container<Type>, std::size_t>::type
+interval_count(const Type& object)
+{
+ return itl::iterative_size(object);
+}
+
+//==============================================================================
+//= Range<IntervalSet|IntervalMap>
+//==============================================================================
+template<class ObjectT>
+typename enable_if<is_interval_container<ObjectT>,
+ typename ObjectT::interval_type>::type
+hull(const ObjectT& object)
+{
+ return
+ itl::is_empty(object) ? neutron<typename ObjectT::interval_type>::value()
+ : hull((key_value<ObjectT>(object.begin())), key_value<ObjectT>(object.rbegin()));
+}
+
+//==============================================================================
+//= Addition<IntervalSet|IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& op +=(T&, c P&) T:{S}|{M} P:{e i}|{b p}
+//------------------------------------------------------------------------------
+/* \par \b Requires: \c OperandT is an addable derivative type of \c Type.
+ \b Effects: \c operand is added to \c object.
+ \par \b Returns: A reference to \c object.
+ \b Complexity:
+\code
+ \ OperandT:
+ \ element segment
+Type:
+ interval container O(log n) O(n)
+
+ interval_set amortized
+ spearate_interval_set O(log n)
+
+n = object.interval_count()
+\endcode
+
+For the addition of \b elements or \b segments
+complexity is \b logarithmic or \b linear respectively.
+For \c interval_sets and \c separate_interval_sets addition of segments
+is \b amortized \b logarithmic.
+*/
+template<class Type, class OperandT>
+typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
+operator += (Type& object, const OperandT& operand)
+{
+ return itl::add(object, operand);
+}
+
+
+//------------------------------------------------------------------------------
+//- T& op +=(T&, c P&) T:{S}|{M} P:{S'}|{M'}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c OperandT is an interval container addable to \c Type.
+ \b Effects: \c operand is added to \c object.
+ \par \b Returns: A reference to \c object.
+ \b Complexity: loglinear */
+template<class Type, class OperandT>
+typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
+operator += (Type& object, const OperandT& operand)
+{
+ typename Type::iterator prior_ = object.end();
+ ITL_const_FORALL(typename OperandT, elem_, operand)
+ prior_ = itl::add(object, prior_, *elem_);
+
+ return object;
+}
+
+
+//------------------------------------------------------------------------------
+//- T op + (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c object and \c operand are addable.
+ \b Effects: \c operand is added to \c object.
+ \par \b Efficieny: There is one additional copy of
+ \c Type \c object compared to inplace \c operator \c += */
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator + (Type object, const OperandT& operand)
+{
+ return object += operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op + (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c object and \c operand are addable.
+ \b Effects: \c operand is added to \c object.
+ \par \b Efficieny: There is one additional copy of
+ \c Type \c object compared to inplace \c operator \c += */
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator + (const OperandT& operand, Type object)
+{
+ return object += operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op + (T, c P&) T:{S}|{M} P:{S}|{M}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c object and \c operand are addable.
+ \b Effects: \c operand is added to \c object.
+ \par \b Efficieny: There is one additional copy of
+ \c Type \c object compared to inplace \c operator \c += */
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator + (Type object, const Type& operand)
+{
+ return object += operand;
+}
+
+
+//------------------------------------------------------------------------------
+//- Addition |=, |
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+//- T& op |=(c P&) T:{S}|{M} P:{e i}|{b p}
+//------------------------------------------------------------------------------
+/** \par \b Requires: Types \c Type and \c OperandT are addable.
+ \par \b Effects: \c operand is added to \c object.
+ \par \b Returns: A reference to \c object.
+ \b Complexity:
+\code
+ \ OperandT: interval
+ \ element segment container
+Type:
+ interval container O(log n) O(n) O(m log(n+m))
+
+ interval_set amortized
+ spearate_interval_set O(log n)
+
+n = object.interval_count()
+m = operand.interval_count()
+\endcode
+
+For the addition of \b elements, \b segments and \b interval \b containers
+complexity is \b logarithmic, \b linear and \b loglinear respectively.
+For \c interval_sets and \c separate_interval_sets addition of segments
+is \b amortized \b logarithmic.
+*/
+template<class Type, class OperandT>
+typename enable_if<is_right_intra_combinable<Type, OperandT>, Type>::type&
+operator |= (Type& object, const OperandT& operand)
+{
+ return object += operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op | (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c object and \c operand are addable.
+ \b Effects: \c operand is added to \c object.
+ \par \b Efficieny: There is one additional copy of
+ \c Type \c object compared to inplace \c operator \c |= */
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator | (Type object, const OperandT& operand)
+{
+ return object += operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c object and \c operand are addable.
+ \b Effects: \c operand is added to \c object.
+ \par \b Efficieny: There is one additional copy of
+ \c Type \c object compared to inplace \c operator \c |= */
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator | (const OperandT& operand, Type object)
+{
+ return object += operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
+//------------------------------------------------------------------------------
+/** \par \b Requires: \c object and \c operand are addable.
+ \b Effects: \c operand is added to \c object.
+ \par \b Efficieny: There is one additional copy of
+ \c Type \c object compared to inplace \c operator \c |= */
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator | (Type object, const Type& operand)
+{
+ return object += operand;
+}
+
+//==============================================================================
+//= Insertion<IntervalSet|IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& insert(T&, c P&) T:{S}|{M} P:{S'}|{M'}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
+insert(Type& object, const OperandT& operand)
+{
+ typename Type::iterator prior_ = object.end();
+ ITL_const_FORALL(typename OperandT, elem_, operand)
+ insert(object, *elem_);
+
+ return object;
+}
+
+//==============================================================================
+//= Erasure<IntervalSet|IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& erase(T&, c P&) T:{S}|{M} P:{S'}|{S' M'}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<combines_right_to_interval_container<Type, OperandT>,
+ Type>::type&
+erase(Type& object, const OperandT& operand)
+{
+ typedef typename OperandT::const_iterator const_iterator;
+
+ if(itl::is_empty(operand))
+ return object;
+
+ const_iterator common_lwb, common_upb;
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return object;
+
+ const_iterator it_ = common_lwb;
+ while(it_ != common_upb)
+ itl::erase(object, *it_++);
+
+ return object;
+}
+
+//==============================================================================
+//= Subtraction<IntervalSet|IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& op -= (c P&) T:{M} P:{M'}
+//------------------------------------------------------------------------------
+/** \par \b Requires: Types \c Type and \c OperandT are subtractable.
+ \par \b Effects: \c operand is subtracted from \c object.
+ \par \b Returns: A reference to \c object.
+ \b Complexity:
+\code
+ \ OperandT: interval
+ \ element segment container
+Type:
+ interval container O(log n) O(n) O(m log(n+m))
+
+ amortized
+ interval_sets O(log n)
+
+n = object.interval_count()
+m = operand.interval_count()
+\endcode
+
+For the subtraction of \em elements, \b segments and \b interval \b containers
+complexity is \b logarithmic, \b linear and \b loglinear respectively.
+For interval sets subtraction of segments
+is \b amortized \b logarithmic.
+*/
+template<class Type, class OperandT>
+typename enable_if<is_concept_compatible<is_interval_map, Type, OperandT>,
+ Type>::type&
+operator -=(Type& object, const OperandT& operand)
+{
+ ITL_const_FORALL(typename OperandT, elem_, operand)
+ itl::subtract(object, *elem_);
+
+ return object;
+}
+
+//------------------------------------------------------------------------------
+//- T& op -= (c P&) T:{S}|{M} P:{e i}|{b p}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
+operator -= (Type& object, const OperandT& operand)
+{
+ return itl::subtract(object, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& op -= (c P&) T:{M} P:{e i}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_cross_derivative<Type, OperandT>, Type>::type&
+operator -= (Type& object, const OperandT& operand)
+{
+ return itl::erase(object, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& op -= (c P&) T:{S M} P:{S'}
+//------------------------------------------------------------------------------
+template<class Type, class IntervalSetT>
+typename enable_if<combines_right_to_interval_set<Type, IntervalSetT>,
+ Type>::type&
+operator -= (Type& object, const IntervalSetT& operand)
+{
+ return erase(object, operand);
+}
+
+
+//------------------------------------------------------------------------------
+//- T op - (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
+operator - (Type object, const OperandT& operand)
+{
+ return object -= operand;
+}
+
+
+//==============================================================================
+//= Intersection<IntervalSet|IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- void add_intersection(T&, c T&, c P&) T:{S M} P:{S'}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<mpl::and_<is_interval_set<Type>,
+ combines_right_to_interval_set<Type, OperandT> >,
+ void>::type
+add_intersection(Type& section, const Type& object, const OperandT& operand)
+{
+ typedef typename OperandT::const_iterator const_iterator;
+
+ if(operand.empty())
+ return;
+
+ const_iterator common_lwb, common_upb;
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return;
+
+ const_iterator it_ = common_lwb;
+ while(it_ != common_upb)
+ itl::add_intersection(section, object, key_value<OperandT>(it_++));
+}
+
+//------------------------------------------------------------------------------
+//- T& op &=(T&, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type&
+operator &= (Type& object, const OperandT& operand)
+{
+ Type intersection;
+ add_intersection(intersection, object, operand);
+ object.swap(intersection);
+ return object;
+}
+
+//------------------------------------------------------------------------------
+//- T op & (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
+operator & (Type object, const OperandT& operand)
+{
+ return object &= operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op & (c P&, T) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
+operator & (const OperandT& operand, Type object)
+{
+ return object &= operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op & (T, c T&) T:{S M}
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator & (Type object, const Type& operand)
+{
+ return object &= operand;
+}
+
+//------------------------------------------------------------------------------
+//- intersects<IntervalSet|IntervalMap>
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//- bool intersects(c T&, c P&) T:{S}|{M} P:{e i}
+//------------------------------------------------------------------------------
+template<class Type, class CoType>
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_same<CoType, domain_type_of<Type> > >,
+ bool>::type
+intersects(const Type& left, const CoType& right)
+{
+ return itl::contains(left, right);
+}
+
+template<class Type, class CoType>
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_same<CoType, interval_type_of<Type> > >,
+ bool>::type
+intersects(const Type& left, const CoType& right)
+{
+ return left.find(right) != left.end();
+}
+
+template<class LeftT, class RightT>
+typename enable_if< mpl::and_< is_intra_combinable<LeftT, RightT>
+ , mpl::or_<is_total<LeftT>, is_total<RightT> > >
+ , bool>::type
+intersects(const LeftT& left, const RightT& right)
+{
+ return true;
+}
+
+template<class LeftT, class RightT>
+typename enable_if< mpl::and_< is_intra_combinable<LeftT, RightT>
+ , mpl::not_<mpl::or_< is_total<LeftT>
+ , is_total<RightT> > > >
+ , bool>::type
+intersects(const LeftT& left, const RightT& right)
+{
+ typedef typename RightT::const_iterator const_iterator;
+ LeftT intersection;
+
+ const_iterator right_common_lower_, right_common_upper_;
+ if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
+ return false;
+
+ const_iterator it_ = right_common_lower_;
+ while(it_ != right_common_upper_)
+ {
+ itl::add_intersection(intersection, left, *it_++);
+ if(!itl::is_empty(intersection))
+ return true;
+ }
+ return false;
+}
+
+template<class LeftT, class RightT>
+typename enable_if<is_cross_combinable<LeftT, RightT>, bool>::type
+intersects(const LeftT& left, const RightT& right)
+{
+ typedef typename RightT::const_iterator const_iterator;
+ LeftT intersection;
+
+ if(itl::is_empty(left) || itl::is_empty(right))
+ return false;
+
+ const_iterator right_common_lower_, right_common_upper_;
+ if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
+ return false;
+
+ typename RightT::const_iterator it_ = right_common_lower_;
+ while(it_ != right_common_upper_)
+ {
+ itl::add_intersection(intersection, left, key_value<RightT>(it_++));
+ if(!itl::is_empty(intersection))
+ return true;
+ }
+
+ return false;
+}
+
+template<class Type, class AssociateT>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , is_inter_derivative<Type, AssociateT> >,
+ bool>::type
+intersects(const Type& left, const AssociateT& right)
+{
+ return itl::intersects(left, right);
+}
+
+/** \b Returns true, if \c left and \c right have no common elements.
+ Intervals are interpreted as sequence of elements.
+ \b Complexity: loglinear, if \c left and \c right are interval containers. */
+template<class LeftT, class RightT>
+typename enable_if<is_inter_combinable<LeftT, RightT>, bool>::type
+disjoint(const LeftT& left, const RightT& right)
+{
+ return !intersects(left, right);
+}
+
+/** \b Returns true, if \c left and \c right have no common elements.
+ Intervals are interpreted as sequence of elements.
+ \b Complexity: logarithmic, if \c AssociateT is an element type \c Type::element_type.
+ linear, if \c AssociateT is a segment type \c Type::segment_type. */
+template<class Type, class AssociateT>
+typename enable_if<is_inter_derivative<Type, AssociateT>, bool>::type
+disjoint(const Type& left, const AssociateT& right)
+{
+ return !intersects(left,right);
+}
+
+//==============================================================================
+//= Symmetric difference<IntervalSet|IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- Symmetric difference ^=, ^
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//- T& op ^=(T&, c P&) T:{S}|{M} P:{S'}|{M'}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
+operator ^= (Type& object, const OperandT& operand)
+{
+ return itl::flip(object, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& op ^=(T&, c P&) T:{S}|{M} P:{e i}|{b p}
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
+operator ^= (Type& object, const OperandT& operand)
+{
+ return itl::flip(object, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T op ^ (T, c P&) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator ^ (Type object, const OperandT& operand)
+{
+ return object ^= operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op ^ (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
+operator ^ (const OperandT& operand, Type object)
+{
+ return object ^= operand;
+}
+
+//------------------------------------------------------------------------------
+//- T op ^ (T, c T&) T:{S M}
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type
+operator ^ (typename Type::overloadable_type object, const Type& operand)
+{
+ return object ^= operand;
+}
+
+//==========================================================================
+//= Element Iteration <IntervalSet|IntervalMap>
+//==========================================================================
+//--------------------------------------------------------------------------
+//- Forward
+//--------------------------------------------------------------------------
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_iterator>::type
+elements_begin(Type& object)
+{
+ return typename Type::element_iterator(object.begin());
+}
+
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_iterator>::type
+elements_end(Type& object)
+{
+ return typename Type::element_iterator(object.end());
+}
+
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_const_iterator>::type
+elements_begin(const Type& object)
+{
+ return typename Type::element_const_iterator(object.begin());
+}
+
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_const_iterator>::type
+elements_end(const Type& object)
+{
+ return typename Type::element_const_iterator(object.end());
+}
+
+//--------------------------------------------------------------------------
+//- Reverse
+//--------------------------------------------------------------------------
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_reverse_iterator>::type
+elements_rbegin(Type& object)
+{
+ return typename Type::element_reverse_iterator(object.rbegin());
+}
+
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_reverse_iterator>::type
+elements_rend(Type& object)
+{
+ return typename Type::element_reverse_iterator(object.rend());
+}
+
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_const_reverse_iterator>::type
+elements_rbegin(const Type& object)
+{
+ return typename Type::element_const_reverse_iterator(object.rbegin());
+}
+
+template<class Type>
+typename enable_if
+<mpl::and_< is_interval_container<Type>
+ , mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
+typename Type::element_const_reverse_iterator>::type
+elements_rend(const Type& object)
+{
+ return typename Type::element_const_reverse_iterator(object.rend());
+}
+
+//==============================================================================
+//= Morphisms
+//==============================================================================
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type&
+join(Type& object)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::iterator iterator;
+
+ iterator it_ = object.begin();
+ if(it_ == object.end())
+ return object;
+
+ iterator next_ = it_; next_++;
+
+ while(next_ != object.end())
+ {
+ if( segmental::is_joinable<Type>(it_, next_) )
+ {
+ iterator fst_mem = it_; // hold the first member
+
+ // Go on while touching members are found
+ it_++; next_++;
+ while( next_ != object.end()
+ && segmental::is_joinable<Type>(it_, next_) )
+ { it_++; next_++; }
+
+ // finally we arrive at the end of a sequence of joinable intervals
+ // and it points to the last member of that sequence
+ const_cast<interval_type&>(key_value<Type>(it_))
+ = hull(key_value<Type>(it_), key_value<Type>(fst_mem));
+ object.erase(fst_mem, it_);
+
+ it_++; next_=it_;
+ if(next_!=object.end())
+ next_++;
+ }
+ else { it_++; next_++; }
+ }
+ return object;
+}
+
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/interval_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/interval_map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,632 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_INTERVAL_MAP_HPP_JOFA_100920
+#define BOOST_ITL_CONCEPT_INTERVAL_MAP_HPP_JOFA_100920
+
+#include <boost/itl/type_traits/element_type_of.hpp>
+#include <boost/itl/type_traits/segment_type_of.hpp>
+#include <boost/itl/type_traits/absorbs_neutrons.hpp>
+#include <boost/itl/type_traits/is_combinable.hpp>
+
+#include <boost/itl/concept/map_value.hpp>
+#include <boost/itl/detail/interval_map_algo.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= Containedness<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{M} P:{b p M} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, bool>::type
+contains(const Type& super, const typename Type::element_type& key_value_pair)
+{
+ typedef typename Type::const_iterator const_iterator;
+ const_iterator it_ = super.find(key_value_pair.key);
+ return it_ != super.end() && it_->second == key_value_pair.data;
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, bool>::type
+contains(const Type& super, const typename Type::segment_type& sub_segment)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::const_iterator const_iterator;
+
+ interval_type sub_interval = sub_segment.first;
+ if(itl::is_empty(sub_interval))
+ return true;
+
+ std::pair<const_iterator, const_iterator> exterior = super.equal_range(sub_interval);
+ if(exterior.first == exterior.second)
+ return false;
+
+ const_iterator last_overlap = prior(exterior.second);
+
+ if(!(sub_segment.second == exterior.first->second) )
+ return false;
+
+ return
+ itl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
+ && Interval_Map::is_joinable(super, exterior.first, last_overlap);
+}
+
+template<class Type, class CoType>
+typename enable_if<is_concept_compatible<is_interval_map, Type, CoType>, bool>::type
+contains(const Type& super, const CoType& sub)
+{
+ return Interval_Set::within(sub, super);
+}
+
+
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{M} P:{e i S} key_types : total
+//------------------------------------------------------------------------------
+template<class Type, class CoType>
+typename enable_if< mpl::and_< is_interval_map<Type>
+ , is_total<Type>
+ , is_cross_derivative<Type, CoType> >
+ , bool>::type
+contains(const Type& super, const CoType& sub)
+{
+ return true;
+}
+
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{M} P:{e i S} key_types : partial
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if< mpl::and_< is_interval_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+contains(const Type& super, const typename Type::domain_type& key)
+{
+ return super.find(key) != super.end();
+}
+
+template<class Type>
+typename enable_if< mpl::and_< is_interval_map<Type>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+contains(const Type& super, const typename Type::interval_type& sub_interval)
+{
+ typedef typename Type::const_iterator const_iterator;
+
+ if(itl::is_empty(sub_interval))
+ return true;
+
+ std::pair<const_iterator, const_iterator> exterior = super.equal_range(sub_interval);
+ if(exterior.first == exterior.second)
+ return false;
+
+ const_iterator last_overlap = prior(exterior.second);
+
+ return
+ itl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
+ && Interval_Set::is_joinable(super, exterior.first, last_overlap);
+}
+
+template<class Type, class KeyT>
+typename enable_if< mpl::and_< is_concept_combinable<is_interval_map, is_interval_set, Type, KeyT>
+ , mpl::not_<is_total<Type> > >
+ , bool>::type
+contains(const Type& super, const KeyT& sub)
+{
+ return Interval_Set::within(sub, super);
+}
+
+
+//==============================================================================
+//= Addition<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& add(T&, c P&) T:{M} P:{b p} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+add(Type& object, const typename Type::element_type& operand)
+{
+ return object.add(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+add(Type& object, const typename Type::segment_type& operand)
+{
+ return object.add(operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& add(T&, J, c P&) T:{M} P:{p} segment_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, typename Type::iterator >::type
+add(Type& object, typename Type::iterator prior_,
+ const typename Type::segment_type& operand)
+{
+ return object.add(prior_, operand);
+}
+
+//==============================================================================
+//= Insertion<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& insert(T&, c P&) T:{M} P:{b p} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+insert(Type& object, const typename Type::element_type& operand)
+{
+ return object.insert(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+insert(Type& object, const typename Type::segment_type& operand)
+{
+ return object.insert(operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& insert(T&, J, c P&) T:{M} P:{p} with hint
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, typename Type::iterator>::type
+insert(Type& object, typename Type::iterator prior,
+ const typename Type::segment_type& operand)
+{
+ return object.insert(prior, operand);
+}
+
+
+//==============================================================================
+//= Erasure<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& erase(T&, c P&) T:{M} P:{e i} key_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+erase(Type& object, const typename Type::domain_type& minuend)
+{
+ return object.erase(minuend);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+erase(Type& object, const typename Type::interval_type& minuend)
+{
+ return object.erase(minuend);
+}
+
+//------------------------------------------------------------------------------
+//- T& erase(T&, c P&) T:{M} P:{b p} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+erase(Type& object, const typename Type::element_type& minuend)
+{
+ return object.erase(minuend);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+erase(Type& object, const typename Type::segment_type& minuend)
+{
+ return object.erase(minuend);
+}
+
+//==============================================================================
+//= Subtraction<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{M} P:{b p} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::element_type& operand)
+{
+ return object.subtract(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::segment_type& operand)
+{
+ return object.subtract(operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{M} P:{e i} key_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::domain_type& operand)
+{
+ return object.erase(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+subtract(Type& object, const typename Type::interval_type& operand)
+{
+ return object.erase(operand);
+}
+
+//==============================================================================
+//= Selective Update<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& set_at(T&, c P&) T:{M} P:{e i}
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+set_at(Type& object, const typename Type::segment_type& operand)
+{
+ itl::erase(object, operand.first);
+ return itl::insert(object, operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+set_at(Type& object, const typename Type::element_type& operand)
+{
+ return itl::set_at(object, make_segment<Type>(operand));
+}
+
+//==============================================================================
+//= Intersection<IntervalMap>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{M} P:{b p} fragment_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::element_type& operand)
+{
+ object.add_intersection(section, operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::segment_type& operand)
+{
+ object.add_intersection(section, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{M} P:{M'} map fragment_type total
+//------------------------------------------------------------------------------
+template<class Type, class MapT>
+typename enable_if
+<
+ mpl::and_< is_total<Type>
+ , is_concept_compatible<is_interval_map, Type, MapT> >
+ , void
+>::type
+add_intersection(Type& section, const Type& object, const MapT& operand)
+{
+ section += object;
+ section += operand;
+}
+
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{M} P:{M'} map fragment_type partial
+//------------------------------------------------------------------------------
+template<class Type, class MapT>
+typename enable_if
+<
+ mpl::and_< mpl::not_<is_total<Type> >
+ , is_concept_compatible<is_interval_map, Type, MapT> >
+ , void
+>::type
+add_intersection(Type& section, const Type& object, const MapT& operand)
+{
+ typedef typename Type::segment_type segment_type;
+ typedef typename Type::interval_type interval_type;
+ typedef typename MapT::const_iterator const_iterator;
+
+ if(operand.empty())
+ return;
+ const_iterator common_lwb, common_upb;
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return;
+ const_iterator it_ = common_lwb;
+ while(it_ != common_upb)
+ add_intersection(section, object, *it_++);
+}
+
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{M} P:{e i S} key_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::domain_type& key_value)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::segment_type segment_type;
+ typedef typename Type::const_iterator const_iterator;
+
+ const_iterator it_ = object.find(key_value);
+ if(it_ != object.end())
+ add(section, segment_type(interval_type(key_value),it_->second));
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::interval_type& inter_val)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::value_type value_type;
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::iterator iterator;
+
+ if(itl::is_empty(inter_val))
+ return;
+
+ std::pair<const_iterator, const_iterator> exterior
+ = object.equal_range(inter_val);
+ if(exterior.first == exterior.second)
+ return;
+
+ iterator prior_ = section.end();
+ for(const_iterator it_=exterior.first; it_ != exterior.second; it_++)
+ {
+ interval_type common_interval = it_->first & inter_val;
+ if(!itl::is_empty(common_interval))
+ prior_ = add(section, prior_,
+ value_type(common_interval, it_->second) );
+ }
+}
+
+template<class Type, class KeySetT>
+typename enable_if<is_concept_combinable<is_interval_map, is_interval_set, Type, KeySetT>, void>::type
+add_intersection(Type& section, const Type& object, const KeySetT& key_set)
+{
+ typedef typename KeySetT::const_iterator const_iterator;
+
+ if(itl::is_empty(key_set))
+ return;
+
+ const_iterator common_lwb, common_upb;
+ if(!Set::common_range(common_lwb, common_upb, key_set, object))
+ return;
+
+ const_iterator it_ = common_lwb;
+ while(it_ != common_upb)
+ add_intersection(section, object, *it_++);
+}
+
+//------------------------------------------------------------------------------
+//- intersects<IntervalMaps> fragment_types
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , is_total<Type>
+ , is_same<OperandT, segment_type_of<Type> > >,
+ bool>::type
+intersects(const Type&, const OperandT&)
+{
+ return true;
+}
+
+template<class Type, class OperandT>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , mpl::not_<is_total<Type> >
+ , is_same<OperandT, segment_type_of<Type> > >,
+ bool>::type
+intersects(const Type& object, const OperandT& operand)
+{
+ Type intersection; //JODO
+ itl::add_intersection(intersection, left, operand);
+ return !itl::is_empty(intersection);
+}
+
+template<class Type, class OperandT>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , is_same<OperandT, element_type_of<Type> > >,
+ bool>::type
+intersects(const Type& object, const OperandT& operand)
+{
+ return itl::intersects(object, make_segment<Type>(operand));
+}
+
+//------------------------------------------------------------------------------
+//- Symmetric difference flip<Interval_Map> fragment_types
+//------------------------------------------------------------------------------
+//JODO NOTE: typename enable_if< mpl::and_< is_interval_map_right_intra_combinable<Type, OperandT> //JODO =^= fragment_type_of
+//------------------------------------------------------------------------------
+//- T& flip(T&, c P&) T:{M} P:{b p} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+flip(Type& object, const typename Type::element_type& operand)
+{
+ return object.flip(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_map<Type>, Type>::type&
+flip(Type& object, const typename Type::segment_type& operand)
+{
+ return object.flip(operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& flip(T&, c P&) T:{M} P:{M'} total absorber
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if< mpl::and_< is_total<Type>
+ , absorbs_neutrons<Type>
+ , is_concept_compatible<is_interval_map,
+ Type, OperandT >
+ >
+ , Type>::type&
+flip(Type& object, const OperandT&)
+{
+ object.clear();
+ return object;
+}
+
+//------------------------------------------------------------------------------
+//- T& flip(T&, c P&) T:{M} P:{M'} total enricher
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if< mpl::and_< is_total<Type>
+ , mpl::not_<absorbs_neutrons<Type> >
+ , is_concept_compatible<is_interval_map,
+ Type, OperandT >
+ >
+ , Type>::type&
+flip(Type& object, const OperandT& operand)
+{
+ typedef typename Type::codomain_type codomain_type;
+
+ object += operand;
+ ITL_FORALL(typename Type, it_, object) //JODO: neutralisierendes add.
+ it_->second = neutron<codomain_type>::value();
+
+ if(mpl::not_<is_interval_splitter<Type> >::value) //JODO
+ itl::join(object);
+
+ return object;
+}
+
+//------------------------------------------------------------------------------
+//- T& flip(T&, c P&) T:{M} P:{M'} partial
+//------------------------------------------------------------------------------
+template<class Type, class OperandT>
+typename enable_if< mpl::and_< mpl::not_<is_total<Type> >
+ , is_concept_compatible<is_interval_map,
+ Type, OperandT >
+ >
+ , Type>::type&
+flip(Type& object, const OperandT& operand)
+{
+ typedef typename OperandT::const_iterator const_iterator;
+ typedef typename Type::codomain_type codomain_type;
+
+ const_iterator common_lwb, common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return object += operand;
+
+ const_iterator it_ = operand.begin();
+
+ // All elements of operand left of the common range are added
+ while(it_ != common_lwb)
+ itl::add(object, *it_++);
+ // All elements of operand in the common range are symmetrically subtracted
+ while(it_ != common_upb)
+ itl::flip(object, *it_++);
+ // All elements of operand right of the common range are added
+ while(it_ != operand.end())
+ itl::add(object, *it_++);
+
+ return object;
+}
+
+//==============================================================================
+//= Domain
+//==============================================================================
+template<class Type, class SetT>
+typename enable_if<is_concept_combinable<is_interval_set, is_interval_map,
+ SetT, Type>, SetT>::type&
+domain(SetT& result, const Type& object)
+{
+ result.clear();
+ ITL_const_FORALL(typename Type, it_, object)
+ result += it_->first;
+
+ return result;
+}
+
+//==============================================================================
+//= Manipulation by predicates
+//==============================================================================
+template<class MapT, class Predicate> //JODO unify with element_map . . .
+typename enable_if<is_interval_map<MapT>, MapT>::type&
+erase_if(const Predicate& pred, MapT& object)
+{
+ typename MapT::iterator it_ = object.begin();
+ while(it_ != object.end())
+ if(pred(*it_))
+ object.erase(it_++);
+ else ++it_;
+ return object;
+}
+
+template<class MapT, class Predicate>
+inline typename enable_if<is_interval_map<MapT>, MapT>::type&
+add_if(const Predicate& pred, MapT& object, const MapT& src)
+{
+ typename MapT::const_iterator it_ = src.begin();
+ while(it_ != src.end())
+ if(pred(*it_))
+ itl::add(object, *it_++);
+
+ return object;
+}
+
+template<class MapT, class Predicate>
+inline typename enable_if<is_interval_map<MapT>, MapT>::type&
+assign_if(const Predicate& pred, MapT& object, const MapT& src)
+{
+ itl::clear(object);
+ return add_if(object, src, pred);
+}
+
+
+//==============================================================================
+//= Morphisms
+//==============================================================================
+template<class Type>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , absorbs_neutrons<Type> >, Type>::type&
+absorb_neutrons(Type& object)
+{
+ return object;
+}
+
+template<class Type>
+typename enable_if<mpl::and_< is_interval_map<Type>
+ , mpl::not_<absorbs_neutrons<Type> > >, Type>::type&
+absorb_neutrons(Type& object)
+{
+ typedef typename Type::segment_type segment_type;
+ return itl::erase_if(content_is_neutron<segment_type>(), object);
+}
+
+//==============================================================================
+//= Streaming
+//==============================================================================
+template<class CharType, class CharTraits, class Type>
+typename enable_if<is_interval_map<Type>,
+ std::basic_ostream<CharType, CharTraits> >::type&
+operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
+{
+ stream << "{";
+ ITL_const_FORALL(typename Type, it_, object)
+ stream << "(" << it_->first << "->" << it_->second << ")";
+
+ return stream << "}";
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/interval_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/interval_set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,309 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_INTERVAL_SET_HPP_JOFA_100920
+#define BOOST_ITL_CONCEPT_INTERVAL_SET_HPP_JOFA_100920
+
+#include <boost/itl/type_traits/is_combinable.hpp>
+
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= Containedness<IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- bool contains(c T&, c P&) T:{S} P:{e i S} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, bool>::type
+contains(const Type& super, const typename Type::element_type& element)
+{
+ return !(super.find(element) == super.end());
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, bool>::type
+contains(const Type& super, const typename Type::segment_type& inter_val)
+{
+ typedef typename Type::const_iterator const_iterator;
+ if(itl::is_empty(inter_val))
+ return true;
+
+ std::pair<const_iterator, const_iterator> exterior
+ = super.equal_range(inter_val);
+ if(exterior.first == exterior.second)
+ return false;
+
+ const_iterator last_overlap = cyclic_prior(super, exterior.second);
+
+ return
+ itl::contains(hull(*(exterior.first), *last_overlap), inter_val)
+ && Interval_Set::is_joinable(super, exterior.first, last_overlap);
+}
+
+template<class Type, class OperandT>
+typename enable_if<has_same_concept<is_interval_set, Type, OperandT>,
+ bool>::type
+contains(const Type& super, const OperandT& sub)
+{
+ return Interval_Set::contains(super, sub);
+}
+
+//==============================================================================
+//= Addition<IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& add(T&, c P&) T:{S} P:{e i} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+add(Type& object, const typename Type::element_type& operand)
+{
+ return object.add(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+add(Type& object, const typename Type::segment_type& operand)
+{
+ return object.add(operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& add(T&, J, c P&) T:{S} P:{i} interval_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, typename Type::iterator>::type
+add(Type& object, typename Type::iterator prior,
+ const typename Type::segment_type& operand)
+{
+ return object.add(prior, operand);
+}
+
+//==============================================================================
+//= Insertion<IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& insert(T&, c P&) T:{S} P:{e i} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+insert(Type& object, const typename Type::element_type& operand)
+{
+ return itl::add(object, operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+insert(Type& object, const typename Type::segment_type& operand)
+{
+ return itl::add(object, operand);
+}
+
+//------------------------------------------------------------------------------
+//- T& insert(T&, J, c P&) T:{S} P:{i} with hint
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+insert(Type& object, const typename Type::iterator prior,
+ const typename Type::segment_type& operand)
+{
+ return itl::add(object, prior, operand);
+}
+
+//==============================================================================
+//= Erasure<IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& erase(T&, c P&) T:{S} P:{e i} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+erase(Type& object, const typename Type::segment_type& minuend)
+{
+ return itl::subtract(object, minuend);
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+erase(Type& object, const typename Type::element_type& minuend)
+{
+ return itl::subtract(object, minuend);
+}
+
+//==============================================================================
+//= Subtraction<IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& subtract(T&, c P&) T:{S} P:{e i} fragment_type
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+subtract(Type& object, const typename Type::element_type& operand)
+{
+ return object.subtract(operand);
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+subtract(Type& object, const typename Type::segment_type& operand)
+{
+ return object.subtract(operand);
+}
+
+//==============================================================================
+//= Intersection
+//==============================================================================
+//------------------------------------------------------------------------------
+//- void add_intersection(T&, c T&, c P&) T:{S} P:{e i} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::element_type& operand)
+{
+ typedef typename Type::const_iterator const_iterator;
+ const_iterator found = object.find(operand);
+ if(found != object.end())
+ itl::add(section, operand);
+}
+
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, void>::type
+add_intersection(Type& section, const Type& object,
+ const typename Type::segment_type& segment)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::iterator iterator;
+ typedef typename Type::interval_type interval_type;
+
+ if(itl::is_empty(segment))
+ return;
+
+ std::pair<const_iterator, const_iterator> exterior
+ = object.equal_range(segment);
+ if(exterior.first == exterior.second)
+ return;
+
+ iterator prior_ = section.end();
+ for(const_iterator it_=exterior.first; it_ != exterior.second; it_++)
+ {
+ interval_type common_interval = key_value<Type>(it_) & segment;
+ if(!itl::is_empty(common_interval))
+ prior_ = section.insert(prior_, common_interval);
+ }
+}
+
+//==============================================================================
+//= Symmetric difference<IntervalSet>
+//==============================================================================
+//------------------------------------------------------------------------------
+//- T& flip(T&, c P&) T:{S} P:{e i S'} fragment_types
+//------------------------------------------------------------------------------
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+flip(Type& object, const typename Type::element_type& operand)
+{
+ if(itl::contains(object, operand))
+ return object -= operand;
+ else
+ return object += operand;
+}
+
+template<class Type>
+typename enable_if<is_interval_set<Type>, Type>::type&
+flip(Type& object, const typename Type::segment_type& segment)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::interval_type interval_type;
+ // That which is common shall be subtracted
+ // That which is not shall be added
+ // So x has to be 'complementary added' or flipped
+ interval_type span = segment;
+ std::pair<const_iterator, const_iterator> exterior
+ = object.equal_range(span);
+
+ const_iterator fst_ = exterior.first;
+ const_iterator end_ = exterior.second;
+
+ interval_type covered, left_over;
+ const_iterator it_ = fst_;
+ while(it_ != end_)
+ {
+ covered = *it_++;
+ //[a ... : span
+ // [b ... : covered
+ //[a b) : left_over
+ left_over = right_subtract(span, covered);
+ itl::subtract(object, span & covered); //That which is common shall be subtracted
+ itl::add(object, left_over); //That which is not shall be added
+
+ //... d) : span
+ //... c) : covered
+ // [c d) : span'
+ span = left_subtract(span, covered);
+ }
+
+ //If span is not empty here, it_ is not in the set so it_ shall be added
+ itl::add(object, span);
+ return object;
+}
+
+
+template<class Type, class OperandT>
+typename enable_if<is_concept_compatible<is_interval_set, Type, OperandT>, Type>::type&
+flip(Type& object, const OperandT& operand)
+{
+ typedef typename OperandT::const_iterator const_iterator;
+
+ if(operand.empty())
+ return object;
+
+ const_iterator common_lwb, common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return object += operand;
+
+ const_iterator it_ = operand.begin();
+
+ // All elements of operand left of the common range are added
+ while(it_ != common_lwb)
+ itl::add(object, *it_++);
+ // All elements of operand in the common range are symmertrically subtracted
+ while(it_ != common_upb)
+ itl::flip(object, *it_++);
+ // All elements of operand right of the common range are added
+ while(it_ != operand.end())
+ itl::add(object, *it_++);
+
+ return object;
+}
+
+//==============================================================================
+//= Streaming
+//==============================================================================
+template<class CharType, class CharTraits, class Type>
+typename enable_if<is_interval_set<Type>,
+ std::basic_ostream<CharType, CharTraits> >::type&
+operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
+{
+ stream << "{";
+ ITL_const_FORALL(typename Type, it_, object)
+ stream << (*it_);
+
+ return stream << "}";
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/interval_set_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/interval_set_value.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,31 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_INTERVAL_SET_VALUE_HPP_JOFA_100924
+#define BOOST_ITL_CONCEPT_INTERVAL_SET_VALUE_HPP_JOFA_100924
+
+#include <boost/itl/type_traits/is_interval_container.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= AlgoUnifiers<Set>
+//==============================================================================
+template<class Type, class Iterator>
+inline typename enable_if<is_interval_set<Type>, typename Type::codomain_type>::type
+co_value(Iterator value_)
+{
+ typedef typename Type::codomain_type codomain_type;
+ return itl::is_empty(*value_)? codomain_type() : (*value_).lower();
+}
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/map_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/map_value.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,46 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_MAP_VALUE_HPP_JOFA_100924
+#define BOOST_ITL_CONCEPT_MAP_VALUE_HPP_JOFA_100924
+
+#include <boost/itl/type_traits/is_map.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= AlgoUnifiers<Map>
+//==============================================================================
+template<class Type, class Iterator>
+inline typename enable_if<is_map<Type>, const typename Type::key_type>::type&
+key_value(Iterator it_)
+{
+ return it_->first;
+}
+
+template<class Type, class Iterator>
+inline typename enable_if<is_map<Type>, const typename Type::codomain_type>::type&
+co_value(Iterator it_)
+{
+ return it_->second;
+}
+
+template<class Type>
+inline typename enable_if<is_map<Type>, typename Type::value_type>::type
+make_value(const typename Type:: key_type& key_val,
+ const typename Type::codomain_type& co_val)
+{
+ return typename Type::value_type(key_val, co_val);
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Added: sandbox/itl/boost/itl/concept/set_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/concept/set_value.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,39 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_CONCEPT_SET_VALUE_HPP_JOFA_100924
+#define BOOST_ITL_CONCEPT_SET_VALUE_HPP_JOFA_100924
+
+#include <boost/itl/type_traits/is_set.hpp>
+
+namespace boost{ namespace itl
+{
+
+//==============================================================================
+//= AlgoUnifiers<Set>
+//==============================================================================
+template<class Type, class Iterator>
+inline typename enable_if<is_set<Type>, const typename Type::key_type>::type&
+key_value(Iterator it_)
+{
+ return *it_;
+}
+
+template<class Type>
+inline typename enable_if<is_set<Type>, typename Type::value_type>::type
+make_value(const typename Type:: key_type& key_val,
+ const typename Type::codomain_type& )
+{
+ return typename Type::value_type(key_val);
+}
+
+
+}} // namespace boost itl
+
+#endif
+
+

Modified: sandbox/itl/boost/itl/continuous_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/continuous_interval.hpp (original)
+++ sandbox/itl/boost/itl/continuous_interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -14,7 +14,7 @@
 #include <boost/itl/type_traits/is_continuous_interval.hpp>
 #include <boost/itl/detail/base_interval.hpp>
 #include <boost/itl/interval_bounds.hpp>
-#include <boost/itl/interval_functions.hpp>
+#include <boost/itl/concept/interval.hpp>
 
 namespace boost{namespace itl
 {

Modified: sandbox/itl/boost/itl/detail/associated_value.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/associated_value.hpp (original)
+++ sandbox/itl/boost/itl/detail/associated_value.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -23,7 +23,7 @@
 co_equal(typename Type::const_iterator left_, typename CoType::const_iterator right_,
                  const Type* = 0, const CoType* = 0)
 {
- return Type::co_value(left_) == CoType::co_value(right_);
+ return co_value<Type>(left_) == co_value<CoType>(right_);
 }
 
 template<class Type, class CoType>

Modified: sandbox/itl/boost/itl/detail/base_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/base_interval.hpp (original)
+++ sandbox/itl/boost/itl/detail/base_interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -1,5 +1,5 @@
 /*-----------------------------------------------------------------------------+
-Copyright (c) 2007-2010: Joachim Faulhaber
+Copyright (c) 2010-2010: Joachim Faulhaber
 +------------------------------------------------------------------------------+
    Distributed under the Boost Software License, Version 1.0.
       (See accompanying file LICENCE.txt or copy at
@@ -57,18 +57,18 @@
     /// The size type of an interval which is mostly std::size_t
     typedef typename itl::size_type_of<DomainT>::type size_type;
 
- typedef typename boost::call_traits<DomainT>::param_type DomainP;
+ typedef typename boost::call_traits<DomainT>::param_type domain_param;
 
     /** Less compare of interval elements. */
- inline static bool domain_less(DomainP left, DomainP right)
+ inline static bool domain_less(domain_param left, domain_param right)
     { return domain_compare()(left, right) ;}
 
     /** Less or equal compare of interval elements. */
- inline static bool domain_less_equal(DomainP left, DomainP right)
+ inline static bool domain_less_equal(domain_param left, domain_param right)
     { return !domain_compare()(right, left );}
 
     /** Equality compare of interval elements. */
- inline static bool domain_equal(DomainP left, DomainP right)
+ inline static bool domain_equal(domain_param left, domain_param right)
     { return !domain_compare()(left, right) && !domain_compare()(right, left);}
 };
 

Modified: sandbox/itl/boost/itl/detail/design_config.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/design_config.hpp (original)
+++ sandbox/itl/boost/itl/detail/design_config.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -141,9 +141,6 @@
 
 
 //------------------------------------------------------------------------------
-//CL #define ITL_INTERVAL_DEFAULT itl::rightopen_interval
-//CL #define ITL_INTERVAL_DEFAULT itl::continuous_interval
-
 #ifdef ITL_NEW_INTERVAL_IMPL
 # define ITL_INTERVAL_DEFAULT boost::itl::interval_type_default
 #else

Modified: sandbox/itl/boost/itl/detail/element_comparer.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/element_comparer.hpp (original)
+++ sandbox/itl/boost/itl/detail/element_comparer.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -51,22 +51,22 @@
 
     bool covalues_are_equal(LeftIterT& left, RightIterT& right)
     {
- if(LeftT::co_value(left) < RightT::co_value(right))
+ if(co_value<LeftT>(left) < co_value<RightT>(right))
             _result = less;
- if(RightT::co_value(right) < LeftT::co_value(left))
+ if(co_value<RightT>(right) < co_value<LeftT>(left))
             _result = greater;
         return _result == equal;
     }
 
     int proceed(LeftIterT& left, RightIterT& right)
     {
- if(upper_less(LeftT::key_value(left), RightT::key_value(right)))
+ if(upper_less(key_value<LeftT>(left), key_value<RightT>(right)))
         {
             _prior_left = left;
             ++left;
             return nextleft;
         }
- else if(upper_less(RightT::key_value(right), LeftT::key_value(left)))
+ else if(upper_less(key_value<RightT>(right), key_value<LeftT>(left)))
         {
             _prior_right = right;
             ++right;
@@ -96,14 +96,14 @@
         }
 
         // The starting intervals have to begin equally
- if(lower_less(LeftT::key_value(left), RightT::key_value(right)))
+ if(lower_less(key_value<LeftT>(left), key_value<RightT>(right)))
         { // left: same A... = sameA...
             // right:same B.. = sameB...
             _result = less;
             return stop;
         }
 
- if(lower_less(LeftT::key_value(right), RightT::key_value(left)))
+ if(lower_less(key_value<LeftT>(right), key_value<RightT>(left)))
         { // left: same B.. = sameB...
             // right:same A... = sameA...
             _result = greater;
@@ -125,7 +125,7 @@
             return stop;
         }
 
- if(!LeftT::key_value(_prior_left).touches(LeftT::key_value(left)))
+ if(!key_value<LeftT>(_prior_left).touches(key_value<LeftT>(left)))
         { // left: same B = sameB...
             // right:sameA = sameA...
             _result = greater;
@@ -147,7 +147,7 @@
             return stop;
         }
 
- if(!RightT::key_value(_prior_right).touches(RightT::key_value(right)))
+ if(!key_value<RightT>(_prior_right).touches(key_value<RightT>(right)))
         {
             // left: sameA... = sameA...
             // right:same B.. = sameB...

Modified: sandbox/itl/boost/itl/detail/interval_map_algo.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/interval_map_algo.hpp (original)
+++ sandbox/itl/boost/itl/detail/interval_map_algo.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -43,13 +43,13 @@
     ++next_;
 
     const typename IntervalMapT::codomain_type& co_value
- = IntervalMapT::co_value(first);
+ = itl::co_value<IntervalMapT>(first);
     while(it_ != past)
     {
- if(IntervalMapT::co_value(next_) != co_value)
+ if(itl::co_value<IntervalMapT>(next_) != co_value)
             return false;
- if(!itl::touches(IntervalMapT::key_value(it_++),
- IntervalMapT::key_value(next_++)))
+ if(!itl::touches(key_value<IntervalMapT>(it_++),
+ key_value<IntervalMapT>(next_++)))
             return false;
     }
 

Modified: sandbox/itl/boost/itl/detail/interval_morphism.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/interval_morphism.hpp (original)
+++ sandbox/itl/boost/itl/detail/interval_morphism.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -9,6 +9,11 @@
 #define BOOST_ITL_DETAIL_INTERVAL_MORPHISM_HPP_JOFA_080315
 
 #include <boost/itl/detail/notate.hpp>
+#include <boost/itl/concept/interval_set_value.hpp>
+#include <boost/itl/concept/element_set_value.hpp>
+#include <boost/itl/concept/set_value.hpp>
+#include <boost/itl/concept/map_value.hpp>
+
 namespace boost{namespace itl
 {
     namespace segmental
@@ -18,14 +23,11 @@
         {
             ITL_const_FORALL(typename IntervalContainerT, itv_, src)
             {
- const typename IntervalContainerT::key_type& itv = IntervalContainerT::key_value(itv_);
- typename IntervalContainerT::codomain_type coval = IntervalContainerT::co_value(itv_);
+ const typename IntervalContainerT::key_type& itv = itl::key_value<IntervalContainerT>(itv_);
+ typename IntervalContainerT::codomain_type coval = itl::co_value<IntervalContainerT>(itv_);
 
                 for(typename IntervalContainerT::domain_type element = first(itv); element <= last(itv); ++element)
- {
- insert(result, ElementContainerT::make_value(element, coval));
- //CL result.insert(ElementContainerT::make_element(element, coval));
- }
+ insert(result, itl::make_value<ElementContainerT>(element, coval));
             }
         }
 
@@ -35,10 +37,10 @@
                         typedef typename IntervalContainerT::key_type key_type;
             ITL_const_FORALL(typename ElementContainerT, element_, src)
             {
- const typename ElementContainerT::key_type& key = ElementContainerT::key_value(element_);
- const typename ElementContainerT::data_type& data = ElementContainerT::co_value(element_);
+ const typename ElementContainerT::key_type& key = key_value<ElementContainerT>(element_);
+ const typename ElementContainerT::data_type& data = co_value<ElementContainerT>(element_);
 
- result += IntervalContainerT::make_value(key_type(key), data);
+ result += itl::make_value<IntervalContainerT>(key_type(key), data);
             }
         }
 

Modified: sandbox/itl/boost/itl/detail/interval_set_algo.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/interval_set_algo.hpp (original)
+++ sandbox/itl/boost/itl/detail/interval_set_algo.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -14,6 +14,8 @@
 #include <boost/itl/type_traits/is_map.hpp>
 #include <boost/itl/type_traits/is_total.hpp>
 #include <boost/itl/type_traits/is_combinable.hpp>
+#include <boost/itl/concept/set_value.hpp>
+#include <boost/itl/concept/map_value.hpp>
 #include <boost/itl/interval.hpp>
 #include <boost/itl/interval_combining_style.hpp>
 #include <boost/itl/detail/element_comparer.hpp>
@@ -33,8 +35,7 @@
     size_type interval_size;
     ITL_const_FORALL(typename IntervalContainerT, it, object)
     {
- //CL interval_size = continuous_interval_<interval_type>::cardinality(IntervalContainerT::key_value(it));
- interval_size = itl::cardinality(IntervalContainerT::key_value(it));
+ interval_size = itl::cardinality(key_value<IntervalContainerT>(it));
         if(interval_size == infinity<size_type>::value())
             return interval_size;
         else
@@ -51,7 +52,7 @@
 
     size_type size = neutron<size_type>::value();
     ITL_const_FORALL(typename IntervalContainerT, it, object)
- size += discrete_interval_<interval_type>::cardinality(IntervalContainerT::key_value(it));
+ size += discrete_interval_<interval_type>::cardinality(key_value<IntervalContainerT>(it));
     return size;
 }
 
@@ -128,8 +129,8 @@
     ++next_;
 
     while(next_ != container.end() && it_ != past)
- if(!itl::touches(IntervalContainerT::key_value(it_++),
- IntervalContainerT::key_value(next_++)))
+ if(!itl::touches(key_value<IntervalContainerT>(it_++),
+ key_value<IntervalContainerT>(next_++)))
             return false;
 
     return true;
@@ -245,28 +246,6 @@
     return result == inclusion::superset || result == inclusion::equal;
 }
 
-/*CL
-//JODO check if this is still needed
-template<class IntervalContainerT>
-bool contains(const IntervalContainerT& container,
- const typename IntervalContainerT::segment_type& sub_interval)
-{
- typedef typename IntervalContainerT::const_iterator const_iterator;
- if(itl::is_empty(sub_interval))
- return true;
-
- std::pair<const_iterator, const_iterator> exterior = container.equal_range(sub_interval);
- if(exterior.first == exterior.second)
- return false;
-
- const_iterator last_overlap = prior(exterior.second);
-
- return
- itl::contains(hull(*(exterior.first), *last_overlap), sub_interval)
- && Interval_Set::is_joinable(container, exterior.first, last_overlap);
-}
-*/
-
 template<class IntervalContainerT>
 bool is_dense(const IntervalContainerT& container,
               typename IntervalContainerT::const_iterator first,
@@ -279,8 +258,8 @@
     ++next_;
 
     while(next_ != container.end() && it_ != past)
- if(!itl::touches(IntervalContainerT::key_value(it_++),
- IntervalContainerT::key_value(next_++)))
+ if(!itl::touches(key_value<IntervalContainerT>(it_++),
+ key_value<IntervalContainerT>(next_++)))
             return false;
 
     return true;
@@ -295,7 +274,7 @@
 inline bool joinable(const Type& _Type, typename Type::iterator& some, typename Type::iterator& next)
 {
     // assert: next != end && some++ == next
- return touches(Type::key_value(some), Type::key_value(next))
+ return touches(key_value<Type>(some), key_value<Type>(next))
         && co_equal(some, next, &_Type, &_Type);
 }
 
@@ -304,10 +283,10 @@
                                      typename Type::iterator& right_)
 {
     typedef typename Type::interval_type interval_type;
- interval_type right_interval = Type::key_value(right_);
+ interval_type right_interval = key_value<Type>(right_);
         ((typename Type::base_type&)object).erase(right_); //JODO
- const_cast<interval_type&>(Type::key_value(left_))
- = hull(Type::key_value(left_), right_interval);
+ const_cast<interval_type&>(key_value<Type>(left_))
+ = hull(key_value<Type>(left_), right_interval);
 }
 
 template<class Type>
@@ -317,7 +296,7 @@
 {
     typedef typename Type::interval_type interval_type;
     // both left and right are in the set and they are neighbours
- BOOST_ASSERT(exclusive_less(Type::key_value(left_), Type::key_value(right_)));
+ BOOST_ASSERT(exclusive_less(key_value<Type>(left_), key_value<Type>(right_)));
     BOOST_ASSERT(joinable(object, left_, right_));
 
     join_nodes(object, left_, right_);
@@ -331,7 +310,7 @@
 {
     typedef typename Type::interval_type interval_type;
     // both left and right are in the map and they are neighbours
- BOOST_ASSERT(exclusive_less(Type::key_value(left_), Type::key_value(right_)));
+ BOOST_ASSERT(exclusive_less(key_value<Type>(left_), key_value<Type>(right_)));
     BOOST_ASSERT(joinable(object, left_, right_));
 
     join_nodes(object, left_, right_);
@@ -395,12 +374,12 @@
 
     iterator second_= first_; ++second_;
 
- interval_type left_resid = right_subtract(Type::key_value(first_), addend);
- interval_type right_resid = left_subtract(Type::key_value(last_) , addend);
+ interval_type left_resid = right_subtract(key_value<Type>(first_), addend);
+ interval_type right_resid = left_subtract(key_value<Type>(last_) , addend);
 
     object.erase(second_, end_);
 
- const_cast<value_type&>(Type::key_value(first_))
+ const_cast<value_type&>(key_value<Type>(first_))
         = hull(hull(left_resid, addend), right_resid);
     return first_;
 }
@@ -419,12 +398,12 @@
     //BOOST_ASSERT(next(last_) == this->_set.upper_bound(inter_val));
     iterator second_= next(first_), end_ = next(last_);
 
- interval_type left_resid = right_subtract(Type::key_value(first_), addend);
- interval_type right_resid = left_subtract(Type::key_value(last_) , addend);
+ interval_type left_resid = right_subtract(key_value<Type>(first_), addend);
+ interval_type right_resid = left_subtract(key_value<Type>(last_) , addend);
 
     object.erase(second_, end_);
 
- const_cast<value_type&>(Type::key_value(first_))
+ const_cast<value_type&>(key_value<Type>(first_))
         = hull(hull(left_resid, addend), right_resid);
     return first_;
 }
@@ -542,17 +521,16 @@
     // The addend interval 'inter_val' covers the beginning of the collision sequence.
 
     // only for the first there can be a left_resid: a part of *first_ left of inter_val
- interval_type left_resid = right_subtract(Type::key_value(first_), inter_val);
+ interval_type left_resid = right_subtract(key_value<Type>(first_), inter_val);
 
     if(!itl::is_empty(left_resid))
     { // [------------ . . .
         // [left_resid---first_ --- . . .
         iterator prior_ = cyclic_prior(object, first_);
- const_cast<interval_type&>(Type::key_value(first_))
- = left_subtract(Type::key_value(first_), left_resid);
+ const_cast<interval_type&>(key_value<Type>(first_))
+ = left_subtract(key_value<Type>(first_), left_resid);
         //NOTE: Only splitting
- //CL iterator insertion_ =
- object._insert(prior_, Type::make_value(left_resid, Type::co_value(first_)));
+ object._insert(prior_, itl::make_value<Type>(left_resid, co_value<Type>(first_)));
     }
 
     //POST:

Modified: sandbox/itl/boost/itl/detail/interval_subset_comparer.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/interval_subset_comparer.hpp (original)
+++ sandbox/itl/boost/itl/detail/interval_subset_comparer.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -16,6 +16,7 @@
 #include <boost/itl/type_traits/is_interval_container.hpp>
 #include <boost/itl/type_traits/is_set.hpp>
 #include <boost/itl/interval.hpp>
+#include <boost/itl/concept/interval_set_value.hpp>
 
 namespace boost{namespace itl
 {
@@ -34,8 +35,8 @@
 {
     static int apply(typename LeftT::const_iterator& left_, typename RightT::const_iterator& right_)
     {
- return inclusion_compare( LeftT::co_value(left_),
- RightT::co_value(right_));
+ return inclusion_compare( itl::co_value<LeftT>(left_),
+ itl::co_value<RightT>(right_));
     }
 };
 
@@ -44,7 +45,7 @@
 {
     static int apply(typename LeftT::const_iterator& left_, typename RightT::const_iterator& right_)
     {
- if(LeftT::co_value(left_) == RightT::co_value(right_))
+ if(itl::co_value<LeftT>(left_) == itl::co_value<RightT>(right_))
             return inclusion::equal;
         else
             return inclusion::unrelated;
@@ -133,21 +134,21 @@
 
     int proceed(LeftIterT& left, RightIterT& right)
     {
- if(upper_less(LeftT::key_value(left), RightT::key_value(right)))
+ if(upper_less(key_value<LeftT>(left), key_value<RightT>(right)))
         { // left ..)
             // right .....)
             _prior_left = left;
             ++left;
             return nextleft;
         }
- else if(upper_less(RightT::key_value(right), LeftT::key_value(left)))
+ else if(upper_less(key_value<RightT>(right), key_value<LeftT>(left)))
         { // left .....)
             // right ..)
             _prior_right = right;
             ++right;
             return nextright;
         }
- else//LeftT::key_value(left).upper_equal(RightT::key_value(right))
+ else//key_value<LeftT>(left).upper_equal(key_value<RightT>(right))
         { // left ..)
             // right ..)
             ++left;
@@ -172,7 +173,7 @@
             restrict_result(superset);
             return stop;
         }
- else if(exclusive_less(LeftT::key_value(left), RightT::key_value(right)))
+ else if(exclusive_less(key_value<LeftT>(left), key_value<RightT>(right)))
         { // left: [..) . . .[---) left could be superset
             // right: [..).... if [---) exists
             restrict_result(superset);
@@ -180,7 +181,7 @@
                 return stop;
             else
             {
- LeftIterT joint_ = _left.lower_bound(RightT::key_value(right));
+ LeftIterT joint_ = _left.lower_bound(key_value<RightT>(right));
                 if(joint_ == _left.end())
                 {
                     _result = unrelated;
@@ -193,7 +194,7 @@
                 }
             }
         }
- else if(exclusive_less(RightT::key_value(right), LeftT::key_value(left)))
+ else if(exclusive_less(key_value<RightT>(right), key_value<LeftT>(left)))
         { // left: [.. left could be subset
             // right:....) . . .[---) if [---) exists
             restrict_result(subset);
@@ -201,7 +202,7 @@
                 return stop;
             else
             {
- RightIterT joint_ = _right.lower_bound(LeftT::key_value(left));
+ RightIterT joint_ = _right.lower_bound(key_value<LeftT>(left));
                 if(joint_ == _right.end())
                 {
                     _result = unrelated;
@@ -221,19 +222,19 @@
                 return stop;
 
         // examine left borders only. Right borders are checked in proceed
- if(lower_less(LeftT::key_value(left), RightT::key_value(right)))
+ if(lower_less(key_value<LeftT>(left), key_value<RightT>(right)))
         { // left: ....[... left could be superset
             // right:.... [..
             if(unrelated == restrict_result(superset))
                 return stop;
         }
- else if(lower_less(RightT::key_value(right), LeftT::key_value(left)))
+ else if(lower_less(key_value<RightT>(right), key_value<LeftT>(left)))
         { // left: .... [.. left can be subset
             // right:....[...
             if(unrelated == restrict_result(subset))
                 return stop;
         }
- //else LeftT::key_value(right).lower_equal(RightT::key_value(left))
+ //else key_value<LeftT>(right).lower_equal(key_value<RightT>(left))
             // left: ....[.. both can be equal
             // right:....[..
             // nothing to do: proceed
@@ -249,10 +250,10 @@
             restrict_result(subset);
             return stop;
         }
- else if(!touches(LeftT::key_value(_prior_left), LeftT::key_value(left)))
+ else if(!touches(key_value<LeftT>(_prior_left), key_value<LeftT>(left)))
         { // left: ..) [..
             // right:.........)
- if(lower_less(RightT::key_value(right), LeftT::key_value(left)))
+ if(lower_less(key_value<RightT>(right), key_value<LeftT>(left)))
             { // ..) [.. left could be subset
                 // ..........)
                 if(unrelated == restrict_result(subset))
@@ -260,14 +261,14 @@
             }
             //else ..) [...
             // [..
- if(_compare_codomain && intersects(LeftT::key_value(left),RightT::key_value(right)) )
+ if(_compare_codomain && intersects(key_value<LeftT>(left),key_value<RightT>(right)) )
                 if(unrelated == restrict_result(co_compare(left,right)))
                     return stop;
         }
         else
         { // left: ..)[.. left could be subset
             // right:.......)
- if(_compare_codomain && intersects(LeftT::key_value(left), RightT::key_value(right)) )
+ if(_compare_codomain && intersects(key_value<LeftT>(left), key_value<RightT>(right)) )
                 if(unrelated == restrict_result(co_compare(left,right)))
                     return stop;
         }
@@ -284,10 +285,10 @@
             restrict_result(superset);
             return stop;
         }
- else if(!touches(RightT::key_value(_prior_right), RightT::key_value(right)))
+ else if(!touches(key_value<RightT>(_prior_right), key_value<RightT>(right)))
         { // left: .........)
             // right:..) [..
- if(lower_less(LeftT::key_value(left), RightT::key_value(right)))
+ if(lower_less(key_value<LeftT>(left), key_value<RightT>(right)))
             { // [....) left could be superset
                 // ..) [..
                 if(unrelated == restrict_result(superset))
@@ -295,13 +296,13 @@
             }
             //else [....)
             // ..) [..
- if(_compare_codomain && intersects(LeftT::key_value(left), RightT::key_value(right)) )
+ if(_compare_codomain && intersects(key_value<LeftT>(left), key_value<RightT>(right)) )
                 if(unrelated == restrict_result(co_compare(left,right)))
                     return stop;
         }
         else
         {
- if(_compare_codomain && intersects(LeftT::key_value(left), RightT::key_value(right)) )
+ if(_compare_codomain && intersects(key_value<LeftT>(left), key_value<RightT>(right)) )
                 if(unrelated == restrict_result(co_compare(left,right)))
                     return stop;
         }

Modified: sandbox/itl/boost/itl/detail/map_algo.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/map_algo.hpp (original)
+++ sandbox/itl/boost/itl/detail/map_algo.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -34,7 +34,7 @@
 
     co_iterator right_ = right_common_lower_;
     while(right_ != right_common_upper_)
- if(itl::intersects(left, CoObjectT::key_value(right_++)))
+ if(itl::intersects(left, key_value<CoObjectT>(right_++)))
             return true;
 
     return false;

Modified: sandbox/itl/boost/itl/detail/set_algo.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/set_algo.hpp (original)
+++ sandbox/itl/boost/itl/detail/set_algo.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -10,16 +10,16 @@
 #ifndef BOOST_ITL_SET_ALGO_HPP_JOFA_990225
 #define BOOST_ITL_SET_ALGO_HPP_JOFA_990225
 
+#include <boost/type_traits/remove_const.hpp>
+
 #include <boost/itl/detail/notate.hpp>
 #include <boost/itl/predicates.hpp>
 #include <boost/itl/functors.hpp>
-//CL #include <boost/itl/seqs.hpp>
 
-/*
-<b>SetAlgo </b>
-SetAlgo is a collection of algorithms that work with sets but may also
-used with other set-implementations like e.g. hash_set.
-*/
+#include <boost/itl/concept/container.hpp>
+#include <boost/itl/concept/set_value.hpp>
+#include <boost/itl/concept/map_value.hpp>
+
 
 namespace boost{namespace itl
 {
@@ -30,15 +30,16 @@
 template<class ObjectT, class ConstObjectT, class IteratorT>
 bool common_range(IteratorT& lwb, IteratorT& upb, ObjectT& x1, const ConstObjectT& x2)
 {
- // lwb and upb are iterator of x1 marking the lower and upper bound of
+ // lwb and upb are iterators of x1 marking the lower and upper bound of
     // the common range of x1 and x2.
     typedef typename ConstObjectT::const_iterator ConstObject_iterator;
+ // ObjectT may be const or non const.
+ typedef typename remove_const<ObjectT>::type PureObjectT;
 
     lwb = x1.end();
     upb = x1.end();
 
- //JODO gcc.3.4.4 :( if(itl::is_empty(x1) || itl::is_empty(x2))
- if(x1.empty() || x2.empty())
+ if(itl::is_empty(x1) || itl::is_empty(x2))
         return false;
 
     IteratorT x1_fst_ = x1.begin();
@@ -48,15 +49,16 @@
     ConstObject_iterator x2_lst_ = x2.end(); x2_lst_--;
 
     typename ObjectT::key_compare key_less;
-
- if(key_less(ObjectT::key_value(x1_lst_), ConstObjectT::key_value(x2_fst_))) // {x1} {x2}
+ if(key_less(itl::key_value< PureObjectT>(x1_lst_),
+ itl::key_value<ConstObjectT>(x2_fst_))) // {x1} {x2}
         return false;
- if(key_less(ConstObjectT::key_value(x2_lst_), ObjectT::key_value(x1_fst_))) // {x2} {x1}
+ if(key_less(itl::key_value<ConstObjectT>(x2_lst_),
+ itl::key_value< PureObjectT>(x1_fst_))) // {x2} {x1}
         return false;
 
     // We do have a common range
- lwb = x1.lower_bound(ConstObjectT::key_value(x2_fst_));
- upb = x1.upper_bound(ConstObjectT::key_value(x2_lst_));
+ lwb = x1.lower_bound(itl::key_value<ConstObjectT>(x2_fst_));
+ upb = x1.upper_bound(itl::key_value<ConstObjectT>(x2_lst_));
 
     return true;
 }

Modified: sandbox/itl/boost/itl/detail/subset_comparer.hpp
==============================================================================
--- sandbox/itl/boost/itl/detail/subset_comparer.hpp (original)
+++ sandbox/itl/boost/itl/detail/subset_comparer.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -16,6 +16,8 @@
 #include <boost/itl/type_traits/is_concept_equivalent.hpp>
 #include <boost/itl/type_traits/is_element_container.hpp>
 #include <boost/itl/interval.hpp>
+#include <boost/itl/concept/interval_set_value.hpp>
+#include <boost/itl/concept/map_value.hpp>
 
 namespace boost{namespace itl
 {
@@ -34,8 +36,8 @@
 {
     static int apply(typename LeftT::const_iterator& left_, typename RightT::const_iterator& right_)
     {
- return inclusion_compare( LeftT::co_value(left_),
- RightT::co_value(right_));
+ return inclusion_compare( co_value<LeftT>(left_),
+ co_value<RightT>(right_));
     }
 };
 
@@ -44,7 +46,7 @@
 {
     static int apply(typename LeftT::const_iterator& left_, typename RightT::const_iterator& right_)
     {
- if(LeftT::co_value(left_) == RightT::co_value(right_))
+ if(co_value<LeftT>(left_) == co_value<RightT>(right_))
             return inclusion::equal;
         else
             return inclusion::unrelated;
@@ -145,7 +147,7 @@
             restrict_result(superset);
             return stop;
         }
- else if(typename LeftT::domain_compare()(LeftT::key_value(left), RightT::key_value(right)))
+ else if(typename LeftT::domain_compare()(key_value<LeftT>(left), key_value<RightT>(right)))
         { // left: *left . . *joint_ left could be superset
             // right: *right ... if joint_ exists
             restrict_result(superset);
@@ -153,9 +155,9 @@
                 return stop;
             else
             {
- LeftIterT joint_ = _left.lower_bound(RightT::key_value(right));
+ LeftIterT joint_ = _left.lower_bound(key_value<RightT>(right));
                 if( joint_ == _left.end()
- || typename LeftT::domain_compare()(RightT::key_value(right), LeftT::key_value(joint_)))
+ || typename LeftT::domain_compare()(key_value<RightT>(right), key_value<LeftT>(joint_)))
                 {
                     _result = unrelated;
                     return stop;
@@ -164,7 +166,7 @@
                     left = joint_;
             }
         }
- else if(typename LeftT::domain_compare()(RightT::key_value(right), LeftT::key_value(left)))
+ else if(typename LeftT::domain_compare()(key_value<RightT>(right), key_value<LeftT>(left)))
         { // left: *left left could be subset
             // right:*right . . .*joint_ if *joint_ exists
             restrict_result(subset);
@@ -172,9 +174,9 @@
                 return stop;
             else
             {
- RightIterT joint_ = _right.lower_bound(LeftT::key_value(left));
+ RightIterT joint_ = _right.lower_bound(key_value<LeftT>(left));
                 if( joint_ == _right.end()
- || typename LeftT::domain_compare()(LeftT::key_value(left), RightT::key_value(joint_)))
+ || typename LeftT::domain_compare()(key_value<LeftT>(left), key_value<RightT>(joint_)))
                 {
                     _result = unrelated;
                     return stop;

Modified: sandbox/itl/boost/itl/discrete_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/discrete_interval.hpp (original)
+++ sandbox/itl/boost/itl/discrete_interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -16,7 +16,7 @@
 #include <boost/itl/type_traits/is_discrete_interval.hpp>
 #include <boost/itl/detail/base_interval.hpp>
 #include <boost/itl/interval_bounds.hpp>
-#include <boost/itl/interval_functions.hpp>
+#include <boost/itl/concept/interval.hpp>
 
 namespace boost{namespace itl
 {

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -34,7 +34,7 @@
 #include <boost/itl/type_traits/to_string.hpp>
 #include <boost/itl/type_traits/is_universal_interval.hpp>
 #include <boost/itl/interval_bounds.hpp>
-#include <boost/itl/interval_functions.hpp>
+#include <boost/itl/concept/interval.hpp>
 
 //JODO For the migration from old to new itl::intervals activate this code:
 //

Modified: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -23,8 +23,6 @@
 #include <boost/itl/interval_base_set.hpp>
 #include <boost/itl/detail/interval_map_algo.hpp>
 
-#include <boost/mpl/bool.hpp> //CL
-
 
 #define const_FOR_IMPLMAP(iter) for(typename ImplMapT::const_iterator iter=_map.begin(); (iter)!=_map.end(); (iter)++)
 #define FOR_IMPLMAP(iter) for(typename ImplMapT::iterator iter=_map.begin(); (iter)!=_map.end(); (iter)++)
@@ -97,6 +95,7 @@
     //--------------------------------------------------------------------------
     /// Domain type (type of the keys) of the map
     typedef DomainT domain_type;
+ typedef typename boost::call_traits<DomainT>::param_type domain_param;
     /// Domain type (type of the keys) of the map
     typedef CodomainT codomain_type;
     /// Auxiliary type to help the compiler resolve ambiguities when using std::make_pair
@@ -129,7 +128,6 @@
     /// Inverse Combine functor for codomain value aggregation
     typedef typename inverse<codomain_combine>::type inverse_codomain_combine;
     /// Intersection functor for codomain values
- //CL typedef ITL_SECTION_CODOMAIN(Section,CodomainT) codomain_intersect;
 
     typedef typename mpl::if_
     <has_set_semantics<codomain_type>
@@ -331,13 +329,12 @@
     /** Addition of a key value pair to the map */
     SubType& add(const element_type& key_value_pair)
     {
- return add(make_segment(key_value_pair));
+ return add(make_segment<type>(key_value_pair));
     }
 
     /** Addition of an interval value pair to the map. */
     SubType& add(const segment_type& interval_value_pair)
     {
- //CL return itl::add(*that(), interval_value_pair);
         this->template _add<codomain_combine>(interval_value_pair);
         return *that();
     }
@@ -347,7 +344,6 @@
         inserted after. */
     iterator add(iterator prior_, const segment_type& interval_value_pair)
     {
- //CL return itl::add(*that(), prior_, interval_value_pair);
         return this->template _add<codomain_combine>(prior_, interval_value_pair);
     }
 
@@ -358,7 +354,7 @@
     /** Subtraction of a key value pair from the map */
     SubType& subtract(const element_type& key_value_pair)
     {
- return subtract(make_segment(key_value_pair));
+ return subtract(make_segment<type>(key_value_pair));
     }
 
     /** Subtraction of an interval value pair from the map. */
@@ -373,13 +369,13 @@
     //= Insertion
     //==========================================================================
 
- std::pair<iterator,bool> _insert(const value_type& value_pair){ return _map.insert(value_pair); } //CL
- iterator _insert(iterator prior, const value_type& value_pair){ return _map.insert(prior, value_pair); } //CL
+ //std::pair<iterator,bool> _insert(const value_type& value_pair){ return _map.insert(value_pair); } //CL
+ //iterator _insert(iterator prior, const value_type& value_pair){ return _map.insert(prior, value_pair); } //CL
 
     /** Insertion of a \c key_value_pair into the map. */
     SubType& insert(const element_type& key_value_pair)
     {
- return insert(make_segment(key_value_pair));
+ return insert(make_segment<type>(key_value_pair));
     }
 
     /** Insertion of an \c interval_value_pair into the map. */
@@ -417,7 +413,7 @@
     /** Erase a \c key_value_pair from the map. */
     SubType& erase(const element_type& key_value_pair)
     {
- erase(make_segment(key_value_pair));
+ erase(make_segment<type>(key_value_pair));
         return *that();
     }
 
@@ -449,7 +445,7 @@
     /** The intersection of \c key_value_pair and \c *this map is added to \c section. */
     void add_intersection(SubType& section, const element_type& key_value_pair)const
     {
- add_intersection(section, make_segment(key_value_pair));
+ add_intersection(section, make_segment<type>(key_value_pair));
     }
 
     /** The intersection of \c interval_value_pair and \c *this map is added to \c section. */
@@ -494,7 +490,7 @@
     /** If \c *this map contains \c key_value_pair it is erased, otherwise it is added. */
     SubType& flip(const element_type& key_value_pair)
     {
- return flip(make_segment(key_value_pair));
+ return flip(make_segment<type>(key_value_pair));
     }
 
     /** If \c *this map contains \c interval_value_pair it is erased, otherwise it is added. */
@@ -536,26 +532,6 @@
     const_reverse_iterator rbegin()const { return _map.rbegin(); }
     const_reverse_iterator rend()const { return _map.rend(); }
 
- //==========================================================================
- //= Algorithm unifiers
- //==========================================================================
-
- template<typename IteratorT>
- static const key_type& key_value(IteratorT value_){ return (*value_).first; }
-
- template<typename IteratorT>
- static codomain_type co_value(IteratorT value_){ return (*value_).second; }
-
- template<typename LeftIterT, typename RightIterT>
- static bool key_less(LeftIterT left_, RightIterT right_)
- { return key_compare()((*left_).first, (*right_).first); }
-
- static value_type make_value(const key_type& key_value, const codomain_type& codom_val)
- { return value_type(key_value, codom_val); }
-
- static segment_type make_segment(const element_type& element)
- { return segment_type(interval_type(element.key), element.data); }
-
 private:
     template<class Combiner>
     iterator _add(const segment_type& interval_value_pair);
@@ -626,7 +602,7 @@
 
     void partial_add_intersection(SubType& section, const element_type& operand)const
     {
- partial_add_intersection(section, make_segment(operand));
+ partial_add_intersection(section, make_segment<type>(operand));
     }
 
 
@@ -898,16 +874,16 @@
     // The addend interval 'inter_val' covers the beginning of the collision sequence.
 
     // only for the first there can be a left_resid: a part of *first_ left of inter_val
- interval_type left_resid = right_subtract(key_value(first_), inter_val);
+ interval_type left_resid = right_subtract(first_->first, inter_val);
 
     if(!itl::is_empty(left_resid))
     { // [------------ . . .
         // [left_resid---first_ --- . . .
         iterator prior_ = cyclic_prior(*this, first_);
- const_cast<interval_type&>(key_value(first_))
- = left_subtract(key_value(first_), left_resid);
+ const_cast<interval_type&>(first_->first)
+ = left_subtract(first_->first, left_resid);
         //NOTE: Only splitting
- this->_map.insert(prior_, make_value(left_resid, co_value(first_)));
+ this->_map.insert(prior_, segment_type(left_resid, first_->second));
     }
     //POST:
     // [----- inter_val ---- . . .

Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -149,6 +149,7 @@
     //--------------------------------------------------------------------------
     /// The domain type of the set
     typedef DomainT domain_type;
+ typedef typename boost::call_traits<DomainT>::param_type domain_param;
     /// The codomaintype is the same as domain_type
     typedef DomainT codomain_type;
 
@@ -371,13 +372,8 @@
     SubType& subtract(const segment_type& inter_val);
 
     //==========================================================================
- //= Insertion, erasure
+ //= Insertion
     //==========================================================================
-
- //CL std::pair<iterator,bool> _insert(const value_type& value){ return this->_set.insert(value); } //CL
- //CL iterator _insert(iterator prior, const value_type& value){ return this->_set.insert(prior, value); } //CL
-
-
     /** Insert an element \c key into the set */
     SubType& insert(const element_type& key)
     {
@@ -400,6 +396,9 @@
 
 
 
+ //==========================================================================
+ //= Erasure
+ //==========================================================================
     /** Erase an element \c key from the set */
     SubType& erase(const element_type& key)
     {
@@ -529,24 +528,6 @@
     std::pair<const_iterator,const_iterator> equal_range(const key_type& interval)const
     { return _set.equal_range(interval); }
 
- //==========================================================================
- //= Algorithm unifiers
- //==========================================================================
-
- template<typename IteratorT>
- static const key_type& key_value(IteratorT value_){ return (*value_); }
-
- template<typename IteratorT>
- static codomain_type co_value(IteratorT value_)
- { return itl::is_empty(*value_)? codomain_type() : (*value_).lower(); }
-
- template<typename LeftIterT, typename RightIterT>
- static bool key_less(LeftIterT lhs_, RightIterT rhs_)
- { return key_compare()(*lhs_, *rhs_); }
-
- static value_type make_value(const key_type& key_value, const codomain_type&)
- { return value_type(key_value); }
-
 private:
     iterator _add(const segment_type& addend);
     iterator _add(iterator prior, const segment_type& addend);

Deleted: sandbox/itl/boost/itl/interval_functions.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_functions.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
+++ (empty file)
@@ -1,836 +0,0 @@
-/*-----------------------------------------------------------------------------+
-Copyright (c) 2007-2010: Joachim Faulhaber
-+------------------------------------------------------------------------------+
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENCE.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-+-----------------------------------------------------------------------------*/
-#ifndef BOOST_ITL_INTERVAL_FUNCTIONS_HPP_JOFA_100323
-#define BOOST_ITL_INTERVAL_FUNCTIONS_HPP_JOFA_100323
-
-#include <boost/utility/enable_if.hpp>
-#include <boost/mpl/and.hpp>
-#include <boost/itl/detail/design_config.hpp>
-#include <boost/itl/type_traits/is_discrete.hpp>
-#include <boost/itl/type_traits/is_asymmetric_interval.hpp>
-#include <boost/itl/type_traits/is_universal_interval.hpp>
-#include <boost/itl/type_traits/is_discrete_interval.hpp>
-#include <boost/itl/type_traits/is_continuous_interval.hpp>
-#include <boost/itl/type_traits/has_dynamic_bounds.hpp>
-
-
-namespace boost{namespace itl
-{
-
-typedef unsigned char bound_type; //JODO encapsulation in a small class
-
-//==============================================================================
-//= Construct
-//==============================================================================
-
-class interval_bounds; //JODO separate dynamically and statically bounded interval concepts
-template<class DomainT> class bounded_value;
-
-//------------------------------------------------------------------------------
-//- Adapter classes
-//------------------------------------------------------------------------------
-template<class IntervalT>
-struct intervals
-{
- typedef typename IntervalT::domain_type domain_type;
- typedef typename IntervalT::domain_compare domain_compare;
-
- static IntervalT construct(const domain_type& lo, const domain_type& up);
-
- static domain_type upper(const IntervalT& inter_val);
- static domain_type lower(const IntervalT& inter_val);
-};
-
-
-template<class IntervalT>
-struct dynamic_intervals
-{
- typedef typename IntervalT::domain_type domain_type;
- typedef typename IntervalT::domain_compare domain_compare;
-
- static IntervalT construct(const domain_type& lo, const domain_type& up, interval_bounds bounds);
- static IntervalT construct_bounded(const bounded_value<domain_type>& lo,
- const bounded_value<domain_type>& up);
-};
-
-
-
-
-//==============================================================================
-//= Construct
-//==============================================================================
-
-template<class IntervalT>
-typename enable_if<is_asymmetric_interval<IntervalT>, IntervalT>::type
-construct(const typename IntervalT::domain_type& low, //JODO Parameter passing DomainP
- const typename IntervalT::domain_type& up,
- interval_bounds bounds = interval_bounds::right_open()) //JODO separate static intervals to avoid dependency
-{
- return intervals<IntervalT>::construct(low, up);
-}
-
-
-template<class IntervalT>
-typename enable_if<is_dynamic_bounded<IntervalT>, IntervalT>::type
-construct(const typename IntervalT::domain_type& low,
- const typename IntervalT::domain_type& up,
- interval_bounds bounds = interval_bounds::right_open())
-{
- return dynamic_intervals<IntervalT>::construct(low, up, bounds);
-}
-
-
-//- construct form bounded values ----------------------------------------------
-template<class IntervalT>
-typename enable_if<is_dynamic_bounded<IntervalT>, IntervalT>::type
-construct(const typename IntervalT::bounded_domain_type& low,
- const typename IntervalT::bounded_domain_type& up)
-{
- return dynamic_intervals<IntervalT>::construct_bounded(low, up);
-}
-
-template<class IntervalT>
-typename enable_if<is_interval<IntervalT>, IntervalT>::type
-span(const typename IntervalT::domain_type& lhs,
- const typename IntervalT::domain_type& rhs)
-{
- if(IntervalT::domain_compare(lhs,rhs))
- return construct(lhs, rhs);
- else
- return construct(rhs, lhs);
-}
-
-
-//==============================================================================
-//= Selection
-//==============================================================================
-
-template<class IntervalT>
-inline typename enable_if<is_interval<IntervalT>,
- typename IntervalT::domain_type>::type
-lower(const IntervalT& object)
-{
- return intervals<IntervalT>::lower(object);
-}
-
-template<class IntervalT>
-inline typename enable_if<is_interval<IntervalT>,
- typename IntervalT::domain_type>::type
-upper(const IntervalT& object)
-{
- return intervals<IntervalT>::upper(object);
-}
-
-
-//- first ----------------------------------------------------------------------
-template<class IntervalT>
-inline typename enable_if<is_static_rightopen<IntervalT>,
- typename IntervalT::domain_type>::type
-first(const IntervalT& object)
-{
- return lower(object);
-}
-
-template<class IntervalT>
-inline typename enable_if<is_discrete_interval<IntervalT>,
- typename IntervalT::domain_type>::type
-first(const IntervalT& object)
-{
- return is_left_closed(object.bounds()) ?
- lower(object) :
- succ(lower(object));
-}
-
-//- last -----------------------------------------------------------------------
-template<class IntervalT>
-inline typename enable_if<mpl::and_<is_static_rightopen<IntervalT>,
- is_discrete<typename IntervalT::domain_type> >,
- typename IntervalT::domain_type>::type
-last(const IntervalT& object)
-{
- return pred(upper(object));
-}
-
-template<class IntervalT>
-inline typename enable_if<is_discrete_interval<IntervalT>,
- typename IntervalT::domain_type>::type
-last(const IntervalT& object)
-{
- return is_right_closed(object.bounds()) ?
- upper(object) :
- pred(upper(object));
-}
-
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename enable_if<is_dynamic_bounded<IntervalT>,
- typename IntervalT::bounded_domain_type>::type
-bounded_lower(const IntervalT& object)
-{
- return typename
- IntervalT::bounded_domain_type(lower(object),
- object.bounds().left());
-}
-
-template<class IntervalT>
-typename enable_if<is_dynamic_bounded<IntervalT>,
- typename IntervalT::bounded_domain_type>::type
-reverse_bounded_lower(const IntervalT& object)
-{
- return typename
- IntervalT::bounded_domain_type(lower(object),
- object.bounds().reverse_left());
-}
-
-template<class IntervalT>
-typename enable_if<is_dynamic_bounded<IntervalT>,
- typename IntervalT::bounded_domain_type>::type
-bounded_upper(const IntervalT& object)
-{
- return typename
- IntervalT::bounded_domain_type(upper(object),
- object.bounds().right());
-}
-
-template<class IntervalT>
-typename enable_if<is_dynamic_bounded<IntervalT>,
- typename IntervalT::bounded_domain_type>::type
-reverse_bounded_upper(const IntervalT& object)
-{
- return typename
- IntervalT::bounded_domain_type(upper(object),
- object.bounds().reverse_right());
-}
-
-
-//==============================================================================
-//= Containedness
-//==============================================================================
-//- is_empty -------------------------------------------------------------------
-/** Is the interval empty? */
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-is_empty(const IntervalT& object)
-{
- return IntervalT::domain_less_equal(upper(object),
- lower(object));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-is_empty(const IntervalT& object)
-{
- return object.empty();
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-is_empty(const IntervalT& object)
-{
- //CL return IntervalT::domain_less(last(object), first(object));
-
- if(object.bounds() == interval_bounds::closed())
- return IntervalT::domain_less(upper(object), lower(object));
- else if(object.bounds() == interval_bounds::open())
- return IntervalT::domain_less_equal(upper(object), succ(lower(object)));
- else
- return IntervalT::domain_less_equal(upper(object), lower(object));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-is_empty(const IntervalT& object)
-{
- return IntervalT::domain_less(upper(object), lower(object))
- || ( IntervalT::domain_equal(upper(object), lower(object))
- && object.bounds() != interval_bounds::closed() );
-}
-
-//- contains -------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-contains(const IntervalT& super, const IntervalT& sub)
-{
- return lower_less_equal(super,sub) && upper_less_equal(sub,super);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-contains(const IntervalT& super, const typename IntervalT::domain_type& element)
-{
- return contains(super,IntervalT(element));
-}
-
-//- within ---------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-within(const IntervalT& sub, const IntervalT& super)
-{
- return contains(super,sub);
-}
-
-
-//==============================================================================
-//= Equivalences and Orderings
-//==============================================================================
-//- exclusive_less -------------------------------------------------------------
-/** Maximal element of <tt>left</tt> is less than the minimal element of
- <tt>right</tt> */
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-exclusive_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less_equal(left.upper(), right.lower());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-exclusive_less(const IntervalT& left, const IntervalT& right)
-{
- return left.exclusive_less(right);
-}
-
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-exclusive_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less(last(left), first(right));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-exclusive_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less(left.upper(), right.lower())
- || ( IntervalT::domain_equal(left.upper(), right.lower())
- && inner_bounds(left,right) != interval_bounds::open() );
-}
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-lower_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less(left.lower(), right.lower());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-lower_less(const IntervalT& left, const IntervalT& right)
-{
- return left.lower_less(right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-lower_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less(first(left), first(right));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-lower_less(const IntervalT& left, const IntervalT& right)
-{
- if(left_bounds(left,right) == interval_bounds::right_open()) //'[(' == 10
- return IntervalT::domain_less_equal(left.lower(), right.lower());
- else
- return IntervalT::domain_less(left.lower(), right.lower());
-}
-
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-upper_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less(left.upper(), right.upper());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-upper_less(const IntervalT& left, const IntervalT& right)
-{
- return left.upper_less(right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-upper_less(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_less(last(left), last(right));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-upper_less(const IntervalT& left, const IntervalT& right)
-{
- if(right_bounds(left,right) == interval_bounds::left_open())
- return IntervalT::domain_less_equal(left.upper(), right.upper());
- else
- return IntervalT::domain_less(left.upper(), right.upper());
-}
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::bounded_domain_type >::type
-lower_min(const IntervalT& left, const IntervalT& right)
-{
- return lower_less(left, right) ? bounded_lower(left) : bounded_lower(right);
-}
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::bounded_domain_type >::type
-lower_max(const IntervalT& left, const IntervalT& right)
-{
- return lower_less(left, right) ? bounded_lower(right) : bounded_lower(left);
-}
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::bounded_domain_type >::type
-upper_max(const IntervalT& left, const IntervalT& right)
-{
- return upper_less(left, right) ? bounded_upper(right) : bounded_upper(left);
-}
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>,
- typename IntervalT::bounded_domain_type >::type
-upper_min(const IntervalT& left, const IntervalT& right)
-{
- return upper_less(left, right) ? bounded_upper(left) : bounded_upper(right);
-}
-
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-lower_equal(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_equal(left.lower(), right.lower());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-lower_equal(const IntervalT& left, const IntervalT& right)
-{
- return left.lower_equal(right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-lower_equal(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_equal(first(left), first(right));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-lower_equal(const IntervalT& left, const IntervalT& right)
-{
- return (left.bounds().left()==right.bounds().left())
- && IntervalT::domain_equal(left.lower(), right.lower());
-}
-
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-upper_equal(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_equal(left.upper(), right.upper());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-upper_equal(const IntervalT& left, const IntervalT& right)
-{
- return left.upper_equal(right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-upper_equal(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_equal(last(left), last(right));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-upper_equal(const IntervalT& left, const IntervalT& right)
-{
- return (left.bounds().right()==right.bounds().right())
- && IntervalT::domain_equal(left.upper(), right.upper());
-}
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-lower_less_equal(const IntervalT& left, const IntervalT& right)
-{
- return lower_less(left,right) || lower_equal(left,right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-upper_less_equal(const IntervalT& left, const IntervalT& right)
-{
- return upper_less(left,right) || upper_equal(left,right);
-}
-
-
-//- operator == ----------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-operator == (const IntervalT& lhs, const IntervalT& rhs)
-{
- return (itl::is_empty(lhs) && itl::is_empty(rhs))
- || (lower_equal(lhs,rhs) && upper_equal(lhs,rhs));
-}
-
-//- operator < -----------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-operator < (const IntervalT& lhs, const IntervalT& rhs)
-{
- if(itl::is_empty(lhs))
- return !itl::is_empty(rhs);
- else
- return lower_less(lhs,rhs)
- || (lower_equal(lhs,rhs) && upper_less(lhs,rhs));
-}
-
-
-
-//------------------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, bool>::type
-touches(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_equal(left.upper(), right.lower());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, bool>::type
-touches(const IntervalT& left, const IntervalT& right)
-{
- return left.touches(right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>, bool>::type
-touches(const IntervalT& left, const IntervalT& right)
-{
- return IntervalT::domain_equal(succ(last(left)), first(right));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>, bool>::type
-touches(const IntervalT& left, const IntervalT& right)
-{
- return is_complementary(inner_bounds(left,right))
- && IntervalT::domain_equal(left.upper(), right.lower());
-}
-
-
-//==============================================================================
-//= Size
-//==============================================================================
-//- cardinality ----------------------------------------------------------------
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>,
- typename IntervalT::size_type>::type
-cardinality(const IntervalT& object)
-{
- typedef typename IntervalT::size_type SizeT;
- if(itl::is_empty(object))
- return itl::neutron<SizeT>::value();
- else if( object.bounds() == interval_bounds::closed()
- && IntervalT::domain_equal(lower(object), upper(object)))
- return itl::unon<SizeT>::value();
- else
- return infinity<SizeT>::value();
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_interval<IntervalT>,
- typename IntervalT::size_type>::type
-cardinality(const IntervalT& object)
-{
- return (last(object) + itl::unon<typename IntervalT::size_type>::value()) - first(object);
-}
-
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_asymmetric<IntervalT>,
- typename IntervalT::size_type>::type
-cardinality(const IntervalT& object)
-{
- typedef typename IntervalT::size_type SizeT;
- if(itl::is_empty(object))
- return itl::neutron<SizeT>::value();
- else
- return infinity<SizeT>::value();
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_discrete_asymmetric<IntervalT>,
- typename IntervalT::size_type>::type
-cardinality(const IntervalT& object)
-{
- return (last(object) + itl::unon<typename IntervalT::size_type>::value()) - first(object);
-}
-
-
-
-
-
-//- size -----------------------------------------------------------------------
-template<class IntervalT>
-inline typename enable_if<is_interval<IntervalT>,
- typename IntervalT::size_type>::type
-size(const IntervalT& object)
-{
- return cardinality(object);
-}
-
-//- length ---------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_continuous_interval<IntervalT>,
- typename IntervalT::difference_type>::type
-length(const IntervalT& object)
-{
- return upper(object) - lower(object);
-}
-
-template<class IntervalT>
-inline typename boost::enable_if<is_discrete_interval<IntervalT>,
- typename IntervalT::difference_type>::type
-length(const IntervalT& object)
-{
- return (last(object) + itl::unon<typename IntervalT::difference_type>::value())
- - first(object);
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_continuous_asymmetric<IntervalT>,
- typename IntervalT::difference_type>::type
-length(const IntervalT& object)
-{
- return upper(object) - lower(object);
-}
-
-template<class IntervalT>
-inline typename boost::enable_if<is_discrete_asymmetric<IntervalT>,
- typename IntervalT::difference_type>::type
-length(const IntervalT& object)
-{
- return (last(object) + itl::unon<typename IntervalT::difference_type>::value())
- - first(object);
-}
-
-//==============================================================================
-//= Addition
-//==============================================================================
-//- hull -----------------------------------------------------------------------
-/** \c hull returns the smallest interval containing \c left and \c right. */
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, IntervalT>::type
-hull(IntervalT left, const IntervalT& right)
-{
- if(itl::is_empty(right))
- return left;
- else if(itl::is_empty(left))
- return right;
-
- //JODO return construct
- return
- IntervalT
- (
- (std::min)(left.lower(), right.lower(), IntervalT::domain_compare()),
- (std::max)(left.upper(), right.upper(), IntervalT::domain_compare())
- );
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, IntervalT>::type
-hull(IntervalT left, const IntervalT& right)
-{
- return left.extend(right);
-}
-
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>, IntervalT>::type
-hull(IntervalT left, const IntervalT& right)
-{
- if(itl::is_empty(right))
- return left;
- else if(itl::is_empty(left))
- return right;
-
- //JODO return construct<IntervalT,std::less>
- return dynamic_intervals<IntervalT>::construct_bounded
- (
- lower_min(left, right),
- upper_max(left, right)
- );
-}
-
-//==============================================================================
-//= Subtraction
-//==============================================================================
-//- left_subtract --------------------------------------------------------------
-/** subtract \c left_minuend from the \c right interval on it's left side.
- Return the difference: The part of \c right right of \c left_minuend.
-\code
-right_over = right - left_minuend; //on the left.
-... d) : right
-... c) : left_minuend
- [c d) : right_over
-\endcode
-*/
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, IntervalT>::type
-left_subtract(IntervalT right, const IntervalT& left_minuend)
-{
- if(exclusive_less(left_minuend, right))
- return right;
- //JODO return construct(left_minuend.upper(), right.upper());
- return IntervalT(left_minuend.upper(), right.upper());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, IntervalT>::type
-left_subtract(IntervalT right, const IntervalT& left_minuend)
-{
- return right.left_subtract(left_minuend);
-}
-
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>, IntervalT>::type
-left_subtract(IntervalT right, const IntervalT& left_minuend)
-{
- if(exclusive_less(left_minuend, right))
- return right;
- return dynamic_intervals<IntervalT>::construct_bounded
- ( reverse_bounded_upper(left_minuend), bounded_upper(right) );
-}
-
-
-//- right_subtract -------------------------------------------------------------
-/** subtract \c right_minuend from the \c left interval on it's right side.
- Return the difference: The part of \c left right of \c right_minuend.
-\code
-left_over = left - right_minuend; //on the right side.
-[a ... : left
- [b ... : right_minuend
-[a b) : left_over
-\endcode
-*/
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, IntervalT>::type
-right_subtract(IntervalT left, const IntervalT& right_minuend)
-{
- if(exclusive_less(left, right_minuend))
- return left;
- return IntervalT(left.lower(), right_minuend.lower());
- //JODO return construct(left.lower(), right_minuend.lower());
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, IntervalT>::type
-right_subtract(IntervalT left, const IntervalT& right_minuend)
-{
- return left.right_subtract(right_minuend);
-}
-
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>, IntervalT>::type
-right_subtract(IntervalT left, const IntervalT& right_minuend)
-{
- //JODO s.o.
- if(exclusive_less(left, right_minuend))
- return left;
- //JODO return construct<IntervalT,std::less>(left.lower(), right_minuend.lower(),
- return dynamic_intervals<IntervalT>::construct_bounded
- ( bounded_lower(left), reverse_bounded_lower(right_minuend) );
-}
-
-//==============================================================================
-//= Intersection
-//==============================================================================
-//- operator & -----------------------------------------------------------------
-/** Returns the intersection of \c left and \c right interval. */
-template<class IntervalT>
-typename boost::enable_if<is_asymmetric_interval<IntervalT>, IntervalT>::type
-operator & (IntervalT left, const IntervalT& right)
-{
- if(itl::is_empty(left) || itl::is_empty(right))
- return IntervalT(); //JODO return neutron<IntervalT>::value; neutron for new interval_types.
- else
- return
- IntervalT((std::max)(left.lower(), right.lower(), IntervalT::domain_compare()),
- (std::min)(left.upper(), right.upper(), IntervalT::domain_compare()));
-}
-
-template<class IntervalT>
-typename boost::enable_if<is_universal_interval<IntervalT>, IntervalT>::type
-operator & (IntervalT left, const IntervalT& right)
-{
- return left &= right;
-}
-
-template<class IntervalT>
-typename boost::enable_if<has_dynamic_bounds<IntervalT>, IntervalT>::type
-operator & (IntervalT left, const IntervalT& right)
-{
- if(itl::is_empty(left) || itl::is_empty(right))
- return IntervalT(); //JODO return neutron<IntervalT>::value; neutron for new interval_types.
- else
- //JODO return construct<IntervalT,std::less>
- return dynamic_intervals<IntervalT>::construct_bounded
- (
- lower_max(left, right),
- upper_min(left, right)
- );
-}
-
-
-//- intersects -----------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-intersects(const IntervalT& left, const IntervalT& right)
-{
- return !(exclusive_less(left,right) || exclusive_less(right,left));
-}
-
-//- disjoint -------------------------------------------------------------------
-template<class IntervalT>
-typename boost::enable_if<is_interval<IntervalT>, bool>::type
-disjoint(const IntervalT& left, const IntervalT& right)
-{
- return exclusive_less(left,right) || exclusive_less(right,left);
-}
-
-//------------------------------------------------------------------------------
-
-
-
-}} // namespace itl boost
-
-#endif
-

Modified: sandbox/itl/boost/itl/interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -13,11 +13,10 @@
 #include <boost/itl/rightopen_interval.hpp> //JODO REV?
 #include <boost/itl/type_traits/is_interval_joiner.hpp>
 #include <boost/itl/interval_base_set.hpp>
-//CL #include <boost/itl/functions.hpp>
 #include <boost/itl/concept/interval/base.hpp>
-#include <boost/itl/concept/interval/set.hpp>
-#include <boost/itl/concept/interval/map.hpp>
-#include <boost/itl/concept/interval/set_or_map.hpp>
+#include <boost/itl/concept/interval_set.hpp>
+#include <boost/itl/concept/interval_map.hpp>
+#include <boost/itl/concept/interval_associator.hpp>
 
 
 namespace boost{namespace itl

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -20,6 +20,7 @@
 
 #include <string>
 #include <boost/type_traits/ice.hpp>
+#include <boost/call_traits.hpp>
 #include <boost/itl/detail/notate.hpp>
 #include <boost/itl/detail/design_config.hpp>
 #include <boost/itl/detail/concept_check.hpp>
@@ -35,9 +36,9 @@
 #include <boost/itl/set.hpp>
 
 #include <boost/itl/detail/map_algo.hpp>
-#include <boost/itl/concept/abstract/container.hpp>
-#include <boost/itl/concept/element/map.hpp>
-#include <boost/itl/concept/element/set_or_map.hpp>
+#include <boost/itl/concept/container.hpp>
+#include <boost/itl/concept/element_map.hpp>
+#include <boost/itl/concept/element_associator.hpp>
 
 namespace boost{namespace itl
 {
@@ -109,6 +110,7 @@
 
 public:
     typedef DomainT domain_type;
+ typedef typename boost::call_traits<DomainT>::param_type domain_param;
     typedef DomainT key_type;
     typedef CodomainT codomain_type;
     typedef CodomainT mapped_type;
@@ -241,8 +243,6 @@
         different from \c size(). */
     size_t iterative_size()const { return size(); } //JODO
 
- //CL?? size_t cardinality()const { return size(); }
-
     //==========================================================================
     //= Selection
     //==========================================================================
@@ -333,11 +333,6 @@
             ::add_intersection(section, *this, key_value_pair);
     }
 
- /** The intersection of \c operand in \c *this map is added to \c section. */
- //CL template<class OperandT>
- //map& add_intersection(map& section, const OperandT& operand)const
- //{ return itl::add_intersection(section, *this, operand); }
-
     /** Returns true, if there is an intersection of \c operand and \c *this map. */
     template<class OperandT>
     bool intersects(const OperandT& operand)const
@@ -354,37 +349,6 @@
         return on_total_absorbable<type,_total,_absorbs>::flip(*this, operand);
     }
 
- //==========================================================================
- //= Algorithm unifiers
- //==========================================================================
-
- /** \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 co_value allows for a uniform access to \c codomain_values which is
- is used for common algorithms on sets and maps. */
- template<typename IteratorT>
- static const codomain_type& co_value(IteratorT value_){ return (*value_).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); }
-
- static value_type make_value(const key_type& key_value, const codomain_type& data_value)
- { return value_type(key_value, data_value); }
-
- /** Copy the key values of the map to \c domain_set. Complexity: Linear. */
- void domain(set_type& domain_set)const
- {
- typename set_type::iterator prior_ = domain_set.end();
- ITL_const_FORALL_THIS(it_)
- prior_ = domain_set.insert(prior_, it_->first);
- }
-
 private:
     template<class Combiner>
     map& _add(const element_type& value_pair);

Modified: sandbox/itl/boost/itl/rightopen_interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/rightopen_interval.hpp (original)
+++ sandbox/itl/boost/itl/rightopen_interval.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -16,7 +16,7 @@
                                          //Two partitions of interval_functions
                                          // (dependen on i_b ( independent on i_b ))
 #include <boost/itl/detail/base_interval.hpp>
-#include <boost/itl/interval_functions.hpp>
+#include <boost/itl/concept/interval.hpp>
 
 namespace boost{namespace itl
 {
@@ -63,16 +63,6 @@
     domain_type lower()const{ return _lwb; }
     domain_type upper()const{ return _upb; }
 
- /*CL
- domain_type first()const{ return _lwb; }
-
- DomainT last()const
- { //JODO first and last as global functions?
- BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
- return pred(_upb);
- }
- */
-
 private:
     domain_type _lwb;
     domain_type _upb;

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -19,6 +19,7 @@
 #endif
 
 #include <string>
+#include <boost/call_traits.hpp>
 #include <boost/itl/detail/design_config.hpp>
 #include <boost/itl/detail/concept_check.hpp>
 #include <boost/itl/type_traits/to_string.hpp>
@@ -30,10 +31,10 @@
 #include <boost/mpl/not.hpp>
 #include <boost/type_traits/is_same.hpp>
 
-#include <boost/itl/concept/abstract/container.hpp>
-#include <boost/itl/concept/element/set.hpp>
-#include <boost/itl/concept/element/set_or_map.hpp>
-#include <boost/itl/concept/abstract/comparable.hpp>
+#include <boost/itl/concept/container.hpp>
+#include <boost/itl/concept/element_set.hpp>
+#include <boost/itl/concept/element_associator.hpp>
+#include <boost/itl/concept/comparable.hpp>
 
 
 namespace boost{namespace itl
@@ -55,6 +56,7 @@
 
 public:
     typedef DomainT domain_type;
+ typedef typename boost::call_traits<DomainT>::param_type domain_param;
     typedef DomainT codomain_type;
     typedef DomainT element_type;
     typedef DomainT key_type;
@@ -216,33 +218,6 @@
     /** If \c *this set contains \c element it is erased, otherwise it is added. */
     set& flip(const element_type& element)
     { return itl::flip(*this, element); }
-
-
- //==========================================================================
- //= Algorithm unifiers
- //==========================================================================
-
- /** \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 codomain_value allows for a uniform access to \c data_values which is
- is used for common algorithms on sets and maps. */
- template<typename IteratorT>
- static const codomain_type& co_value(IteratorT value_){ return (*value_); }
-
- /** \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_value(const key_type& key_value, const codomain_type&)
- { return key_value; }
-
 };
 
 

Added: sandbox/itl/boost/itl/type_traits/is_domain_comparable.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_domain_comparable.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -0,0 +1,39 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2010-2010: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ITL_TYPE_TRAITS_IS_DOMAIN_COMPARABLE_HPP_JOFA_100925
+#define BOOST_ITL_TYPE_TRAITS_IS_DOMAIN_COMPARABLE_HPP_JOFA_100925
+
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/itl/type_traits/domain_type_of.hpp>
+
+namespace boost{ namespace itl
+{
+ namespace detail
+ {
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(domain_param)
+ BOOST_MPL_HAS_XXX_TRAIT_DEF(domain_compare)
+ }
+
+ template <class Type>
+ struct is_domain_comparable
+ : mpl::bool_
+ <
+ detail::has_domain_type<Type>::value &&
+ detail::has_domain_param<Type>::value &&
+ detail::has_domain_compare<Type>::value
+ >
+ {};
+
+}} // namespace boost itl
+
+#endif
+
+

Modified: sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -8,6 +8,8 @@
 #ifndef BOOST_ITL_TYPE_TRAITS_IS_INTERVAL_SPLITTER_HPP_JOFA_081004
 #define BOOST_ITL_TYPE_TRAITS_IS_INTERVAL_SPLITTER_HPP_JOFA_081004
 
+#include <boost/config.hpp>
+
 namespace boost{ namespace itl
 {
     template <class Type> struct is_interval_splitter

Modified: sandbox/itl/boost/itl_xt/tuple_computer.hpp
==============================================================================
--- sandbox/itl/boost/itl_xt/tuple_computer.hpp (original)
+++ sandbox/itl/boost/itl_xt/tuple_computer.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -187,7 +187,12 @@
     */
     //@{
         ///
- std::string as_string()const { return m_map.as_string(); }
+ std::string as_string()const
+ {
+ stringstream str;
+ str << m_map;
+ return str.str();
+ }
     //@}
 
 

Modified: sandbox/itl/boost/validate/validater/concept_validater.hpp
==============================================================================
--- sandbox/itl/boost/validate/validater/concept_validater.hpp (original)
+++ sandbox/itl/boost/validate/validater/concept_validater.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -25,7 +25,6 @@
         // the choice probability, and also the availability of laws is individual to each type
         // Somehow it has to be defined in conjunction to every type. So it is an aspect of
         // type traits.
- //CL virtual void setProfile()=0;
         virtual LawValidaterI* chooseValidater()=0;
         virtual bool hasValidProfile()const{ return true; }
 

Modified: sandbox/itl/libs/itl/example/itvset_shell_/itvset_shell.cpp
==============================================================================
--- sandbox/itl/libs/itl/example/itvset_shell_/itvset_shell.cpp (original)
+++ sandbox/itl/libs/itl/example/itvset_shell_/itvset_shell.cpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -18,6 +18,7 @@
 #include <boost/itl/split_interval_map.hpp>
 
 using namespace std;
+using namespace boost;
 using namespace boost::itl;
 
 void instructions()

Modified: sandbox/itl/libs/itl/example/splititvmap_shell_/splititvmap_shell.cpp
==============================================================================
--- sandbox/itl/libs/itl/example/splititvmap_shell_/splititvmap_shell.cpp (original)
+++ sandbox/itl/libs/itl/example/splititvmap_shell_/splititvmap_shell.cpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -19,6 +19,7 @@
 #include <boost/itl/interval_map.hpp>
 
 using namespace std;
+using namespace boost;
 using namespace boost::itl;
 
 void instructions()

Modified: sandbox/itl/libs/itl/test/fastest_itl_map_/fastest_itl_map_cases.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/fastest_itl_map_/fastest_itl_map_cases.hpp (original)
+++ sandbox/itl/libs/itl/test/fastest_itl_map_/fastest_itl_map_cases.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -16,7 +16,7 @@
 (fastest_itl_itl_map_find_4_bicremental_types)
 { itl_map_find_4_bicremental_types<discrete_type_1, int, partial_absorber, INTERVAL_MAP>();}
 
-//CL or repair
+//JODO CL or repair
 //BOOST_AUTO_TEST_CASE
 //(fastest_itl_itl_map_inclusion_compare_4_bicremental_types)
 //{ itl_map_inclusion_compare_4_bicremental_types<discrete_type_1, int, partial_absorber, INTERVAL_MAP>();}

Modified: sandbox/itl/libs/itl/test/test_value_maker.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_value_maker.hpp (original)
+++ sandbox/itl/libs/itl/test/test_value_maker.hpp 2010-09-26 10:10:48 EDT (Sun, 26 Sep 2010)
@@ -109,7 +109,6 @@
     {
         return interval_type(test_value<domain_type>::make(lower),
                              test_value<domain_type>::make(upper), interval_bounds(bounds));
- //CL test_value<domain_type>::make(upper), static_cast<bound_type>(bounds));
     }
 
     static segment_type val_pair(int lower, int upper, int val, int bounds = 2)


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