|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49589 - in sandbox/itl: . boost boost/itl boost/itl/type_traits boost/itl_xt boost/validate boost/validate/gentor boost/validate/laws boost/validate/loki boost/validate/loki_xt libs libs/itl libs/itl/build libs/itl/build/cygwin libs/itl/build/script libs/itl/build/win32 libs/itl/example libs/itl/example/boost_party libs/itl/example/interval libs/itl/example/interval_container libs/itl/example/itvset_shell libs/itl/example/man_power libs/itl/example/month_and_week_grid libs/itl/example/overlap_counter libs/itl/example/party libs/itl/example/splititvmap_shell libs/itl/example/user_groups libs/itl/test libs/itl/test/test_interval_map libs/itl/test/test_interval_map_mixed libs/itl/test/test_interval_set libs/itl/test/test_interval_set_mixed libs/itl/test/test_itl_interval libs/itl/test/test_separate_interval_set libs/itl/test/test_split_interval_map libs/itl/test/test_split_interval_set libs/itl_xt libs/itl_xt/example libs/itl_xt/example/amount_cube libs/itl_xt/example/history libs/itl_xt/test libs/itl_xt/test/auto_itv_test libs/validate libs/validate/example libs/validate/example/labatea libs/validate/src libs/validate/src/gentor
From: afojgo_at_[hidden]
Date: 2008-11-04 13:46:32
Author: jofaber
Date: 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
New Revision: 49589
URL: http://svn.boost.org/trac/boost/changeset/49589
Log:
initial import
Added:
sandbox/itl/
sandbox/itl/boost/
sandbox/itl/boost/itl/
sandbox/itl/boost/itl/functors.hpp (contents, props changed)
sandbox/itl/boost/itl/gregorian.hpp (contents, props changed)
sandbox/itl/boost/itl/interval.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_base_map.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_base_set.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_map.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_map_algo.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_maps.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_morphism.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_set.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_set_algo.hpp (contents, props changed)
sandbox/itl/boost/itl/interval_sets.hpp (contents, props changed)
sandbox/itl/boost/itl/map.hpp (contents, props changed)
sandbox/itl/boost/itl/map_algo.hpp (contents, props changed)
sandbox/itl/boost/itl/notate.hpp (contents, props changed)
sandbox/itl/boost/itl/predicates.hpp (contents, props changed)
sandbox/itl/boost/itl/ptime.hpp (contents, props changed)
sandbox/itl/boost/itl/rational.hpp (contents, props changed)
sandbox/itl/boost/itl/separate_interval_set.hpp (contents, props changed)
sandbox/itl/boost/itl/set.hpp (contents, props changed)
sandbox/itl/boost/itl/set_algo.hpp (contents, props changed)
sandbox/itl/boost/itl/split_interval_map.hpp (contents, props changed)
sandbox/itl/boost/itl/split_interval_set.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/
sandbox/itl/boost/itl/type_traits/difference.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/is_continuous.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/is_interval_container.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/is_neutron_absorber.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/is_neutron_emitter.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/is_set.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/neutron.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/size.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/succ_pred.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/to_string.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/type_to_string.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/unon.hpp (contents, props changed)
sandbox/itl/boost/itl/type_traits/value_size.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/
sandbox/itl/boost/itl_xt/enum_bitset.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/episode_product.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/episode_set.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/fixtupelconst.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/gentorit.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/group_order.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/grouping.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/itvgentor.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/list.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/mapgentor.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/numbergentor.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/ordered_type.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/prefix_set.cpp (contents, props changed)
sandbox/itl/boost/itl_xt/prefix_set.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/product_history.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/random.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/randomnumber.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/seqgentor.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/setgentor.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/statvardesct.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/string_list.cpp (contents, props changed)
sandbox/itl/boost/itl_xt/string_list.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/string_map.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/string_set.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/string_sheet.cpp (contents, props changed)
sandbox/itl/boost/itl_xt/string_sheet.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/stringpattern_set.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/tuple_computer.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/typed_episode.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/var_permutation.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/var_tuple.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/var_tuple_inscriptor.hpp (contents, props changed)
sandbox/itl/boost/itl_xt/var_tuple_order.hpp (contents, props changed)
sandbox/itl/boost/validate/
sandbox/itl/boost/validate/gentor/
sandbox/itl/boost/validate/gentor/gentorprofile.h (contents, props changed)
sandbox/itl/boost/validate/gentor/randomgentor.h (contents, props changed)
sandbox/itl/boost/validate/gentor/rangegentor.h (contents, props changed)
sandbox/itl/boost/validate/law.h (contents, props changed)
sandbox/itl/boost/validate/laws/
sandbox/itl/boost/validate/laws/monoid.h (contents, props changed)
sandbox/itl/boost/validate/laws/order.h (contents, props changed)
sandbox/itl/boost/validate/laws/pushouts.h (contents, props changed)
sandbox/itl/boost/validate/laws/set_laws.h (contents, props changed)
sandbox/itl/boost/validate/lawvalidater.h (contents, props changed)
sandbox/itl/boost/validate/lawviolations.h (contents, props changed)
sandbox/itl/boost/validate/loki/
sandbox/itl/boost/validate/loki/EmptyType.h (contents, props changed)
sandbox/itl/boost/validate/loki/NullType.h (contents, props changed)
sandbox/itl/boost/validate/loki/Sequence.h (contents, props changed)
sandbox/itl/boost/validate/loki/TypeManip.h (contents, props changed)
sandbox/itl/boost/validate/loki/TypeTraits.h (contents, props changed)
sandbox/itl/boost/validate/loki/Typelist.h (contents, props changed)
sandbox/itl/boost/validate/loki/TypelistMacros.h (contents, props changed)
sandbox/itl/boost/validate/loki_xt/
sandbox/itl/boost/validate/loki_xt/Tuple.h (contents, props changed)
sandbox/itl/boost/validate/loki_xt/TupleGentor.h (contents, props changed)
sandbox/itl/boost/validate/loki_xt/TypelistGentor.h (contents, props changed)
sandbox/itl/boost/validate/realmvalidater.h (contents, props changed)
sandbox/itl/boost/validate/typevalidater.h (contents, props changed)
sandbox/itl/libs/
sandbox/itl/libs/itl/
sandbox/itl/libs/itl/build/
sandbox/itl/libs/itl/build/cygwin/
sandbox/itl/libs/itl/build/cygwin/makefile (contents, props changed)
sandbox/itl/libs/itl/build/script/
sandbox/itl/libs/itl/build/script/rm_svn (contents, props changed)
sandbox/itl/libs/itl/build/script/rm_temps (contents, props changed)
sandbox/itl/libs/itl/build/win32/
sandbox/itl/libs/itl/build/win32/vc9_all.sln (contents, props changed)
sandbox/itl/libs/itl/example/
sandbox/itl/libs/itl/example/Jamfile.v2 (contents, props changed)
sandbox/itl/libs/itl/example/boost_party/
sandbox/itl/libs/itl/example/boost_party/Jamfile.v2 (contents, props changed)
sandbox/itl/libs/itl/example/boost_party/boost_party.cpp (contents, props changed)
sandbox/itl/libs/itl/example/boost_party/vc9_boost_party.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/interval/
sandbox/itl/libs/itl/example/interval/interval.cpp (contents, props changed)
sandbox/itl/libs/itl/example/interval/vc9_interval.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/interval_container/
sandbox/itl/libs/itl/example/interval_container/interval_container.cpp (contents, props changed)
sandbox/itl/libs/itl/example/interval_container/vc9_interval_container.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/itvset_shell/
sandbox/itl/libs/itl/example/itvset_shell/itvset_shell.cpp (contents, props changed)
sandbox/itl/libs/itl/example/itvset_shell/vc9_itvset_shell.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/man_power/
sandbox/itl/libs/itl/example/man_power/man_power.cpp (contents, props changed)
sandbox/itl/libs/itl/example/man_power/vc9_man_power.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/month_and_week_grid/
sandbox/itl/libs/itl/example/month_and_week_grid/month_and_week_grid.cpp (contents, props changed)
sandbox/itl/libs/itl/example/month_and_week_grid/vc9_month_and_week_grid.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/overlap_counter/
sandbox/itl/libs/itl/example/overlap_counter/overlap_counter.cpp (contents, props changed)
sandbox/itl/libs/itl/example/overlap_counter/vc9_overlap_counter.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/party/
sandbox/itl/libs/itl/example/party/Jamfile.v2 (contents, props changed)
sandbox/itl/libs/itl/example/party/party.cpp (contents, props changed)
sandbox/itl/libs/itl/example/party/vc9_party.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/splititvmap_shell/
sandbox/itl/libs/itl/example/splititvmap_shell/splititvmap_shell.cpp (contents, props changed)
sandbox/itl/libs/itl/example/splititvmap_shell/vc9_splititvmap_shell.vcproj (contents, props changed)
sandbox/itl/libs/itl/example/toytime.h (contents, props changed)
sandbox/itl/libs/itl/example/user_groups/
sandbox/itl/libs/itl/example/user_groups/user_groups.cpp (contents, props changed)
sandbox/itl/libs/itl/example/user_groups/vc9_user_groups.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/
sandbox/itl/libs/itl/test/Jamfile.v2 (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_map/
sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_map/vc9_test_interval_map.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_map_mixed/
sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_map_mixed/vc9_test_interval_map_mixed.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_map_shared.hpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_set/
sandbox/itl/libs/itl/test/test_interval_set/test_interval_set.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_set/vc9_test_interval_set.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_set_mixed/
sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_set_mixed/vc9_test_interval_set_mixed.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_interval_set_shared.hpp (contents, props changed)
sandbox/itl/libs/itl/test/test_itl_interval/
sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_itl_interval/vc9_test_itl_interval.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_separate_interval_set/
sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_separate_interval_set/vc9_test_separate_interval_set.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_split_interval_map/
sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_split_interval_map/vc9_test_split_interval_map.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_split_interval_set/
sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp (contents, props changed)
sandbox/itl/libs/itl/test/test_split_interval_set/vc9_test_split_interval_set.vcproj (contents, props changed)
sandbox/itl/libs/itl/test/test_type_lists.hpp (contents, props changed)
sandbox/itl/libs/itl/test/test_value_maker.hpp (contents, props changed)
sandbox/itl/libs/itl_xt/
sandbox/itl/libs/itl_xt/example/
sandbox/itl/libs/itl_xt/example/amount_cube/
sandbox/itl/libs/itl_xt/example/amount_cube/amount_cube.cpp (contents, props changed)
sandbox/itl/libs/itl_xt/example/amount_cube/vc9_amount_cube.vcproj (contents, props changed)
sandbox/itl/libs/itl_xt/example/history/
sandbox/itl/libs/itl_xt/example/history/history.cpp (contents, props changed)
sandbox/itl/libs/itl_xt/example/history/vc9_history.vcproj (contents, props changed)
sandbox/itl/libs/itl_xt/example/toytime.h (contents, props changed)
sandbox/itl/libs/itl_xt/test/
sandbox/itl/libs/itl_xt/test/auto_itv_test/
sandbox/itl/libs/itl_xt/test/auto_itv_test/auto_itv_test.cpp (contents, props changed)
sandbox/itl/libs/itl_xt/test/auto_itv_test/vc9_auto_itv_test.vcproj (contents, props changed)
sandbox/itl/libs/itl_xt/test/itvmaptester.h (contents, props changed)
sandbox/itl/libs/itl_xt/test/itvsettester.h (contents, props changed)
sandbox/itl/libs/validate/
sandbox/itl/libs/validate/example/
sandbox/itl/libs/validate/example/labatea/
sandbox/itl/libs/validate/example/labatea/labatea.cpp (contents, props changed)
sandbox/itl/libs/validate/example/labatea/vc9_labatea.vcproj (contents, props changed)
sandbox/itl/libs/validate/src/
sandbox/itl/libs/validate/src/gentor/
sandbox/itl/libs/validate/src/gentor/gentorprofile.cpp (contents, props changed)
Added: sandbox/itl/boost/itl/functors.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/functors.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,172 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_functors_H_JOFA_080315__
+#define __itl_functors_H_JOFA_080315__
+
+#include <boost/itl/type_traits/neutron.hpp>
+#include <functional>
+
+namespace boost{namespace itl
+{
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_identity
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const{}
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_identity>::apply()
+ { return "i="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_erasure
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const
+ {
+ if(object == operand)
+ object = Type();
+ }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_erasure>::apply()
+ { return "0="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_plus
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ typedef Type type;
+
+ void operator()(Type& object, const Type& operand)const
+ { object += operand; }
+
+ static void complement(Type& object, const Type& operand)
+ { object -= operand; }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_plus>::apply() { return "+="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_minus
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ typedef Type type;
+ void operator()(Type& object, const Type& operand)const
+ { object -= operand; }
+
+ static void complement(Type& object, const Type& operand)
+ { object += operand; }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_minus>::apply() { return "-="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inserter
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const
+ { insert(object,operand); }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inserter>::apply() { return "ins="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct eraser
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const
+ { erase(object,operand); }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<eraser>::apply() { return "ers="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_star
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const
+ { object *= operand; }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_star>::apply() { return "*="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_max
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const
+ {
+ if(object < operand)
+ object = operand;
+ }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_max>::apply() { return "max="; }
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_min
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ void operator()(Type& object, const Type& operand)const
+ {
+ if(object > operand)
+ object = operand;
+ }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<inplace_min>::apply() { return "min="; }
+
+
+ // -------------------------------------------------------------------------
+ template<template<class>class InplaceBinaryOp, class Type> struct complement
+ : public std::binary_function
+ < typename InplaceBinaryOp<Type>::type& ,
+ const typename InplaceBinaryOp<Type>::type& , void>
+ {
+ void operator()(typename InplaceBinaryOp<Type>::type& object,
+ const typename InplaceBinaryOp<Type>::type& operand)
+ {
+ return InplaceBinaryOp<Type>::complement(object, operand);
+ }
+ };
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/gregorian.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/gregorian.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,110 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------------------
+Function-templates for discrete Datatypes like int, unsigned or
+ any class that provides a ++ operator c.f. iterators
+-----------------------------------------------------------------------------*/
+
+#ifndef __itl_gregorian_date_JOFA_080416_H__
+#define __itl_gregorian_date_JOFA_080416_H__
+
+#include <stdio.h>
+#include <string>
+#include <sstream>
+
+#include <boost/date_time/gregorian/gregorian.hpp>
+
+//JODO Produce a better compietime error here.
+//JODO (Write Macro to reduce codereplication. Generate line info.) not needed if compile-time error is nifty.
+//JODO Make it complete for all date_time classes. check portability.
+#ifdef ITL_NEUTRONS_PROVIDED
+#pragma message("error: No neutral element provided for type boost::gregorian::date")
+#pragma message(".. please #include <boost/itl/gregorian.hpp> PRIOR TO other itl/* classes")
+"JODO: Compiletime error has to be produced, but in a nicer way."
+#endif
+
+#ifdef ITL_DIFFERENCE_TYPES_PROVIDED
+#pragma message("error: No difference type provided for type boost::gregorian::date")
+#pragma message(".. please #include <boost/itl/gregorian.hpp> PRIOR TO other itl/* classes")
+#endif
+
+#ifdef ITL_SIZE_TYPES_PROVIDED
+#pragma message("error: No size type provided for type boost::gregorian::date")
+#pragma message(".. please #include <boost/itl/gregorian.hpp> PRIOR TO other itl/* classes")
+#endif
+
+#define ITL_NEEDS_GREGORIAN_DATE_NEUTRON_VALUE
+#define ITL_NEEDS_GREGORIAN_DATE_DIFFERENCE_TYPE
+#define ITL_NEEDS_GREGORIAN_DATE_SIZE_TYPE
+
+namespace boost{namespace itl
+{
+
+ boost::gregorian::date operator ++(boost::gregorian::date& x)
+ {
+ return x += boost::gregorian::date::duration_type::unit();
+ }
+
+ boost::gregorian::date operator --(boost::gregorian::date& x)
+ {
+ return x -= boost::gregorian::date::duration_type::unit();
+ }
+
+ // ------------------------------------------------------------------------
+ boost::gregorian::date_duration operator ++(boost::gregorian::date_duration& x)
+ {
+ return x += boost::gregorian::date::duration_type::unit();
+ }
+
+ boost::gregorian::date_duration operator --(boost::gregorian::date_duration& x)
+ {
+ return x -= boost::gregorian::date::duration_type::unit();
+ }
+
+ // ------------------------------------------------------------------------
+
+ //JODO testing of boost gregorian fails
+ // boost::date_time::date_duration<duration_rep_traits> lacks op <<
+ //
+ //template<class CharType, class CharTraits, class duration_rep_traits>
+ //std::basic_ostream<CharType, CharTraits>& operator <<
+ //(std::basic_ostream<CharType, CharTraits> &stream,
+ // boost::date_time::date_duration<duration_rep_traits> const& x)
+ //{
+ // return stream << "[date_duration<duration_rep_traits>]";
+ //}
+
+ //boost::date_time::date_duration<duration_rep_traits>
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,1173 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_interval_JOFA_000626_H__
+#define __itl_interval_JOFA_000626_H__
+
+#include <ostream>
+#include <functional>
+#include <limits>
+#include <string>
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/call_traits.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/itl/type_traits/neutron.hpp>
+#include <boost/itl/type_traits/unon.hpp>
+#include <boost/itl/type_traits/is_continuous.hpp>
+#include <boost/itl/type_traits/difference.hpp>
+#include <boost/itl/type_traits/size.hpp>
+#include <boost/itl/type_traits/to_string.hpp>
+
+#undef min
+#undef max
+
+#define BOUND_VAL first
+#define BOUND_TYPES second
+
+typedef unsigned char ITV_BOUNDTYPES;
+
+namespace boost{namespace itl
+{
+
+/**
+ \mainpage The Interval Template Library
+
+ \section news_sec News
+
+ New examples are available showing applications of interval containers
+ that use boost::date_time. Boost::gregorian dates and boost::posix times
+ are used in examples boost_party.cpp, man_power.cpp, user_groups.cpp
+ and month_and_week_grid.cpp.
+
+ \section intro_sec Introduction
+
+ The Interval Template Library (ITL) is a collection of
+ generic c++ template classes for computations on <em>collections of
+ intervals</em>. The most important instance of their use is the computation
+ with containers of time intervals that are associated to values. We call
+ such containers \e histories and their elements \e episodes. In addition to
+ intervals and interval containers the library provides classes for
+ generalized crosstables, which are tuple containers. We call such
+ containers <em>tuple computers</em> or \e cubes.
+ \n \n
+ The Interval Template Library is currently hosted at the open source
+ platform sourceforge and can be downloaded from http://sourceforge.net/projects/itl .
+ This doxygen generated html documentation is part of the library release.
+ In addition it is available at http://www.herold-faulhaber.de/itl .
+ \n \n
+ Basic parts of the ITL (interval conainers) are currently discussed at the
+ boost developers mailing list as a contribution to the boost libraries.
+ Although the sourcecode of the ITL is mature and very well tested it's
+ design may be refactored significantly in a process of adapting to the
+ boost library design principles and coding standards.
+ \n \n \n
+
+ \section sample_sec Examples
+
+ We do provide a collection of examples that demonstrate the purpose and basic
+ characteristics of the classes offered by the library. To get an instant
+ impression you may browse these examples first.
+ \n \n \n
+
+ \subsection party_subsec Party
+
+ boost_party.cpp is the ITL's <em>flagship example</em> because it demonstrates
+ at least two important aspects of the library design in a
+ comprehensible way.
+ In boost_party.cpp the change of guests of a party in time is calculated using
+ an interval_map simply by adding pairs of intervals and guest sets
+ to the interval_map. As can be seen from this example interval_map has a
+ <em>decompositional behavior</em> on the time part: time intervals are
+ split up whenever the set of guests is changing. And it has an
+ <em>aggregational behavior</em> on the associated values: Guest sets are
+ added up on insertion. (party.cpp is a variant of the example that does not use
+ boost::date_time).
+ \n \n
+
+ \subsection interval_subsec Intervals
+
+ Interval.cpp gives a short example of different instances of the class interval
+ \n \n
+
+ \subsection interval_container_subsec Interval container
+
+ Sample interval_container.cpp demonstrates basic charactersistics of
+ interval container objects: interval_set, split_interval_set and split_interval_map.
+ \n \n
+
+ \subsection month_and_week_grid Partitioning of times using split_interval_set
+
+ Example month_and_week_grid.cpp shows how the <em>border preserving</em>
+ split_interval_set can be used to create time partitionigs where different
+ periodic time intervals overlay each other. The example uses boost::date_time.
+ \n \n
+
+
+
+ \subsection overlap_counter_subsec Overlap counter: The most basic interval_map application
+
+ The most basic application of an interval_map is a counter counting
+ the number of overlaps of intervals inserted into it as shown in overlap_counter.cpp.
+ \n \n
+
+ \subsection man_power Man-power: Set operations on interval containers
+
+ Set style operations on interval_sets and interval_maps like union, difference
+ and intersection can be used to obtain calculations in a flexible way. Example
+ man_power.cpp demontrates such operations in the process of calculating the
+ available man-power of a company in a given time interval. The example uses
+ boost::date_time.
+ \n \n
+
+ \subsection history_subsec History
+
+ History is a more sophisticated application of an interval_map to decompose
+ data in time. Sample history.cpp shows how we can monitor a set of attributes in a history.
+ \n \n
+
+
+ \subsection user_groups_subsec User Groups: Union and intersecion of histories
+
+ Example user_groups.cpp shows how interval_maps can be unified (+=) or
+ intersected (*=) to calculate desired informations. We have a group of
+ admin users and of medcial staff, who have different authorisations in
+ a ficticious system. The interval_maps for
+ the groups show the history of the group membership: The members
+ and how they change in time. The union of the groups is a
+ history that shows the memberships of employees who have
+ any rights (admin or medical). And the intersection represents the
+ group of employees who have both rights: The superusers.
+
+
+ \subsection amount_cube_subsec Amount cube
+
+ Cubes or tuple computers allow to perform computations on values associated
+ to tuples. A ITL tuple computer works similar to pivot tables (in spreadsheet programs)
+ olap cubes (online analytic processing) or crosstables (in statistical programs).
+ Sample amount_cube.cpp presents an application where values are \e 'amounts',
+ which is the simplest instance.
+ \n \n \n
+
+ \section content_sec Content of the ITL
+
+ \subsection itv_subsec Intervals and sets of intervals
+
+ A set of intervals represents again a set. The implementation of a set as a set of
+ intervals is a very efficient implementation of a set if it's elements are
+ clustered in intervals. Examples for interval sets are given in sample
+ interval_container.cpp.
+ \n \n
+
+ \subsection aov_subsec Interval maps and 'aggregation on overlap'
+
+ On of the most fruitful concept of the ITL is the <em>aggregation on overlap</em>
+ mechanism on interval maps. The associated values of an interval map are
+ aggregated on insertion, whenever an interval value pair is added and
+ the added interval overlaps intervals within the map. Depending on the value
+ type this aggregation can be summation (for numbers), concatentation
+ (for lists, strings), set union (for sets) and more. Samples of the
+ <em>aggreation on overlap</em> mechanics are demonstrated in
+ files boost_party.cpp (party.cpp), overlap_counter.cpp, man_power.cpp
+ and history.cpp.
+ \n \n \n
+
+ \subsection itv_cont_subsec Overview over interval containers
+
+ Interval containers are sets or maps that are implemented as sets or maps of
+ intervals. They are efficient and useful containers in all problem domains
+ where elements of sets apperar in continguous chunks (intervals).
+
+ The design of the itl provides five kinds of interval containers: 3 set
+ class templates and 2 map class templated. The above table presents an
+ overview over interval containers:
+
+ <table>
+ <tr>
+ <th></td>
+ <th>joining</td>
+ <th>separating</td>
+ <th>splitting</td>
+ </tr>
+ <tr>
+ <td>set</td>
+ <td>interval_set</td>
+ <td>separate_interval_set</td>
+ <td>split_interval_set</td>
+ </tr>
+ <tr>
+ <td>map</td>
+ <td>interval_map</td>
+ <td></td>
+ <td>split_interval_map</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td><em>intervals are joined on overlap or touch<br>
+ (if associated values are equal)</em></td>
+ <td><em>intervals are joined on overlap, not on touch</em></td>
+ <td><em>intervals are split on overlap.<br>All interval borders are thus preserved</em></td>
+ </tr>
+ <tr>
+ <td></td><td colspan=3 align="center">
+ The different behavior of interval_containers is clarified
+ in interval_container_conduct.h by example.
+ </td>
+ </tr>
+ </table>
+
+ Aspects of the interval container's desing are presented in interval_container_design.h .
+
+
+ \subsection decom_subsec Decomposition of Histories
+
+ Using interval maps we can build a so called <em>product history</em>,
+ where a product of attributes (or objects) is associated to intervals
+ and then inserted to a history. A product history keeps itself always
+ in a normal form. Whenever any of the attributes changes, the intervals
+ are split such that all attributes associated to an interval are constant.
+ So here we get a general mechanism for decomposition of (time) intervals for
+ the change of monitored attributes. An example for product histories is
+ given in file history.cpp.
+ \n \n
+
+
+ \subsection cubes_subsec Cubes
+
+ Tuple computer or cubes are implemented as maps of tuples in the ITL.
+ Cubes are known as crosstables from statistical packages, OLAP
+ (online analytic processing) cubes from data warehouse technology
+ and pivot tables from spradsheet programs (e.g. excel). In the ITL
+ we offer a generic implementation of such cubes in c++. Aggregation
+ (e.g. summation) can be expressed by omitting elements of the tuple
+ type of the cube, which we call projection. Other things like grouping
+ and sorting can be done quite elegantly. An example for cubes is
+ provided by file amount_cube.cpp.
+ \n \n
+
+ \section thanks_sec Acknowledgements
+
+ I would like to thank CEO Hermann Steppe and Chief Developer Peter Wuttke
+ of Cortex Software GmbH for their friendly support of my work on the
+ ITL and their permission to release the library as open source.
+
+*/
+
+/// A class for intervals
+/** Bounds of the interval may be closed or open.
+ Discrete or continuous datatypes may be used as domain datatypes DataT.
+
+ Template parameter <b>DataT</b>:
+ The intervals domain type or type of the elements of the interval.
+ The interface <b>DataT</b> has to be implemented by any actual template
+ parameter.
+
+ The class defines intervals with closed or open bounds for discrete
+ <tt>(short, int, date, time etc.)</tt> and continuous
+ <tt>float, double, Rational etc.</tt> elements. The domain parameter
+ may be a built in c++ datatype or a class type. It has to implement
+ the interface DataT.
+
+ @author Joachim Faulhaber
+*/
+template <class DataT>
+class interval
+{
+public:
+
+/** @name A: Type definitions for the template class
+*/
+//@{
+ /// Domain type or element type
+ typedef DataT data_type;
+
+ /// The difference type of an interval which is sometimes different form the data_type
+ typedef typename itl::difference<DataT>::type difference_type;
+
+ /// The size type of an interval which is mostly std::size_t
+ typedef typename itl::size<DataT>::type size_type;
+
+ /// Interval bounds as bitset
+ typedef unsigned char bound_types;
+
+ /// Constants for intervalbounds
+ enum BoundTypes {
+ /// Both open: <tt>(x,y)</tt>
+ OPEN = 0x0,
+ /// Left open right closed: <tt>(x,y]</tt>
+ LEFT_OPEN = 0x1,
+ /// Left closed right open: <tt>[x,y)</tt>
+ RIGHT_OPEN = 0x2,
+ /// Both closed: <tt>[x,y]</tt>
+ CLOSED = 0x3,
+ } ;
+
+//@}
+
+
+ /// Default constructor; yields an empty interval <tt>[1,0]</tt>
+ interval() : _lwb(unon<DataT>::value()), _upb(neutron<DataT>::value()),
+ _boundtypes(CLOSED) {}
+
+ // Use compiler generated copy contructor
+
+ /// Constructor for a closed singleton interval <tt>[val,val]</tt>
+ explicit interval(const DataT& val) :
+ _lwb(val), _upb(val), _boundtypes(CLOSED) {}
+ /// Closed interval <tt>[lw,up]</tt>
+ interval(const DataT& lw, const DataT& up) :
+ _lwb(lw), _upb(up), _boundtypes(CLOSED) {}
+ /// Interval from <tt>lw</tt> to <tt>up</tt> with bounds <tt>bt</tt>
+ interval(const DataT& lw, const DataT& up, bound_types bt) :
+ _lwb(lw), _upb(up), _boundtypes(bt) {}
+
+ // Use compiler generated assignment operator =
+
+/** @name E: Selectors
+*/
+//@{
+ /// Lower bound of the interval
+ DataT lower()const { return _lwb; }
+ /// Upper bound of the interval
+ DataT upper()const { return _upb; }
+ /// Typ of interval bounds
+ bound_types boundtypes()const { return _boundtypes; }
+//@}
+
+/** @name F.P: Tester, predicates
+*/
+//@{
+ /// Is the interval empty?
+ bool empty()const;
+ /// Does the interval contain <tt>x</tt>?
+ bool contains(const DataT& x)const;
+
+ /// Both closed: <tt>[x,y]</tt> ?
+ bool is_closed()const { return _boundtypes == CLOSED; }
+ /// Left open right closed: <tt>(x,y]</tt> ?
+ bool is_leftopen()const { return _boundtypes == LEFT_OPEN; }
+ /// Left closed right open: <tt>[x,y)</tt> ?
+ bool is_rightopen()const { return _boundtypes == RIGHT_OPEN; }
+ /// Both open: <tt>(x,y)</tt> ?
+ bool is_open()const { return _boundtypes == OPEN; }
+
+ /// Left bound is open right unknown <tt>(x,y|</tt> ?
+ bool leftbound_open()const { return !leftbound_closed(); }
+
+ /// Right bound is open left unknown <tt>|x,y)</tt> ?
+ bool rightbound_open()const { return !rightbound_closed(); }
+
+ /// Left closed right unknown <tt>[x,y|</tt> ?
+ bool leftbound_closed()const { return 0 != (_boundtypes & RIGHT_OPEN); }
+
+ /// Right closed left unknown <tt>|x,y]</tt> ?
+ bool rightbound_closed()const { return 0 != (_boundtypes & LEFT_OPEN); }
+//@}
+
+/** @name F.R: Tester, relations
+*/
+//@{
+
+ /// <tt>*this</tt> is subset of <tt>super</tt>
+ bool contained_in(const interval& super)const ;
+ /// <tt>*this</tt> is superset of <tt>sub</tt>
+ bool contains(const interval& sub)const;
+
+ /// Equality
+ bool equal(const interval& x2)const
+ { return (empty() && x2.empty()) || (lower_equal(x2) && upper_equal(x2)); }
+ //Equality can also be implemented this way:
+ //{ return contained_in(x2) && x2.contained_in(*this); }
+
+ /// <tt>*this</tt> and <tt>x2</tt> are disjoint; their intersection is empty
+ bool is_disjoint(const interval& x2)const
+ { return exclusive_less(x2) || x2.exclusive_less(*this); }
+ /// There is no gap between <tt>*this</tt> and <tt>x2</tt> but they have no element in common
+ bool touches(const interval& x2)const;
+
+ /// Exclusive less: maximal element of <tt>*this</tt> is less than the minimal element of <tt>x2</tt>
+ bool exclusive_less(const interval& x2)const;
+
+ /// less on intervals
+ bool less(const interval& x2)const
+ { return lower_less(x2) || ( lower_equal(x2) && upper_less(x2) ); }
+
+//@}
+
+
+/** @name G: Modificators
+*/
+//@{
+ /// Set the interval empty
+ void clear()
+ { set_lwb(unon<DataT>::value()); set_upb(neutron<DataT>::value()); _boundtypes=CLOSED; }
+
+ /// Set the intervals values
+ interval& set(const DataT& lw, const DataT& up, bound_types bt)
+ { _lwb=lw; _upb=up; _boundtypes=bt; return *this; }
+
+ /** Extend <tt>*this</tt> to <tt>x2</tt> yielding an interval from the minimum of lower bounds
+ to the maximum of upper bounds */
+ interval& extend(const interval& x2);
+//@}
+
+
+/** @name H: Combinators and more
+*/
+//@{
+ /// Intersection with the interval <tt>x2</tt>; assign result to <tt>isec</tt>
+ void intersect(interval& isec, const interval& x2)const;
+
+ /// Returns the intersection with the interval <tt>x2</tt>
+ interval intersect(const interval& x2)const { interval isec; intersect(isec, x2); return isec; }
+
+ // wenn <tt>*this</tt> links über <tt>x2</tt> herausragt, ist <tt>lsur</tt> das überstehende linke Teilintervall
+ ///
+ void left_surplus(interval& lsur, const interval& x2)const;
+ // wenn <tt>*this</tt> rechts über <tt>x2</tt> herausragt, ist <tt>rsur</tt> das überstehende rechte Teilintervall
+ ///
+ void right_surplus(interval& rsur, const interval& x2)const;
+
+ /** Interval spanning from lower bound of *this interval to the upper bound of rhs.
+ Bordertypes according to the lower bound of *this and the upper bound of rhs.
+ */
+ interval span(const interval& rhs)const
+ {
+ if(empty()) return rhs;
+ else if(rhs.empty()) return *this;
+ else return
+ interval(_lwb, rhs._upb, span(boundtypes(), rhs.boundtypes()));
+ }
+
+ interval& left_subtract(const interval& x2);
+//@}
+
+
+/** @name S: String representation
+ */
+//@{
+ /// Interval as string
+ const std::string as_string()const;
+//@}
+
+
+ // NOTE ------- DISCRETE ONLY ------- DISCRETE ONLY ------- DISCRETE ONLY -------
+/** @name T: For discrete domain datatypes only that implement operators <tt>++</tt>
+ and <tt>--</tt>
+ */
+//@{
+ /// First (smallest) element of the interval
+ DataT first()const;
+ /// Last (largest) element of the interval
+ DataT last()const;
+
+ /// Cardinality of the interval: The number of elements
+ size_type cardinality()const;
+
+ size_type continuous_cardinality()const
+ {
+ if(empty())
+ return itl::neutron<size_type>::value();
+ else if(is_closed() && _lwb == _upb)
+ return itl::unon<size_type>::value();
+ else
+ return std::numeric_limits<size_type>::infinity();
+ }
+
+ size_type discrete_cardinality()const
+ { return empty()? itl::neutron<size_type>::value() : succ(last()-first()); }
+
+
+ /// Arithmetic size of the interval
+ difference_type length()const;
+
+ difference_type continuous_length()const
+ { return empty() ? itl::neutron<difference_type>::value() : _upb - _lwb; }
+
+ difference_type discrete_length()const
+ {
+ return empty() ?
+ itl::neutron<difference_type>::value() :
+ succ(last() - first());
+ }
+
+ /// Size of the interval
+ size_type size()const { return cardinality(); }
+
+ /// <tt>*this</tt> interval as closed <tt>[x,y]</tt> interval
+ interval as_closed_interval()const;
+ /// <tt>*this</tt> interval as open <tt>[x,y]</tt> interval
+ interval as_rightopen_interval()const;
+
+ /** Transforms the interval to the bound-type <tt>bound_types bt</tt> without
+ changing it's content
+ */
+ void transform_bounds(bound_types bt);
+
+ /** Sets left border closed. */
+ void close_left_bound();
+
+ /** Sets right border open. */
+ void open_right_bound();
+
+//@}
+
+/** @name U: Utilities and Limits
+ */
+//@{
+ /// Maximum Interval
+ static interval always()
+ { return closed_interval(std::numeric_limits<DataT>::min(),
+ std::numeric_limits<DataT>::max()); }
+//@}
+
+ void set_lwb(DataT lw) { _lwb=lw; }
+ void set_upb(DataT up) { _upb=up; }
+
+ bool lower_less(const interval& x2)const;
+ bool upper_less(const interval& x2)const;
+ bool lower_less_equal(const interval& x2)const;
+ bool upper_less_equal(const interval& x2)const;
+ bool lower_equal(const interval& x2)const;
+ bool upper_equal(const interval& x2)const;
+
+private:
+ // public?
+ typedef std::pair<DataT, bound_types> BoundT;
+
+ void set_lwb_type(bound_types bt)
+ { _boundtypes = (unsigned char)((LEFT_OPEN & _boundtypes) | (RIGHT_OPEN & bt)); }
+
+ void set_upb_type(bound_types bt)
+ { _boundtypes = (unsigned char)((RIGHT_OPEN & _boundtypes) | (LEFT_OPEN & bt)); }
+
+ static bound_types span(bound_types left, bound_types right)
+ { return (unsigned char)((LEFT_OPEN | left) & (RIGHT_OPEN | right)) ; }
+
+ bound_types succession_bounds()const;
+
+ void set_lwb(const BoundT& lw) { _lwb=lw.BOUND_VAL; set_lwb_type(lw.BOUND_TYPES); }
+ void set_upb(const BoundT& up) { _upb=up.BOUND_VAL; set_upb_type(up.BOUND_TYPES); }
+
+ BoundT lwb_min(const interval& x2)const;
+ BoundT lwb_max(const interval& x2)const;
+ BoundT upb_min(const interval& x2)const;
+ BoundT upb_max(const interval& x2)const;
+
+ BoundT lwb_rightOf(const interval& x2)const;
+ BoundT upb_leftOf(const interval& x2)const;
+
+private:
+ DataT _lwb;
+ DataT _upb;
+ bound_types _boundtypes;
+} ;
+
+
+
+
+template <class DataT>
+interval<DataT> closed_interval(const DataT& lwb, const DataT& upb)
+{ return interval<DataT>(lwb, upb, interval<DataT>::CLOSED); }
+
+template <class DataT>
+interval<DataT> leftopen_interval(const DataT& lwb, const DataT& upb)
+{ return interval<DataT>(lwb, upb, interval<DataT>::LEFT_OPEN); }
+
+template <class DataT>
+interval<DataT> rightopen_interval(const DataT& lwb, const DataT& upb)
+{ return interval<DataT>(lwb, upb, interval<DataT>::RIGHT_OPEN); }
+
+template <class DataT>
+interval<DataT> open_interval(const DataT& lwb, const DataT& upb)
+{ return interval<DataT>(lwb, upb, interval<DataT>::OPEN); }
+
+
+
+
+template <class DataT>
+typename interval<DataT>::bound_types interval<DataT>::succession_bounds()const
+{
+ if(_boundtypes==RIGHT_OPEN) return RIGHT_OPEN;
+ if(_boundtypes==LEFT_OPEN) return LEFT_OPEN;
+ if(_boundtypes==CLOSED) return OPEN;
+ return CLOSED;
+}
+
+
+template<class DataT>
+struct continuous_type
+{
+ typedef typename boost::call_traits<DataT>::param_type DataP;
+
+ static bool open_bound_less_equal(DataP x, DataP y) { return x <= y; }
+ static bool open_bound_less (DataP x, DataP y) { return x < y; }
+};
+
+template<class DataT>
+struct discrete_type
+{
+ typedef typename boost::call_traits<DataT>::param_type DataP;
+
+ static bool open_bound_less_equal(DataP x, DataP y) { return x <= succ(y); }
+ static bool open_bound_less (DataP x, DataP y) { return succ(x) < y ; }
+};
+
+template <class DataT>
+bool interval<DataT>::empty()const
+{
+ using namespace boost::mpl;
+
+ if(rightbound_closed() && leftbound_closed()) return _upb < _lwb;
+ if(rightbound_open() && leftbound_closed()) return _upb <= _lwb;
+ if(rightbound_closed() && leftbound_open()) return _upb <= _lwb;
+
+ // OTHERWISE (rightbound_open() && leftbound_open())
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_type<DataT>,
+ discrete_type<DataT>
+ >
+ ::type::open_bound_less_equal(_upb, _lwb);
+}
+
+template<class DataT>
+struct continuous_interval
+{
+ static typename itl::interval<DataT>::size_type
+ cardinality(const interval<DataT>& x)
+ { return x.continuous_cardinality(); }
+
+ static typename itl::interval<DataT>::difference_type
+ length(const interval<DataT>& x)
+ { return x.continuous_length(); }
+
+ static bool unaligned_lwb_equal(const interval<DataT>& x1, const interval<DataT>& x2)
+ { return false; }
+
+ static bool unaligned_upb_equal(const interval<DataT>& x1, const interval<DataT>& x2)
+ { return false; }
+
+ static bool has_equal_border_touch(const interval<DataT>& x1, const interval<DataT>& x2)
+ { return false; }
+};
+
+template<class DataT>
+struct discrete_interval
+{
+ static typename itl::interval<DataT>::size_type
+ cardinality(const interval<DataT>& x)
+ { return x.discrete_cardinality(); }
+
+ static typename interval<DataT>::difference_type
+ length(const interval<DataT>& x)
+ { return x.discrete_length(); }
+
+ static bool unaligned_lwb_equal(const interval<DataT>& x1, const interval<DataT>& x2)
+ {
+ if(x1.leftbound_open() && x2.leftbound_closed())
+ return succ(x1.lower()) == x2.lower();
+ else return x1.lower() == succ(x2.lower());
+ }
+
+ static bool unaligned_upb_equal(const interval<DataT>& x1, const interval<DataT>& x2)
+ {
+ if(x1.rightbound_closed() && x2.rightbound_open())
+ return succ(x1.upper()) == x2.upper();
+ else return x1.upper() == succ(x2.upper());
+ }
+
+ static bool has_equal_border_touch(const interval<DataT>& x1, const interval<DataT>& x2)
+ {
+ if(x1.rightbound_closed() && x2.leftbound_closed())
+ return succ(x1.upper()) == x2.lower();
+ if(x1.rightbound_open() && x2.leftbound_open() )
+ return x1.upper() == succ(x2.lower());
+ return false;
+ }
+
+};
+
+// NOTE structural similarities between empty and exclusive_less!
+// emptieness can be defined as being exclusive less to oneself.
+template <class DataT>
+bool interval<DataT>::exclusive_less(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(rightbound_closed() && x2.leftbound_closed()) return _upb < x2._lwb;
+ if(rightbound_open() && x2.leftbound_closed()) return _upb <= x2._lwb;
+ if(rightbound_closed() && x2.leftbound_open() ) return _upb <= x2._lwb;
+
+ // OTHERWISE (rightbound_open() && leftbound_open())
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_type<DataT>,
+ discrete_type<DataT>
+ >
+ ::type::open_bound_less_equal(_upb, x2._lwb);
+}
+
+
+template <class DataT>
+bool interval<DataT>::lower_less(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(leftbound_closed() && x2.leftbound_closed()) return _lwb < x2._lwb;
+ if(leftbound_open() && x2.leftbound_open()) return _lwb < x2._lwb;
+ if(leftbound_closed() && x2.leftbound_open()) return _lwb <= x2._lwb;
+
+ // OTHERWISE (leftbound_open() && x2.leftbound_closed())
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_type<DataT>,
+ discrete_type<DataT>
+ >
+ ::type::open_bound_less(_lwb, x2._lwb);
+}
+
+template <class DataT>
+bool interval<DataT>::upper_less(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(rightbound_closed() && x2.rightbound_closed()) return _upb < x2._upb;
+ if(rightbound_open() && x2.rightbound_open()) return _upb < x2._upb;
+ if(rightbound_open() && x2.rightbound_closed()) return _upb <= x2._upb;
+
+ // OTHERWISE (rightbound_closed() && x2.rightbound_open())
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_type<DataT>,
+ discrete_type<DataT>
+ >
+ ::type::open_bound_less(_upb, x2._upb);
+}
+
+
+template <class DataT>
+bool interval<DataT>::lower_less_equal(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(leftbound_closed() && x2.leftbound_closed()) return _lwb <= x2._lwb;
+ if(leftbound_open() && x2.leftbound_open()) return _lwb <= x2._lwb;
+ if(leftbound_open() && x2.leftbound_closed()) return _lwb < x2._lwb;
+
+ // OTHERWISE (leftbound_closed() && x2.leftbound_open())
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_type<DataT>,
+ discrete_type<DataT>
+ >
+ ::type::open_bound_less_equal(_lwb, x2._lwb);
+}
+
+
+template <class DataT>
+bool interval<DataT>::upper_less_equal(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(rightbound_closed() && x2.rightbound_closed()) return _upb <= x2._upb;
+ if(rightbound_open() && x2.rightbound_open()) return _upb <= x2._upb;
+ if(rightbound_closed() && x2.rightbound_open()) return _upb < x2._upb;
+
+ // OTHERWISE (rightbound_open() && x2.rightbound_closed())
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_type<DataT>,
+ discrete_type<DataT>
+ >
+ ::type::open_bound_less_equal(_upb, x2._upb);
+}
+
+
+//NOTE THINK: This implementation is rather interesting wrt. continuous value types.
+// An alternative implementation was x.lwb_equal(y)={return x.lower_less_equal(y) && y.lower_less_equal(x)}
+template <class DataT>
+bool interval<DataT>::lower_equal(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(leftbound_closed() && x2.leftbound_closed()) return _lwb == x2._lwb;
+ if(leftbound_open() && x2.leftbound_open() ) return _lwb == x2._lwb;
+
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_interval<DataT>,
+ discrete_interval<DataT>
+ >
+ ::type::unaligned_lwb_equal(*this, x2);
+}
+
+//NOTE THINK: This implementation is rather interesting wrt. continuous value types.
+// An alternative implementation was x.lwb_equal(y)={return x.lower_less_equal(y) && y.lower_less_equal(x)}
+template <class DataT>
+bool interval<DataT>::upper_equal(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(rightbound_closed() && x2.rightbound_closed()) return _upb == x2._upb;
+ if(rightbound_open() && x2.rightbound_open() ) return _upb == x2._upb;
+
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_interval<DataT>,
+ discrete_interval<DataT>
+ >
+ ::type::unaligned_upb_equal(*this, x2);
+}
+
+
+
+template <class DataT>
+typename interval<DataT>::BoundT interval<DataT>::lwb_min(const interval& x2)const
+{
+ if( x2.lower_less(*this) )
+ return BoundT(x2._lwb, x2.boundtypes());
+ else
+ return BoundT(_lwb, boundtypes());
+}
+
+template <class DataT>
+typename interval<DataT>::BoundT interval<DataT>::upb_max(const interval& x2)const
+{
+ if( upper_less(x2) )
+ return BoundT(x2._upb, x2.boundtypes());
+ else
+ return BoundT(_upb, boundtypes());
+}
+
+
+// JODO THINK URG do borders reverse when lwb_max is used as upb etc. ?
+template <class DataT>
+typename interval<DataT>::BoundT interval<DataT>::lwb_max(const interval& x2)const
+{
+ if( lower_less(x2) )
+ return BoundT(x2._lwb, x2.boundtypes());
+ else
+ return BoundT(_lwb, boundtypes());
+}
+
+template <class DataT>
+typename interval<DataT>::BoundT interval<DataT>::upb_min(const interval& x2)const
+{
+ if( x2.upper_less(*this) )
+ return BoundT(x2._upb, x2.boundtypes());
+ else
+ return BoundT(_upb, boundtypes());
+}
+
+
+template <class DataT>
+typename interval<DataT>::BoundT interval<DataT>::upb_leftOf(const interval& x2)const
+{
+ return BoundT(x2._lwb, x2.succession_bounds());
+}
+
+template <class DataT>
+typename interval<DataT>::BoundT interval<DataT>::lwb_rightOf(const interval& x2)const
+{
+ return BoundT(x2._upb, x2.succession_bounds());
+}
+
+
+// NOTE non symmetric version: *this[upb].touches(x2[lwb])
+template <class DataT>
+bool interval<DataT>::touches(const interval& x2)const
+{
+ using namespace boost::mpl;
+ if(rightbound_open() && x2.leftbound_closed()) return _upb == x2._lwb;
+ if(rightbound_closed() && x2.leftbound_open()) return _upb == x2._lwb;
+
+ return
+ if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_interval<DataT>,
+ discrete_interval<DataT>
+ >
+ ::type::has_equal_border_touch(*this, x2);
+}
+
+template <class DataT>
+bool interval<DataT>::contains(const DataT& x)const
+{
+ if(rightbound_closed() && leftbound_closed()) return _lwb <= x && x <= _upb;
+ if(rightbound_closed() && leftbound_open() ) return _lwb < x && x <= _upb;
+ if(rightbound_open() && leftbound_closed()) return _lwb <= x && x < _upb;
+ return _lwb < x && x < _upb;
+}
+
+template <class DataT>
+bool interval<DataT>::contained_in(const interval& super)const
+{ return super.lower_less_equal(*this) && upper_less_equal(super); }
+
+template <class DataT>
+bool interval<DataT>::contains(const interval& sub)const
+{ return lower_less_equal(sub) && sub.upper_less_equal(*this); }
+
+
+template <class DataT>
+interval<DataT>& interval<DataT>::extend(const interval<DataT>& x2)
+{
+ if(x2.empty()) return *this;
+ else if(empty())
+ {
+ *this = x2;
+ return *this;
+ }
+ else
+ {
+ set_lwb(lwb_min(x2));
+ set_upb(upb_max(x2));
+ return *this;
+ }
+}
+
+
+template <class DataT>
+inline interval<DataT>& interval<DataT>::left_subtract(const interval& x2)
+{
+ set_lwb( BoundT(x2._upb, x2.succession_bounds()) );
+ return *this;
+}
+
+
+template <class DataT>
+void interval<DataT>::intersect(interval<DataT>& isec, const interval<DataT>& x2)const
+{
+ isec.set_lwb(lwb_max(x2));
+ isec.set_upb(upb_min(x2));
+}
+
+
+template <class DataT>
+void interval<DataT>::left_surplus(interval<DataT>& lsur, const interval<DataT>& x2)const
+{
+ if(lower_less(x2)) {
+ lsur.set_lwb( BoundT(_lwb,boundtypes()) );
+ lsur.set_upb( upb_leftOf(x2) );
+ }
+ else lsur.clear();
+}
+
+template <class DataT>
+void interval<DataT>::right_surplus(interval<DataT>& rsur, const interval<DataT>& x2)const
+{
+ if(x2.upper_less(*this)) {
+ rsur.set_lwb(lwb_rightOf(x2));
+ rsur.set_upb( BoundT(_upb,boundtypes()) );
+ }
+ else rsur.clear();
+}
+
+
+template <class DataT>
+const std::string interval<DataT>::as_string()const
+{
+ std::string itvRep("");
+ std::string lwbRep, ubpRep;
+
+ itvRep += leftbound_open() ? "(" : "[" ;
+ itvRep += itl::to_string<DataT>::apply(_lwb);
+ itvRep += ",";
+ itvRep += itl::to_string<DataT>::apply(_upb);
+ itvRep += rightbound_open() ? ")" : "]" ;
+
+ return itvRep;
+}
+
+
+// NOTE ------- DISCRETE ONLY ------- DISCRETE ONLY ------- DISCRETE ONLY -------
+// these functions do only compile with discrete DataT-Types that implement
+// operators ++ and --
+// NOTE: they must be used in any function that is essential to all instances
+// of DataT
+
+template <class DataT>
+DataT interval<DataT>::first()const
+{
+ //JODO: BOOST_STATIC_ASSERT generates compiletime error even if
+ // code is correctly not used
+ //BOOST_STATIC_ASSERT(!itl::is_continuous<DataT>::value);
+ BOOST_ASSERT(!itl::is_continuous<DataT>::value);
+ return leftbound_closed() ? _lwb : succ(_lwb);
+}
+
+template <class DataT>
+DataT interval<DataT>::last()const
+{
+ BOOST_ASSERT(!itl::is_continuous<DataT>::value);
+ return rightbound_closed() ? _upb : pred(_upb);
+}
+
+template <class DataT>
+typename interval<DataT>::size_type interval<DataT>::cardinality()const
+{
+ using namespace boost::mpl;
+ return if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_interval<DataT>,
+ discrete_interval<DataT>
+ >
+ ::type::cardinality(*this);
+}
+
+template <class DataT>
+typename interval<DataT>::difference_type interval<DataT>::length()const
+{
+ using namespace boost::mpl;
+ return if_<
+ bool_<is_continuous<DataT>::value>,
+ continuous_interval<DataT>,
+ discrete_interval<DataT>
+ >
+ ::type::length(*this);
+}
+
+
+template <class DataT>
+interval<DataT> interval<DataT>::as_closed_interval()const
+{
+ return interval(first(), last(), CLOSED);
+}
+
+template <class DataT>
+interval<DataT> interval<DataT>::as_rightopen_interval()const
+{
+ return interval(first(), pred(last()), RIGHT_OPEN);
+}
+
+template <class DataT>
+void interval<DataT>::transform_bounds(bound_types bt)
+{
+ switch(bt)
+ {
+ case CLOSED: set(first(), last(), bt); break;
+ case RIGHT_OPEN:set(first(), succ(last()), bt); break;
+ case LEFT_OPEN: set(pred(first()), last(), bt); break;
+ case OPEN: set(pred(first()), succ(last()), bt); break;
+ }
+}
+
+template <class DataT>
+void interval<DataT>::close_left_bound()
+{
+ if(leftbound_open())
+ {
+ _boundtypes |= RIGHT_OPEN;
+ _lwb++;
+ }
+}
+
+template <class DataT>
+void interval<DataT>::open_right_bound()
+{
+ if(rightbound_closed())
+ {
+ _boundtypes &= RIGHT_OPEN;
+ _upb++;
+ }
+}
+
+
+
+template <typename DataT>
+inline bool operator == (const interval<DataT>& lhs, const interval<DataT>& rhs)
+{
+ return lhs.equal(rhs);
+}
+
+template <typename DataT>
+inline bool operator < (const interval<DataT>& lhs, const interval<DataT>& rhs)
+{
+ return lhs.less(rhs);
+}
+
+
+/// Comparison functor on intervals implementing an overlap free less
+/**
+ <b>Template-Klasse exclusive_less: Comparison Functor for Intervals</b>
+
+ Template parameter <b>IntervalType</b>: needs to implement the boolean function
+
+ <tt>bool IntervalType::exclusive_less(IntervalType x2)const; </tt>
+
+ <b>exclusive_less</b> implements a strict weak ordering that serves to
+ sort sets and maps of intervals interval_set, split_interval_set and
+ split_interval_map.
+
+ Function <tt>bool IntervalType::exclusive_less(IntervalType x2)const; </tt> is true if every
+ element of the interval <tt>*this</tt> is less than any element of <tt>x2</tt>
+
+ @author Joachim Faulhaber
+*/
+template <class IntervalType>
+struct exclusive_less {
+ /** Operator <tt>operator()</tt> implements a strict weak ordering on intervals. */
+ bool operator()(const IntervalType& x1, const IntervalType& x2)const
+ { return x1.exclusive_less(x2); }
+};
+
+
+// ----------------------------------------------------------------------------
+// operators
+// ----------------------------------------------------------------------------
+template <class DataT>
+itl::interval<DataT>& operator *= ( itl::interval<DataT>& section,
+ const itl::interval<DataT>& sectant)
+{
+ section.intersect(section, sectant);
+ return section;
+}
+
+template<class CharType, class CharTraits, class DataT>
+std::basic_ostream<CharType, CharTraits> &operator<<
+ (std::basic_ostream<CharType, CharTraits> &stream, interval<DataT> const& x)
+{
+ if(x.empty())
+ return stream << "[]";
+ else
+ {
+ return stream << std::string(x.leftbound_open() ? "(" : "[")
+ << x.lower() << "," << x.upper()
+ << std::string(x.rightbound_open()? ")" : "]");
+ }
+}
+
+
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,1312 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/* ------------------------------------------------------------------
+class interval_base_map
+--------------------------------------------------------------------*/
+#ifndef __interval_base_map_h_JOFA_990223__
+#define __interval_base_map_h_JOFA_990223__
+
+#include <limits>
+#include <boost/itl/notate.hpp>
+#include <boost/itl/map.hpp>
+#include <boost/itl/interval_base_set.hpp>
+#include <boost/itl/interval_sets.hpp>
+#include <boost/itl/interval.hpp>
+
+
+#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)++)
+
+namespace boost{namespace itl
+{
+
+template<class DomainT, class CodomainT>
+struct base_pair
+{
+ DomainT key;
+ CodomainT data;
+
+ base_pair(const DomainT& key_value, const CodomainT& data_value)
+ :key(key_value), data(data_value){}
+
+ base_pair(const std::pair<DomainT,CodomainT>& std_pair)
+ :key(std_pair.first), data(std_pair.second){}
+};
+
+
+
+/// Implements a map as a map of intervals (abstract base class)
+/**
+ class template <b>interval_base_map</b>
+ implements a map as a map of intervals
+
+ Template parameter <b>DomainT</b>: Domain type of the map. Also type of the
+ map's keys.
+
+ Suitable as domain types are all datatypes that posess a strict weak order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Template parameter <b>CodomainT</b>: The map's codomain type or data type: Type
+ of associated values contained in the map.
+
+ Datatypes for the codomain parameter have to <b>implement</b> operations
+ <tt>+=</tt>, <tt>-=</tt>, <tt>==</tt> (equality) and <tt>CodomainT()</tt> (default constructor).
+
+ The default constructor <tt>CodomainT()</tt> has to contruct a neutral element
+ such that the following holds:
+
+ If <tt>x = y; y += CodomainT();</tt> then <tt>x==y;</tt> and
+ If <tt>x = y; y -= CodomainT();</tt> then <tt>x==y;</tt>
+
+ Template parameter <b>Interval=itl::interval</b>: Type of interval template used
+ to implement the set. The default <b>itl::interval</b> uses the
+ interval class that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>interval_base_map</b> implements a map <tt>map<DomainT, CodomainT></tt> as a map
+ of intervals <tt>map<interval<DomainT>, CodomainT, exclusive_less<interval_type> ></tt>
+
+ Interval maps <tt>interval_base_map<DomainT,CodomainT></tt> can be used similar (and in many
+ aspects exactly like) common stl-maps. Unlike to stl-maps where you store
+ a value for every key an interval map stores a contents value for an interval of
+ keys. In it's degenerated form the key intervals contain a single element
+ only. Then the interval map works like a normal stl-map. But if you work in problem
+ domains where you associate values to large contiguous intervals, interval maps
+ are very useful and efficient.
+
+ <b>Class <tt>interval_base_map</tt> yields the following benefits: </b>
+
+ <ul>
+ <li> A set of intervals is conceived as the domain set of the map.
+ The complexity involved with
+ operations on intervals maps is encapsulated. The user of the class who
+ wants to perform operations on interval maps is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_base_map</b> gives an efficient implementation of maps consisting
+ of larger contiguous chunks. Very large, even uncountably infinite maps
+ can be represented in a compact way and handled efficiently.
+ </ul>
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+
+ These functions are tagged in the documentation. Using such functions
+ for continuous domain datatypes yields compiletime errors. C.f. getting
+ the <tt>first()</tt> element of a left open interval makes sense for intervals of
+ int but not for intervals of double.
+
+ @author Joachim Faulhaber
+*/
+template
+<
+ class SubType,
+ typename DomainT,
+ typename CodomainT,
+ class Traits = itl::neutron_absorber,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+>
+#ifdef USE_CONCEPTS
+//conceptgcc is still too buggy
+//requires
+//{
+// std::LessThanComparable<DomainT>,
+// std::EqualityComparable<Codomain>
+//}
+#endif
+class interval_base_map
+{
+public:
+
+/** @name A: Type definitions for the template class
+*/
+//@{
+ typedef Traits traits;
+ typedef SubType sub_type;
+
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>
+ type;
+
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ itl::neutron_absorber,Interval,Compare,Alloc>
+ neutron_absorber_type;
+
+ /// Domain type (type of the keys) of the map
+ typedef DomainT domain_type;
+ /// Domain type (type of the keys) of the map
+ typedef CodomainT codomain_type;
+ /// basic value type
+ typedef std::pair<domain_type,codomain_type> base_value_type;
+ /// Auxiliary type to help the compiler resolve ambiguities when using std::make_pair
+ typedef base_pair<domain_type,codomain_type> base_pair_type;
+ /// The interval type of the map
+ typedef Interval<DomainT> interval_type;
+
+ /// The difference type of an interval which is sometimes different form the domain_type
+ typedef typename interval_type::difference_type difference_type;
+
+ /// The size type of an interval which is mostly std::size_t
+ typedef typename interval_type::size_type size_type;
+
+ /// Comparison functor for domain values
+ typedef Compare<DomainT> domain_compare;
+ /// Comparison functor for intervals which are keys as well
+ typedef exclusive_less<interval_type> interval_compare;
+
+ /// Comparison functor for keys
+ typedef exclusive_less<interval_type> key_compare;
+
+ /// The allocator type of the set
+ typedef Alloc<std::pair<const interval_type, codomain_type> >
+ allocator_type;
+
+ /// Container type for the implementation
+ typedef itl::map<interval_type,codomain_type,Traits,
+ exclusive_less,Alloc> ImplMapT;
+
+ /// key type of the implementing container
+ typedef typename ImplMapT::key_type key_type;
+ /// value type of the implementing container
+ typedef typename ImplMapT::value_type value_type;
+ /// data type of the implementing container
+ typedef typename ImplMapT::value_type::second_type data_type;
+
+ /// iterator for iteration over intervals
+ typedef typename ImplMapT::iterator iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplMapT::const_iterator const_iterator;
+ /// iterator for reverse iteration over intervals
+ typedef typename ImplMapT::reverse_iterator reverse_iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplMapT::const_reverse_iterator const_reverse_iterator;
+
+
+ // Corresponding abstract interval set type
+ //typedef interval_base_set<SetSubType,DomainT,Interval,Compare,Alloc> interval_base_set_type;
+
+ /// The atomized type is elementbased map that is equivalent to the interval map
+ typedef typename itl::map<DomainT,CodomainT,
+ Traits,Compare,Alloc> atomized_type;
+//@}
+
+public:
+ inline static bool has_symmetric_difference()
+ { return is_set<codomain_type>::value || !traits::absorbs_neutrons || traits::emits_neutrons; }
+
+public:
+/** @name B: Constructors, destructors, assignment
+*/
+//@{
+ /// Default constructor for the empty map
+ interval_base_map(){}
+
+ /// Copy constructor
+ interval_base_map(const interval_base_map& src): _map(src._map) {}
+
+ /// Assignment operator
+ interval_base_map& operator = (const interval_base_map& src)
+ {
+ if(this==&src)
+ return *this;
+
+ that()->assign(src);
+ return *this;
+ }
+
+ /// swap the content of containers
+ void swap(interval_base_map& x) { _map.swap(x._map); }
+//@}
+
+/** @name C: Basic container functions */
+//@{
+ /// clear the map
+ void clear() { _map.clear(); }
+
+ /// is the map empty?
+ bool empty()const { return _map.empty(); }
+
+ //--- contains: set view ------------------------------------------------------
+ /// Does the map contain the key element \c x
+ bool contains(const DomainT& x)const
+ {
+ typename ImplMapT::const_iterator it = _map.find(interval_type(x));
+ return it != _map.end();
+ }
+
+ //--- contains: map view ------------------------------------------------------
+ /// Does the map contain the element pair <tt>x = (key_element,value)</tt>?
+ bool contains(const base_pair_type& x)const
+ { return that()->contains_(value_type(interval_type(x.key), x.data)); }
+
+ /// Does the map contain all element value pairs represented by the interval-value pair sub?
+ bool contains(const value_type& sub)const
+ { return that()->contains_(sub); }
+
+ /** Does <tt>*this</tt> container contain <tt>sub</tt>? */
+ bool contains(const interval_base_map& sub)const
+ { return sub.contained_in(*this); }
+
+ /// <tt>*this</tt> is subset of <tt>super</tt>
+ bool contained_in(const interval_base_map& super)const;
+//@}
+
+
+/** @name E: Bounds and other selectors */
+//@{
+ /// Lower bound of the first interval
+ DomainT lower()const
+ { return empty()? Interval<DomainT>().lower() : (*(_map.begin())).KEY_VALUE.lower(); }
+
+ /// Upper bound of the last interval
+ DomainT upper()const
+ { return empty()? Interval<DomainT>().upper() : (*(_map.rbegin())).KEY_VALUE.upper(); }
+
+ /// Number of intervals which is also the size of the iteration over the map
+ size_t interval_count()const { return _map.size(); }
+ /// Size of the iteration over this container
+ size_t iterative_size()const { return _map.size(); }
+
+ /// Number of elements in the map (cardinality).
+ size_type cardinality()const;
+
+ /// An interval map's size is it's cardinality
+ size_type size()const { return cardinality(); }
+
+ /// The length of the interval map which is the sum of interval lenghts
+ difference_type length()const;
+
+//@}
+
+
+
+//-----------------------------------------------------------------------------
+/** @name G.add: Addition */
+//@{
+
+ /// Addition of a base value pair using a Combinator operation.
+ /** Addition of a base value pair <tt>x := pair(k,y)</tt> where
+ <tt>base_value_type:=pair<DomainT,CodomainT></tt>
+
+ This adds (inserts) a value <tt>y</tt> for a single key <tt>k</tt> into the map.
+ If <tt>k</tt> already has a value <tt>y0</tt> associated with it, <tt>y0</tt>
+ will be 'incremented' by <tt>y</tt> calling <tt>Combinator(y0,y)</tt>.
+
+ If Combinator implements addition (+=) associated values will contain sums.
+ If Combinator implements max, associated values will contain maximal values and so on.
+ */
+ template<template<class>class Combinator>
+ SubType& add(const base_pair_type& x)
+ {
+ that()->template add_<Combinator>( value_type(interval_type(x.KEY_VALUE), x.CONT_VALUE) );
+ return *that();
+ }
+
+ /// Addition of a value pair using a Combinator operation.
+ /** Addition of a value pair <tt>x := pair(I,y)</tt> where <tt>base_value_type:=pair<DomainT,CodomainT></tt>
+
+ This adds (inserts) a value <tt>y</tt> an interval <tt>I</tt> into the map.
+
+ If no values are associated already within the range of <tt>I</tt>,
+ <tt>y</tt> will be associated to that interval.
+
+ If there are associated values, in the range of <tt>I</tt>, then all
+ those values within the ranges of their intervals,
+ are combined by <tt>y</tt>. This is done via the <tt>Combinator</tt> function
+ that is passed as template parameter.
+
+ If Combinator implements addition (+=) associated values will contain sums.
+ If Combinator implements max, associated values will contain maximal values and so on.
+ */
+ template<template<class>class Combinator>
+ SubType& add(const value_type& x)
+ { that()->template add_<Combinator>(x); return *that(); };
+
+ /// Addition of a base value pair.
+ /** Addition of a base value pair <tt>x := pair(k,y)</tt> where <tt>base_value_type:=pair<DomainT,CodomainT></tt>
+
+ This adds (inserts) a value <tt>y</tt> for a single key <tt>k</tt> into the map.
+ If <tt>k</tt> already has a value <tt>y0</tt> associated with it, <tt>y0</tt>
+ will be incremented by <tt>y</tt> using operator <tt>+=</tt>.
+
+ Addition and subtraction are reversible as follows:
+ <tt>m0=m; m.add(x); m.subtract(x);</tt> implies <tt>m==m0 </tt>
+ */
+ SubType& add(const base_pair_type& x)
+ { return add( value_type(interval_type(x.key), x.data) ); }
+
+ /// Addition of a base value pair.
+ /** Addition of an value pair <tt>x=(I,y)</tt>
+
+ This adds (inserts) a value <tt>y</tt> for an interval <tt>I</tt> into the map.
+
+ If no values are associated already within the range of <tt>I</tt>,
+ <tt>y</tt> will be associated to that interval.
+
+ If there are associated values, in the range of <tt>I</tt>, then all
+ those values within the ranges of their intervals,
+ are incremented by <tt>y</tt>. This is done via operator <tt>+=</tt>
+ which has to be implemented for CodomainT.
+
+ Insertion and subtraction are reversible as follows:
+ <tt>m0=m; m.add(x); m.subtract(x);</tt> implies <tt>m==m0 </tt>
+ */
+ SubType& add(const value_type& x)
+ { that()->template add_<inplace_plus>(x); return *that(); }
+//@}
+
+
+//-----------------------------------------------------------------------------
+/** @name G.sub: Subtraction */
+//@{
+
+ /// Subtraction of an base value pair using a Combinator operation
+ /** Subtraction of an base value pair <tt>x=(k,y)</tt>
+
+ This subtracts a value <tt>y</tt> for a key <tt>k</tt> from the map.
+
+ If there is an associated values \c y0, in for <tt>k</tt>,
+ \c y0 is combined with \c y by <tt>Combinator(y0,y)</tt>.
+
+ A Combinator for subtract is usually an inverse function of
+ the corresponding add<Combinator>.
+ */
+ template<template<class>class Combinator>
+ void subtract(const base_pair_type& x)
+ { that()->template subtract_<Combinator>( value_type(interval_type(x.KEY_VALUE), x.CONT_VALUE) ); }
+
+ /// Subtraction of an interval value pair using a Combinator operation
+ /** Subtraction of an interval value pair <tt>x=(I,y)</tt>
+
+ This subtracts a value <tt>y</tt> for an interval <tt>I</tt> from the map.
+
+ If there are associated values, in the range of <tt>I</tt>, all
+ those values within the ranges of their intervals,
+ are decremented by <tt>y</tt>. This is done via the Combinator function
+ that is passed a template parameter.
+ */
+ template<template<class>class Combinator>
+ void subtract(const value_type& x){ that()->template subtract_<Combinator>(x); }
+
+
+ /// Subtraction of a base value pair.
+ /** Subtraction of a base value pair <tt>x=(k,y)</tt> where <tt>base_value_type:=pair<DomainT,CodomainT></tt>
+
+ This subtracts a value <tt>y</tt> for a single key <tt>k</tt> from the map.
+ If <tt>k</tt> already has a value <tt>y0</tt> associated with it, <tt>y0</tt>
+ will be decremented by <tt>y</tt>: <tt>y0 -= y</tt> via operator <tt>-=</tt>
+ which has to be implemented for CodomainT. If <tt>y</tt> becomes
+ the neutral element CodomainT() <tt>k</tt> will also be removed from
+ the map, if the Traits include the property neutron_absorber.
+
+ Insertion and subtraction are reversible as follows:
+ <tt>m0=m; m.add(x); m.subtract(x);</tt> implies <tt>m==m0 </tt>
+ */
+ SubType& subtract(const base_pair_type& x)
+ {
+ that()->subtract_( value_type(interval_type(x.key), x.data) );
+ return *that();
+ }
+
+
+ /// Subtraction of an interval value pair
+ /** Subtraction of an interval value pair <tt>x=(I,y)</tt>
+
+ This subtracts a value <tt>y</tt> for an interval <tt>I</tt> from the map.
+
+ If there are associated values, in the range of <tt>I</tt>, all
+ those values within the ranges of their intervals,
+ are decremented by <tt>y</tt>. This is done usign operator -=.
+
+ If <tt>y</tt> becomes the neutral element CodomainT() <tt>k</tt> will
+ also be removed from the map, if the Traits include the property
+ neutron_absorber.
+ */
+ SubType& subtract(const value_type& x)
+ {
+ if(Traits::emits_neutrons)
+ that()->template add_<inplace_minus>(x);
+ else
+ that()->template subtract_<inplace_minus>(x);
+
+ return *that();
+ }
+//@}
+
+
+//-----------------------------------------------------------------------------
+/** @name G.ins&ers: Insertion and Erasure */
+//@{
+
+ /// Insertion of a base value pair.
+ /** Insertion of a base value pair <tt>x=(k,y)</tt> where <tt>base_value_type:=pair<DomainT,CodomainT></tt>
+
+ This inserts a value <tt>y</tt> for a single key <tt>k</tt> into the map.
+ Insertion is done only if there is no value \c y0 in the map for key \c k.
+
+ This is the insertion semantics known from std::map::insert.
+ */
+ SubType& insert(const base_pair_type& x)
+ {
+ that()->insert_( value_type(interval_type(x.key), x.data) );
+ return *that();
+ }
+
+ /// Insertion of an interval value pair
+ /** Insertion of an interval value pair <tt>x=(I,y)</tt>
+
+ This inserts a value <tt>y</tt> for an interval <tt>I</tt> into the map.
+ Insertion is done for all sections of interval \c I that are not yet
+ associated with a value.
+
+ This is the insertion semantics known from std::map::insert.
+
+ \c insert(x) is equivalent to \c add<inplace_identity>(x)
+ */
+ SubType& insert(const value_type& x)
+ { that()->insert_(x); return *that(); }
+
+ /// Erase a base value pair from the map
+ /** Erase a base value pair <tt>x=(k,y)</tt>.
+ This does erase a base value pair <tt>x=(k,y)</tt> form the map, if
+ a value \c y is stored for key \c k.
+ */
+ SubType& erase(const base_pair_type& x)
+ {
+ that()->erase_(value_type(interval_type(x.key), x.data));
+ return *that();
+ }
+
+ /// Erase a interval value pair from the map
+ /** Erase a interval value pair <tt>x=(I,y)</tt>.
+ This does erase a interval value pair <tt>x=(I,y)</tt> form the map.
+
+ At all places in the range of interval \c I, where a value of \c y
+ is stored, it will be erased.
+
+ \c erase(x) is equivalent to \c subtract<inplace_erasure>(x)
+ */
+ SubType& erase(const value_type& x)
+ { that()->erase_(x); return *that(); }
+
+
+ /// Erase an associated value for a key
+ /** Erase an associated value <tt>y</tt> for the key <tt>k</tt> from the map.
+
+ Any value \c y that is stored for key \c k will be erased.
+ */
+ SubType& erase(const DomainT& x)
+ { erase(interval_type(x)); return *that(); }
+
+ /// Erase all associated values for an interval
+ /** Erase all associated values within the range of the interval <tt>x</tt>
+ from the map.
+ */
+ SubType& erase(const interval_type& x);
+
+ /// Erase all associated values for a set of intervals
+ /** Erase an entire interval set <tt>x</tt> from the map.
+
+ All values within the scope of the interval set \c x will be erased.
+ */
+ template<class SetSubType>
+ SubType& erase(const interval_base_set<SetSubType,DomainT,Interval,Compare,Alloc>& x)
+ {
+ typedef interval_base_set<SetSubType,DomainT,Interval,Compare,Alloc> interval_base_set_type;
+ for(typename interval_base_set_type::const_iterator x_ = x.begin(); x_ != x.end(); ++x_)
+ erase(*x_);
+
+ return *that();
+ }
+
+ /// Erase an interval map from this interval map
+ /** Erase an entire interval map <tt>x</tt> from the map.
+
+ All values within the scope of the interval map \c x will be erased,
+ If there are equal values associated in \c *this map.
+ */
+ SubType& erase(const interval_base_map& x);
+
+//@}
+
+//-----------------------------------------------------------------------------
+/** @name G.sect: Intersection */
+//@{
+
+ //JODO DOC Intersection with an interval
+ /* Compute the intersection of <tt>*this</tt> and the interval <tt>x</tt>; assign
+ result to the interval map <tt>section</tt>.
+
+ The result of the intersection with an interval has to be a interval map,
+ because a whole set of intervals may exist in <tt>*this</tt> within the range
+ of the interval <tt>x</tt>.
+
+ Use the intersect function to find intervals or elements in an interval map.
+
+ Given
+
+ <tt>split_interval_map<int> x, sec; interval<int> i; fill x; fill i</tt>
+
+ <tt>x.intersect(sec,i);</tt>
+
+ if <tt>i</tt> can be found completely in <tt>x</tt> then
+
+ <tt>sec.size()==1</tt> and <tt>(*sec.begin()).first==i</tt>
+
+ No find function is implemented, because all find operations can be expressed
+ as intersections.
+ */
+
+
+ /// Intersect the sectant with *this. Pass the result to section.
+ template<class SectantT>
+ void intersect(interval_base_map& section, const SectantT& sectant)const
+ {
+ section.clear();
+ add_intersection(section, sectant);
+ }
+
+ void add_intersection(interval_base_map& section, const domain_type& x)const
+ { add_intersection(section, interval_type(x)); }
+
+ void add_intersection(interval_base_map& section, const base_pair_type& x)const
+ { add_intersection(section, value_type(interval_type(x.key), x.data)); }
+
+ /// Intersection with an interval value pair
+ /** Compute an intersection with the value pair \c x=(I,y). The intersection
+ operation is progagated to the associated values: For common intervals
+ the intersection of associated values is stored in the resulting map
+ \c section.
+ */
+ void add_intersection(interval_base_map& section, const value_type& x)const;
+
+ void add_intersection(interval_base_map& section, const interval_type& x)const;
+
+ template
+ <
+ template
+ <
+ class DomT, template<class>class Interv,
+ template<class>class Comp, template<class>class Allc
+ >
+ class IntervalSet
+ >
+ void add_intersection
+ (
+ interval_base_map& section,
+ const IntervalSet<DomainT,Interval,Compare,Alloc>& sectant
+ )const
+ {
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> set_type;
+ if(sectant.empty()) return;
+
+ // THINK JODO optimize using the ordering: if intervalls are beyond borders we can terminate
+ typename set_type::const_iterator it = sectant.begin();
+ while(it != sectant.end())
+ add_intersection(section, *it++);
+ }
+
+
+ /// Intersection with an interval map
+ /** Compute the intersection of <tt>*this</tt> and the interval map <tt>x</tt>;
+ assign result to the interval map <tt>section</tt>. */
+ template
+ <
+ template
+ <
+ class DomT, class CodomT,
+ class Trts, template<class>class Interv,
+ template<class>class Comp, template<class>class Allc
+ >
+ class IntervalMap
+ >
+ void add_intersection
+ (
+ interval_base_map& intersection,
+ const IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>& sectant
+ )const;
+
+//@}
+
+
+ iterator lower_bound(const key_type& interval)
+ { return _map.lower_bound(interval); }
+
+ iterator upper_bound(const key_type& interval)
+ { return _map.upper_bound(interval); }
+
+ const_iterator lower_bound(const key_type& interval)const
+ { return _map.lower_bound(interval); }
+
+ const_iterator upper_bound(const key_type& interval)const
+ { return _map.upper_bound(interval); }
+
+
+//-----------------------------------------------------------------------------
+/** @name H.mor: Morphic modifiers */
+//@{
+
+ /// Removal of neutral element values
+ /** All value pairs \c (I,y) that have neutral elements \c y==codomain_type()
+ as associated values are removed form the map.
+ */
+ void absorb_neutrons()
+ {
+ //content_is_neutron<key_type, data_type> neutron_dropper;
+ if(!Traits::absorbs_neutrons)
+ erase_if<content_is_neutron>();
+ }
+
+ /// Copies this map into a neutron_absorber type.
+ /** \c x is a copy of \c *this as a neutron_aborber.
+ A neutron absorber is a map that does not store neutral elements
+ (<tt>neutron() == codomain_type()</tt>)
+ as associated values.
+ */
+ void as_neutron_absorber(neutron_absorber_type& x)const
+ { FOR_IMPLMAP(it) x.add(*it); }
+
+ /// Join bounding intervals
+ interval_base_map& join();
+
+
+ /// Gives the domain of the map as interval set
+ template
+ <
+ template
+ <
+ class DomT, template<class>class Interv,
+ template<class>class Comp, template<class>class Allc
+ >
+ class IntervalSet
+ >
+ void domain(IntervalSet<DomainT,Interval,Compare,Alloc>& dom)const
+ {
+ dom.clear();
+ const_FOR_IMPLMAP(it)
+ dom += (*it).KEY_VALUE;
+ }
+//@}
+
+
+
+/** @name I: Interval search
+ */
+//@{
+ /** A find function has <b>NOT</b> been implemented; Use \ref intersect
+ as a generalized find operation on interval maps.
+
+ All find operations can be expressed by means of intersection \ref intersect
+ or \ref operator *=. Searching for an interval in an interval map yields
+ an interval map anyway in the general case.
+ */
+//@}
+
+
+/** @name J: Interval iterators
+ */
+//@{
+ ///
+ iterator begin() { return _map.begin(); }
+ ///
+ iterator end() { return _map.end(); }
+ ///
+ const_iterator begin()const { return _map.begin(); }
+ ///
+ const_iterator end()const { return _map.end(); }
+ ///
+ reverse_iterator rbegin() { return _map.rbegin(); }
+ ///
+ reverse_iterator rend() { return _map.rend(); }
+ ///
+ const_reverse_iterator rbegin()const { return _map.rbegin(); }
+ ///
+ const_reverse_iterator rend()const { return _map.rend(); }
+//@}
+
+
+
+/** @name K: Selection by predicates
+ */
+//@{
+ /// Remove all elements where property <tt>p</tt> holds, keep all others
+ template<template<class>class Predicate>
+ interval_base_map& erase_if(){ _map.erase_if<Predicate>(); return *this; }
+
+ /// Copy all elements if property <tt>p</tt> holds
+ template<template<class>class Predicate>
+ interval_base_map& assign_if(const interval_base_map& src)
+ { _map.assign_if<Predicate>(src._map); return *this; }
+
+//@}
+
+
+/** @name S: String representation
+ */
+//@{
+ /** Convert the interval map to string (c.f. \ref value)
+
+ This string converter is based on a general converter function <tt>as_string</tt>
+ and the template class \ref value which serves as base for string
+ representation.
+ */
+ std::string as_string() const;
+//@}
+
+/** @name T: For discrete domain datatypes only that implement operators <tt>++</tt>
+ and <tt>--</tt>
+ */
+//@{
+
+ /** Smallest element of the map (wrt. the partial ordering on DomainT).
+ first() does not exist for continuous datatypes and open interval bounds.
+ */
+ DomainT first()const { return (*(_map.begin())).KEY_VALUE.first(); } // JODO NONCONT
+
+ /** Largest element of the map (wrt. the partial ordering on DomainT).
+ first() does not exist for continuous datatypes and open interval bounds.
+ */
+ DomainT last()const { return (*(_map.rbegin())).KEY_VALUE.last(); } // JODO NONCONT
+
+
+ /** Sum of associated elements of the map
+ <b>Nicht getestet</b> */
+ CodomainT sum()const;
+
+ /** Set interval bounds to the type <tt>bt</tt> for intervals in the map.
+
+ Interval bounds of different types are created by opeations on
+ interval maps. This function allows to reset them uniformly without,
+ of course, changing their value. This is only possible for discrete
+ domain datatypes.
+ */
+ void uniformBounds( typename interval<DomainT>::bound_types bt);
+
+ void closeLeftBounds();
+//@}
+
+ void recJoin();
+
+
+ template<typename IteratorT>
+ static const key_type& key_value(IteratorT& value_){ return (*value_).first; }
+
+ template<typename IteratorT>
+ static const data_type& data_value(IteratorT& value_){ return (*value_).second; }
+
+ template<typename IteratorT>
+ static codomain_type codomain_value(IteratorT& value_){ return (*value_).second; }
+
+ template<typename LeftIterT, typename RightIterT>
+ static bool key_less(LeftIterT& lhs_, RightIterT& rhs_) { return key_compare()((*lhs_).first, (*rhs_).first); }
+
+ static value_type make_domain_element(const domain_type& dom_val, const codomain_type& codom_val)
+ { return value_type(interval_type(dom_val), codom_val); }
+
+protected:
+ sub_type* that() { return static_cast<sub_type*>(this); }
+ const sub_type* that()const { return static_cast<const sub_type*>(this); }
+
+protected:
+ ImplMapT _map;
+} ;
+
+
+
+template
+<
+ class SubType, class DomainT, class CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare,
+ template<class>class Alloc
+>
+typename interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc>::size_type
+interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc>::cardinality()const
+{
+ using namespace boost::mpl;
+ return if_<
+ bool_<is_continuous<DomainT>::value>,
+ continuous_interval_container,
+ discrete_interval_container
+ >
+ ::type::cardinality(*this);
+}
+
+template
+<
+ class SubType, class DomainT, class CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare,
+ template<class>class Alloc
+>
+typename interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc>::difference_type
+interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc>::length()const
+{
+ difference_type length = neutron<difference_type>::value();
+ const_FOR_IMPLMAP(it)
+ length += (*it).KEY_VALUE.length();
+ return length;
+}
+
+
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+bool interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>::contained_in(const interval_base_map& super)const
+{
+ // x2 should be larger than *this; so every element in this should be in x2
+ const_FOR_IMPLMAP(it)
+ if(!super.that()->contains_(*it))
+ return false;
+ return true;
+}
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+ template
+ <
+ template
+ <
+ class DomT, class CodomT,
+ class Trts, template<class>class Interv,
+ template<class>class Comp, template<class>class Allc
+ >
+ class IntervalMap
+ >
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_intersection
+(
+ interval_base_map& intersection,
+ const IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>& sectant
+)const
+{
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> sectant_type;
+ if(sectant.empty())
+ return;
+ typename sectant_type::const_iterator common_lwb;
+ typename sectant_type::const_iterator common_upb;
+ if(!Set::common_range(common_lwb, common_upb, sectant, *this))
+ return;
+ typename sectant_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ add_intersection(intersection, *it++);
+}
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_intersection(interval_base_map& section,
+ const typename interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::value_type& sectant)const
+{
+ interval_type sectant_interval = sectant.KEY_VALUE;
+ if(sectant_interval.empty()) return;
+
+ typename ImplMapT::const_iterator fst_it = _map.lower_bound(sectant_interval);
+ typename ImplMapT::const_iterator end_it = _map.upper_bound(sectant_interval);
+
+ for(typename ImplMapT::const_iterator it=fst_it; it != end_it; it++)
+ {
+ interval_type common_interval;
+ (*it).KEY_VALUE.intersect(common_interval, sectant_interval);
+
+ if(!common_interval.empty())
+ {
+ section.that()->add( value_type(common_interval, (*it).CONT_VALUE) );
+ if(is_set<CodomainT>::value)
+ section.that()->add<inplace_star>( value_type(common_interval, sectant.CONT_VALUE) );
+ else
+ section.that()->add<inplace_plus>( value_type(common_interval, sectant.CONT_VALUE) );
+ //section.that()->add<inplace_identity>( value_type(common_interval, sectant.CONT_VALUE) );
+ }
+ }
+}
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_intersection(interval_base_map& section,
+ const typename interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::interval_type& sectant_interval)const
+{
+ if(sectant_interval.empty()) return;
+
+ typename ImplMapT::const_iterator fst_it = _map.lower_bound(sectant_interval);
+ typename ImplMapT::const_iterator end_it = _map.upper_bound(sectant_interval);
+
+ for(typename ImplMapT::const_iterator it=fst_it; it != end_it; it++)
+ {
+ interval_type common_interval;
+ (*it).KEY_VALUE.intersect(common_interval, sectant_interval);
+
+ if(!common_interval.empty())
+ section.that()->add( value_type(common_interval, (*it).CONT_VALUE) );
+ }
+}
+
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::join()
+{
+ iterator it=_map.begin();
+ if(it==_map.end())
+ return *this;
+
+ iterator nxt=it; nxt++;
+ if(nxt==_map.end())
+ return *this;
+
+ while(nxt != _map.end())
+ {
+ if( (*it).KEY_VALUE.touches((*nxt).KEY_VALUE)
+ && (*it).CONT_VALUE == (*nxt).CONT_VALUE )
+ {
+ iterator fst_mem = it; // hold the fist member
+
+ // go noodling on while touchin members found
+ it++; nxt++;
+ while( nxt != _map.end()
+ && (*it).KEY_VALUE.touches((*nxt).KEY_VALUE)
+ && (*it).CONT_VALUE == (*nxt).CONT_VALUE ) //CodomainT::OP ==
+ { it++; nxt++; }
+
+ // finally we arrive at the end of a sequence of joinable intervals
+ // and it points to the last member of that sequence
+ iterator lst_mem = it, end_mem = nxt;
+ interval_type joinedInterval((*fst_mem).KEY_VALUE);
+ joinedInterval.extend((*lst_mem).KEY_VALUE);
+ CodomainT value = (*fst_mem).CONT_VALUE; //CodomainT::OP =
+
+ _map.erase(fst_mem, end_mem);
+ it = _map.insert(value_type(joinedInterval, value)).ITERATOR;
+
+ it++; // go on for the next after the currently inserted
+ nxt=it; if(nxt!=_map.end())nxt++;
+ }
+ else { it++; nxt++; }
+ }
+ return *this;
+}
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+std::string interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>::as_string()const
+{
+ std::string res("");
+ const_FOR_IMPLMAP(it) {
+ std::string cur("(");
+ cur += (*it).KEY_VALUE.as_string();
+ cur += ",";
+ cur += itl::to_string<CodomainT>::apply((*it).CONT_VALUE);
+ cur += ")";
+ res += cur;
+ }
+ return res;
+}
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+CodomainT interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>::sum()const
+{
+ CodomainT sum = CodomainT();
+ const_FOR_IMPLMAP(it)
+ sum += (*it).CONT_VALUE;
+ return sum;
+}
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>::uniformBounds( typename interval<DomainT>::bound_types bt)
+{
+ // I can do this only, because I am shure that the contents and the
+ // ordering < on interval is invariant wrt. this transformation on bounds
+ FOR_IMPLMAP(it) const_cast<interval_type&>((*it).KEY_VALUE).transformBounds(bt);
+}
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>::closeLeftBounds()
+{
+ // I can do this only, because I am shure that the contents and the
+ // ordering < on interval is invariant wrt. this transformation on bounds
+ FOR_IMPLMAP(it) const_cast<interval_type&>((*it).KEY_VALUE).closeLeftBound();
+}
+
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+SubType& interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::erase(const interval_type& x_itv)
+{
+ if(x_itv.empty()) return *that();
+ iterator fst_it = _map.lower_bound(x_itv);
+ if(fst_it==_map.end()) return *that();
+ iterator end_it = _map.upper_bound(x_itv);
+
+ typename ImplMapT::iterator it=fst_it, nxt_it=fst_it, victim;
+ interval_type leftResid; // left residual from first overlapping interval of *this
+ (*it).KEY_VALUE.left_surplus(leftResid,x_itv);
+ interval_type rightResid; // right residual from last overlapping interval of *this
+
+ CodomainT leftResid_ContVal = (*it).CONT_VALUE;
+ CodomainT rightResid_ContVal;
+
+ while(it!=end_it)
+ {
+ if((++nxt_it)==end_it)
+ {
+ (*it).KEY_VALUE.right_surplus(rightResid,x_itv);
+ rightResid_ContVal = (*it).CONT_VALUE;
+ }
+ victim = it; it++; _map.erase(victim);
+ }
+
+ that()->add_(value_type(leftResid, leftResid_ContVal));
+ that()->add_(value_type(rightResid, rightResid_ContVal));
+
+ return *that();
+}
+
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+SubType&
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::erase(const interval_base_map& erasure)
+{
+ const_FORALL(typename interval_base_map, value_pair_, erasure)
+ that()->erase_(*value_pair_);
+
+ return *that();
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+// itl::global function templates
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// equality
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+inline bool operator == (const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& lhs,
+ const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& rhs)
+{
+ //MEMO PORT: This implemetation worked with stlport, sgi and gnu
+ // implementations of the stl. But using MSVC-implementation
+ // results in runtime error! So I had to provide an independent
+ // safe implemetation.
+ //return std::equal(lhs.begin(), lhs.end(), rhs.begin());
+ return Set::lexicographical_equal(lhs, rhs);
+}
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+inline bool is_protonic_equal(const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& lhs,
+ const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& rhs)
+{
+ interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc> lhs0 = lhs;
+ interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc> rhs0 = rhs;
+
+ lhs0.absorb_neutrons();
+ rhs0.absorb_neutrons();
+
+ return Set::lexicographical_equal(lhs0, rhs0);
+}
+
+
+//-----------------------------------------------------------------------------
+// order
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+inline bool operator < (const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& lhs,
+ const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& rhs)
+{
+ return std::lexicographical_compare(
+ lhs.begin(), lhs.end(), rhs.begin(), rhs.end(),
+ Compare<std::pair<Interval<DomainT>, CodomainT> >()
+ );
+}
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc
+>
+inline bool operator <= (const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& lhs,
+ const interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>& rhs)
+{
+ return lhs < rhs || lhs == rhs;
+}
+
+//-----------------------------------------------------------------------------
+// min, max
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType,
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>&
+min_assign
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc> map_type;
+ const_FORALL(typename map_type, elem_, operand)
+ object.template add<inplace_min >(*elem_);
+
+ return object;
+}
+
+template
+<
+ class SubType,
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>&
+max_assign
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc> map_type;
+ const_FORALL(typename map_type, elem_, operand)
+ object.template add<inplace_max>(*elem_);
+
+ return object;
+}
+
+//---------------------------------------------------------------------------------
+
+template<class CharType, class CharTraits,
+ class SubType, class DomainT, class CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare,
+ template<class>class Alloc>
+std::basic_ostream<CharType, CharTraits>& operator <<
+ (std::basic_ostream<CharType, CharTraits>& stream,
+ const interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc>& object)
+{
+ typedef interval_base_map<SubType,DomainT,CodomainT,Traits,
+ Interval,Compare,Alloc> IntervalMapT;
+ stream << "{";
+ const_FORALL(typename IntervalMapT, it, object)
+ stream << "(" << (*it).KEY_VALUE << "->" << (*it).CONT_VALUE << ")";
+
+ return stream << "}";
+}
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,635 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------+
+class interval_base_set
++----------------------------------------------------------------------------*/
+#ifndef __interval_base_set_h_JOFA_990223__
+#define __interval_base_set_h_JOFA_990223__
+
+#include <limits>
+#include <boost/itl/interval_set_algo.hpp>
+#include <boost/itl/set.hpp>
+#include <boost/itl/interval.hpp>
+#include <boost/itl/notate.hpp>
+
+#define const_FOR_IMPL(iter) for(typename ImplSetT::const_iterator iter=_set.begin(); (iter)!=_set.end(); (iter)++)
+#define FOR_IMPL(iter) for(typename ImplSetT::iterator iter=_set.begin(); (iter)!=_set.end(); (iter)++)
+
+
+namespace boost{namespace itl
+{
+
+//JODO update documentation (all invterval containers; template parameters have changed)
+/// Implements a set as a set of intervals (base class)
+/**
+ Abstract template-class <b>interval_base_set</b>
+ implements a set as a set of intervals
+
+ Template parameter <b>DomainT</b>: The set's domain-type. Type of the
+ set's elements.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Template parameter <b>Interval=itl::interval</b>: Type of interval used
+ to implement the set. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>interval_base_set</b> implements a set <tt>set<DomainT></tt> as a set of intervals
+ <tt>set<interval<DomainT>></tt>.
+
+ interval_base_set<DomainT> can thus be used like a set. As it is known from mathematics
+ the union over a set of intervls is a set itself.
+
+ <b>Class <tt>interval_base_set</tt> yields the following benefits: </b>
+
+ <ul>
+ <li>
+ A set of intervals is conceived as a set. The complexity involved with
+ operations on intervals and sets of intervals is encapsulated.
+ The user of the class who
+ wants to perform set operations on sets of intervals is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_base_set</b> gives an efficient implementation of sets consisting
+ of larger contiguous chunks. Very large, even uncountably infinite sets of
+ elements can be represented in a compact way and handled efficiently.
+ </ul>
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+
+ These functions are tagged in the documentation. Using such functions
+ for continuous domain datatypes yields compiletime errors. C.f. getting
+ the <tt>first()</tt> element of a left open interval makes sense for intervals of
+ int but not for intervals of double.
+
+ @author Joachim Faulhaber
+*/
+template
+<
+ typename SubType,
+ typename DomainT,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+>
+#ifdef USE_CONCEPTS
+ requires {std::LessThanComparable<DomainT>}
+#endif
+class interval_base_set
+{
+public:
+
+ //A: Type definitions for the template class
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> type;
+
+ /// The designated \e derived or \e sub_type of this base class
+ typedef SubType sub_type;
+
+ /// The domain type of the set
+ typedef DomainT domain_type;
+ /// The codomaintype is the same as domain_type
+ typedef DomainT codomain_type;
+
+ /// The interval type of the set
+ typedef Interval<DomainT> interval_type;
+
+ /// The difference type of an interval which is sometimes different form the data_type
+ typedef typename interval_type::difference_type difference_type;
+
+ /// The size type of an interval which is mostly std::size_t
+ typedef typename interval_type::size_type size_type;
+
+
+ /// Comparison functor for domain values
+ typedef Compare<DomainT> domain_compare;
+ /// Comparison functor for intervals
+ typedef exclusive_less<interval_type> interval_compare;
+
+ /// Comparison functor for keys
+ typedef exclusive_less<interval_type> key_compare;
+
+ /// The allocator type of the set
+ typedef Alloc<interval_type> allocator_type;
+
+ /// allocator type of the corresponding element set
+ typedef Alloc<DomainT> domain_allocator_type;
+
+ /// The type of the set of elements that is equivalent to the set of intervals
+ typedef typename itl::set<DomainT,Compare,Alloc> element_set;
+
+ /// The corresponding atomized type representing this interval container of elements
+ typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
+
+ /// Container type for the implementation
+ typedef typename itl::set<interval_type,exclusive_less,Alloc> ImplSetT;
+
+ /// key type of the implementing container
+ typedef typename ImplSetT::key_type key_type;
+ /// data type of the implementing container
+ typedef typename ImplSetT::data_type data_type;
+ /// value type of the implementing container
+ typedef typename ImplSetT::value_type value_type;
+
+ /// iterator for iteration over intervals
+ typedef typename ImplSetT::iterator iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplSetT::const_iterator const_iterator;
+ /// iterator for reverse iteration over intervals
+ typedef typename ImplSetT::reverse_iterator reverse_iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplSetT::const_reverse_iterator const_reverse_iterator;
+
+
+ // B: Constructors, destructors, assignment
+ /// Default constructor for the empty set
+ interval_base_set(){}
+ /// Copy constructor
+ interval_base_set(const interval_base_set& src): _set()
+ { that()->assign(src); }
+
+ /// Assignment operator
+ interval_base_set& operator = (const interval_base_set& src)
+ {
+ if(this==&src)
+ return *this;
+
+ that()->assign(src);
+ return *this;
+ }
+
+ void swap(interval_base_set& x) { _set.swap(x._set); }
+
+ // ------------------------------------------------------------------------
+ // Basic set concept
+ // C:
+
+ /// sets the container empty
+ void clear() { _set.clear(); }
+ /// is the container empty
+ bool empty()const { return _set.empty(); }
+
+ /// Does the container contain the element \c x
+ bool contains(const DomainT& x)const
+ { return that()->contains_(interval_type(x)); }
+
+ /// Does the container contain the interval x
+ bool contains(const interval_type& x)const
+ { return that()->contains_(x); }
+
+ /** Does <tt>*this</tt> container contain <tt>sub</tt>? */
+ bool contains(const interval_base_set& sub)const
+ { return sub.contained_in(*this); }
+
+ /** Is <tt>*this</tt> contained in <tt>super</tt>? */
+ bool contained_in(const interval_base_set& super)const;
+
+/** @name E: Bounds and other selectors
+ */
+//@{
+ /// lower bound of all intervals in the set
+ DomainT lower()const
+ { return empty()? Interval<DomainT>().lower() : (*(_set.begin())).lower(); }
+ /// upper bound of all intervals in the set
+ DomainT upper()const
+ { return empty()? Interval<DomainT>().upper() : (*(_set.rbegin())).upper(); }
+
+ iterator lower_bound(const value_type& interval)
+ { return _set.lower_bound(interval); }
+
+ iterator upper_bound(const value_type& interval)
+ { return _set.upper_bound(interval); }
+
+ const_iterator lower_bound(const value_type& interval)const
+ { return _set.lower_bound(interval); }
+
+ const_iterator upper_bound(const value_type& interval)const
+ { return _set.upper_bound(interval); }
+
+ /// number of intervals
+ std::size_t interval_count()const { return _set.size(); }
+ std::size_t iterative_size()const { return _set.size(); }
+//@}
+
+
+//-----------------------------------------------------------------------------
+/** @name G.add: Addition */
+//@{
+
+ /// Add a single element \c x to the set
+ SubType& add(const DomainT& x)
+ { that()->add_(interval_type(x)); return *that(); }
+
+ /// Add an interval of elements \c x to the set
+ SubType& add(const value_type& x)
+ { that()->add_(x); return *that(); }
+
+//@}
+
+//-----------------------------------------------------------------------------
+/** @name G.sub: Subtraction */
+//@{
+
+ /// Subtract a single element \c x from the set
+ SubType& subtract(const DomainT& x)
+ { that()->subtract_(interval_type(x)); return *that(); }
+
+ /// Subtract an interval of elements \c x from the set
+ SubType& subtract(const value_type& x)
+ { that()->subtract_(x); return *that(); }
+
+ ///// Subtract a single element \c x from the set
+ //interval_base_set& operator -= (const DomainT& x)
+ //{ subtract(x); return *this; }
+
+ ///// Subtract an interval of elements \c x from the set
+ //interval_base_set& operator -= (const value_type& x)
+ //{ that()->subtract(x); return *this; }
+
+//@}
+
+//-----------------------------------------------------------------------------
+/** @name G.ins&ers: Insertion and erasure */
+//@{
+ /// Insert an element \c x into the set
+ SubType& insert(const DomainT& x)
+ { return add(interval_type(x)); }
+
+ /// Insert an interval of elements \c x to the set
+ SubType& insert(const value_type& x)
+ { return add(x); }
+
+ /// Erase an element \c x from the set
+ SubType& erase(const DomainT& x)
+ { return subtract(interval_type(x)); }
+
+ /// Erase an interval of element \c x from the set
+ SubType& erase(const value_type& x)
+ { return subtract(x); }
+//@}
+
+//-----------------------------------------------------------------------------
+/** @name G.sect: Intersection */
+//@{
+
+ /*JODO DOC Intersection with interval x; The intersection is assigned to <tt>section</tt>.
+
+ Intersection also serves a generalized <tt>find</tt>-function to search
+ for intervals in the set:
+
+ <tt>ItvSetT<int> x, sec; interval<int> i; fill x; fill i;</tt>
+
+ <tt>x.intersect(sec,i);</tt>
+
+ If <tt>i</tt> is an interval of <tt>x</tt>, then
+
+ <tt>sec.nOfIntervals()==1</tt> and <tt>*(sec.begin())==x</tt>
+ */
+ //CL void intersect(interval_base_set& section, const value_type& x)const;
+
+ //JODO DOC; welche intersect-varianten kann ich ganz los werden.
+ void add_intersection(interval_base_set& section, const value_type& x)const;
+
+ //JODO doku
+ /** Perform intersection of <tt>*this</tt> and <tt>x</tt>; assign result
+ to <tt>section</tt>
+ */
+
+ /** Perform intersection of <tt>*this</tt> and <tt>x</tt>; assign result
+ to <tt>*this</tt>
+
+ Aufruf <tt>x *= y</tt> bedeutet <tt>x = x geschnitten mit y </tt>
+ */
+//@}
+
+//-----------------------------------------------------------------------------
+/** @name G.jodo: JODO */
+
+ /// Join bordering intervals
+ interval_base_set& join();
+
+//@}
+
+
+
+/** @name I: Interval iterators
+ */
+//@{
+ ///
+ iterator begin() { return _set.begin(); }
+ ///
+ iterator end() { return _set.end(); }
+ ///
+ const_iterator begin()const { return _set.begin(); }
+ ///
+ const_iterator end()const { return _set.end(); }
+ ///
+ reverse_iterator rbegin() { return _set.rbegin(); }
+ ///
+ reverse_iterator rend() { return _set.rend(); }
+ ///
+ const_reverse_iterator rbegin()const { return _set.rbegin(); }
+ ///
+ const_reverse_iterator rend()const { return _set.rend(); }
+//@}
+
+
+
+/** @name S: String representation
+ */
+//@{
+ /// Interval-set as string
+ const std::string as_string()const
+ { std::string res(""); const_FOR_IMPL(it) res += (*it).as_string(); return res; }
+//@}
+
+
+/** @name T: For discrete domain datatypes only that implement operators <tt>++</tt>
+ and <tt>--</tt>
+ */
+//@{
+ /** Smallest element of the set (wrt. the partial ordering on DomainT).
+ first() does not exist for continuous datatypes and open interval bounds.
+ */
+ DomainT first()const { return (*(_set.begin())).first(); } // JODO NONCONT
+
+ /** Largest element of the set (wrt. the partial ordering on DomainT).
+ first() does not exist for continuous datatypes and open interval bounds.
+ */
+ DomainT last()const { return (*(_set.rbegin())).last(); } // JODO NONCONT
+
+ /** Number of elements in the set (cardinality).
+ Infinite for continuous domain datatyps */
+ size_type cardinality()const;
+
+ /// An interval set's size is it's cardinality
+ size_type size()const { return cardinality(); }
+
+ difference_type length()const;
+
+ /** Set interval bounds to the type <tt>bt</tt> for intervals in the set.
+
+ Interval bounds of different types are created by opeations on
+ interval sets. This function allows to reset them uniformly without,
+ of course, changing their value. This is only possible for discrete
+ domain datatypes.
+ */
+ void uniform_bounds(typename interval<DomainT>::bound_types bt);
+
+//@}
+
+
+ template<typename IteratorT>
+ static const key_type& key_value(IteratorT& value_){ return (*value_); }
+
+ template<typename IteratorT>
+ static codomain_type codomain_value(IteratorT& value_)
+ { return (*value_).empty()? codomain_type() : (*value_).first(); }
+
+ template<typename LeftIterT, typename RightIterT>
+ static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
+ { return key_compare()(*lhs_, *rhs_); }
+
+ static value_type make_domain_element(const domain_type& dom_val, const codomain_type& codom_val)
+ { return value_type(interval_type(dom_val)); }
+
+protected:
+ sub_type* that() { return static_cast<sub_type*>(this); }
+ const sub_type* that()const { return static_cast<const sub_type*>(this); }
+
+protected:
+ ImplSetT _set;
+} ;
+
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+typename interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::size_type
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::cardinality()const
+{
+ using namespace boost::mpl;
+ return if_<
+ bool_<is_continuous<DomainT>::value>,
+ continuous_interval_container,
+ discrete_interval_container
+ >
+ ::type::cardinality(*this);
+
+ /*JODO BOOST: This more simple implementention fails because ptime::duration has no infinity
+ size_type size = neutron<size_type>::value();
+ size_type interval_size;
+ const_FOR_IMPL(it)
+ {
+ interval_size = (*it).cardinality();
+ if(interval_size == std::numeric_limits<size_type>::infinity())
+ return interval_size;
+ else
+ size += interval_size;
+ }
+ return size;
+ */
+}
+
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+typename
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::difference_type
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::length()const
+{
+ difference_type length = neutron<difference_type>::value();
+ const_FOR_IMPL(it)
+ length += (*it).length();
+ return length;
+}
+
+
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+bool interval_base_set<SubType,DomainT,Interval,Compare,Alloc>
+ ::contained_in(const interval_base_set& x2)const
+{
+ // The empty set is subset of every set
+ if(empty())
+ return true;
+ else if (x2.empty())
+ return false;
+ else if(upper() < x2.lower())
+ return false;
+ else if(x2.upper() < lower())
+ return false;
+ else
+ {
+ // x2 should be larger than *this; so every element in this should be in x2
+ const_FOR_IMPL(it)
+ if(!x2.that()->contains_(*it))
+ return false;
+ return true;
+ }
+}
+
+
+template<class SubType,
+ class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::add_intersection(interval_base_set& section, const value_type& x)const
+{
+ // any intersection with the empty intervall is empty
+ if(x.empty())
+ return;
+
+ typename ImplSetT::const_iterator fst_it = _set.lower_bound(x);
+ typename ImplSetT::const_iterator end_it = _set.upper_bound(x);
+
+ for(typename ImplSetT::const_iterator it=fst_it; it != end_it; it++)
+ {
+ interval_type isec;
+ (*it).intersect(isec, x);
+ section.add(isec);
+ }
+}
+
+
+template<class SubType,
+ class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::join()
+{
+ iterator it=_set.begin();
+ if(it==_set.end())
+ return *this;
+
+ iterator nxt=it; nxt++;
+ if(nxt==_set.end())
+ return *this;
+
+ while(nxt != _set.end())
+ {
+ if( (*it).touches(*nxt) )
+ {
+ iterator fst_mem = it; // hold the fist member
+
+ // go noodling on while touchin members found
+ it++; nxt++;
+ while( nxt != _set.end()
+ && (*it).touches(*nxt) )
+ { it++; nxt++; }
+
+ // finally we arrive at the end of a sequence of joinable intervals
+ // and it points to the last member of that sequence
+ iterator lst_mem = it, end_mem = nxt;
+ interval_type joinedInterval(*fst_mem);
+ joinedInterval.extend(*lst_mem);
+
+ _set.erase(fst_mem, end_mem);
+ it = _set.insert(joinedInterval).ITERATOR;
+
+ it++; // go on for the next after the currently inserted
+ nxt=it; if(nxt!=_set.end())nxt++;
+ }
+ else { it++; nxt++; }
+ }
+ return *this;
+}
+
+
+
+template<class SubType,
+ class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_base_set<SubType,DomainT,Interval,Compare,Alloc>::uniform_bounds(typename interval<DomainT>::bound_types bt)
+{
+ // I can do this only, because I am shure that the contents and the
+ // ordering < on interval is invariant wrt. this transformation on bounds
+ FOR_IMPL(it) const_cast<interval_type&>(*it).transform_bounds(bt);
+}
+
+
+template<class SubType,
+ class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+inline bool operator == (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& lhs,
+ const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& rhs)
+{
+ //MEMO PORT: This implemetation worked with stlport, sgi and gnu
+ // implementations of the stl. But using MSVC-implementation
+ // results in runtime error! So I had to provide an independent
+ // safe implemetation.
+ //return std::equal(lhs.begin(), lhs.end(), rhs.begin());
+ return Set::lexicographical_equal(lhs, rhs);
+}
+
+template<class SubType,
+ class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+inline bool operator < (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& lhs,
+ const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& rhs)
+{
+ return std::lexicographical_compare(
+ lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), Compare<Interval<DomainT> >());
+}
+
+template<class SubType,
+ class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+inline bool operator <= (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& lhs,
+ const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& rhs)
+{
+ return lhs < rhs || lhs == rhs;
+}
+
+
+template<class CharType, class CharTraits,
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+std::basic_ostream<CharType, CharTraits>& operator <<
+ (std::basic_ostream<CharType, CharTraits>& stream,
+ const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object)
+{
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> IntervalSetT;
+ stream << "{";
+ const_FORALL(typename IntervalSetT, it, object)
+ stream << (*it);
+
+ return stream << "}";
+}
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/interval_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_map.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,1056 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+/* ------------------------------------------------------------------
+class interval_map
+--------------------------------------------------------------------*/
+#ifndef __interval_map_h_JOFA_080705__
+#define __interval_map_h_JOFA_080705__
+
+#include <boost/assert.hpp>
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl/interval_base_map.hpp>
+#include <boost/itl/interval_maps.hpp>
+
+namespace boost{namespace itl
+{
+
+/// implements a map as a map of intervals - on insertion overlapping intervals are split and associated values are combined.
+/**
+ Template-class <b>interval_map</b>
+ implements a map as a map of intervals - On insertion overlapping intervals are
+ <b>split</b> and associated values are combined.
+
+ Template parameter <b>DomainT</b>: Domain type of the map. Also type of the
+ map's keys.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Datatypes for the codomain parameter have to <b>implement</b> operations
+ <tt>+=</tt>, <tt>-=</tt>, <tt>==</tt> (equality) and <tt>CodomainT()</tt> (default constructor).
+
+ The default constructor <tt>CodomainT()</tt> has to contruct a neutral element
+ such that the following holds:
+
+ If <tt>x = y; y += CodomainT();</tt> then <tt>x==y;</tt> and
+ If <tt>x = y; y -= CodomainT();</tt> then <tt>x==y;</tt>
+
+ Template parameter <b>Interval=itl::interval</b>: Template type of interval used
+ to implement the map. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>interval_map</b> implements a map <tt>map<DomainT, CodomainT></tt> as a map
+ of intervals <tt>map<interval<DomainT>, CodomainT, ExclusiveLessT<Interval> ></tt>
+
+ Interval maps <tt>interval_map<DomainT,CodomainT></tt> can be used similar (and in many
+ aspects exactly like) common stl-maps. Unlike to stl-maps where you store
+ a value for every key an interval map stores a contents value for an interval of
+ keys. In it's degenerated form the key intervals contain a single element
+ only. Then the interval map works like a normal stl-map. But if you work in problem
+ domains where you associate values to large contiguous intervals, interval maps
+ are very useful and efficient.
+
+
+ Class <tt>interval_base_map</tt> yields the following benefits:
+
+ <ul>
+ <li> A set of intervals is conceived as the domain set of the map.
+ The complexity involved with
+ operations on intervals maps is encapsulated. The user of the class who
+ wants to perform operations on interval maps is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_map</b> gives an efficient implementation of maps consisting
+ of larger contiguous chunks. Very large, even uncountably infinite maps
+ can be represented in a compact way and handled efficiently.
+ <li>
+ <b>interval_map</b> serves as a overlay- or collision-computer.
+ </ul>
+
+ <b>interval_map as overlay computer</b>
+
+ An object <tt>interval_map<int,int> overlays;</tt> computes the overlays or
+ collisions of intervalls which have been inserted into it, if they are
+ associated with the <tt>int</tt>-value <tt>1</tt> as the codommain value.
+
+ If a newly inserted interval overlaps with intervals which are already in the
+ map, the interval is split up at the borders of the collisions. The assiciated
+ values of the overlapping intervals are incremented by 1, thus counting
+ the numbers of overlaps.
+
+ If sets are used as codomain types, interval_maps will compute unions of
+ associated maps in case of interval collisions.
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+
+ These functions are tagged in the documentation. Using such functions
+ for continuous domain datatypes yields compiletime errors. C.f. getting
+ the <tt>first()</tt> element of a left open interval makes sense for intervals of
+ int but not for intervals of double.
+
+ @author Joachim Faulhaber
+*/
+template
+<
+ typename DomainT,
+ typename CodomainT,
+ class Traits = itl::neutron_absorber,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+>
+class interval_map:
+ public interval_base_map<interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>,
+ DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+{
+public:
+ typedef Traits traits;
+ typedef interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc> type;
+ typedef type joint_type;
+ typedef interval_base_map <interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>,
+ DomainT,CodomainT,Traits,Interval,Compare,Alloc> base_type;
+
+ typedef interval_map<DomainT,CodomainT,itl::neutron_absorber,Interval,Compare,Alloc>
+ neutron_absorber_type;
+
+ typedef Interval<DomainT> interval_type;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::base_value_type base_value_type;
+ typedef typename base_type::base_pair_type base_pair_type;
+ typedef typename base_type::ImplMapT ImplMapT;
+
+ typedef interval_set<DomainT,Interval,Compare,Alloc> interval_set_type;
+ typedef interval_set_type set_type;
+
+ /// Default constructor for the empty map
+ interval_map(): base_type() {}
+ /// Copy constructor
+ interval_map(const interval_map& src): base_type(src) {}
+
+
+ /// Copy constructor for base_type
+ template<class SubType>
+ explicit interval_map
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& src)
+ { assign(src); }
+
+ explicit interval_map(base_pair_type& base_pair): base_type()
+ { add(base_pair); }
+
+ explicit interval_map(const value_type& value_pair): base_type()
+ { add(value_pair); }
+
+ /// Assignment operator
+ template<class SubType>
+ interval_map& operator =
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& src)
+ { assign(src); return *this; }
+
+ /// Assignment from a base interval_map.
+ template<class SubType>
+ void assign(const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& src)
+ {
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> base_map_type;
+ this->clear();
+ // Can be implemented via _map.insert: Interval joining not necessary.
+ const_FORALL(typename base_map_type, it, src)
+ this->add(*it);
+ }
+
+ bool contains_(const value_type& x)const;
+
+
+ template<template<class>class Combinator>
+ void add_(const value_type&);
+
+ void add_(const value_type& value)
+ { add_<inplace_plus>(value); }
+
+ template<template<class>class Combinator>
+ void subtract_(const value_type&);
+
+ void subtract_(const value_type& value)
+ {
+ if(Traits::emits_neutrons)
+ add_<inplace_minus>(value);
+ else
+ subtract_<inplace_minus>(value);
+ }
+
+ void insert_(const value_type& value);
+ void erase_(const value_type& value);
+
+ //TESTCODE
+ void getResiduals(const interval_type& x_itv, interval_type& leftResid, interval_type& rightResid);
+
+private:
+ bool insertable(const value_type& value)const
+ {
+ return !value.KEY_VALUE.empty()
+ && !(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT());
+ }
+
+ bool join_left(iterator& it);
+ bool join_right(iterator& it);
+ void join_neighbours(iterator& it){ join_left(it); join_right(it); };
+ bool joinable(const iterator& some, const iterator& next)const;
+ iterator joint_insert(iterator& some, const iterator& next);
+
+ template<template<class>class Combinator>
+ iterator fill_gap_join_left(const value_type&);
+
+ template<template<class>class Combinator>
+ iterator fill_gap_join_both(const value_type&);
+
+ iterator fill_join_left(const value_type&);
+ iterator fill_join_both(const value_type&);
+
+ template<template<class>class Combinator>
+ void add_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+
+ template<template<class>class Combinator>
+ void add_rear(const interval_type& x_itv, const CodomainT& x_val, iterator& it);
+
+ template<template<class>class Combinator>
+ void subtract_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+
+ void insert_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+ void insert_rear(const interval_type& x_itv, const CodomainT& x_val, iterator& it);
+
+ void erase_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+} ;
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+bool interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::contains_(const value_type& interv_value)const
+{
+ interval_type interv = interv_value.KEY_VALUE;
+ if(interv.empty())
+ return true;
+
+ type section;
+ add_intersection(section, interv);
+ return is_element_equal(section, type(interv_value));
+}
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::getResiduals(const interval_type& x_itv, interval_type& leftResid, interval_type& rightResid)
+{
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ iterator end_it = this->_map.upper_bound(x_itv);
+
+ if(fst_it==end_it)
+ {
+ leftResid.clear();
+ rightResid.clear();
+ return;
+ }
+
+ (*fst_it).KEY_VALUE.left_surplus(leftResid, x_itv);
+ iterator lst_it = fst_it; lst_it++;
+
+ if(lst_it==end_it)
+ {
+ rightResid.clear();
+ return;
+ }
+
+ lst_it=end_it; lst_it--;
+
+ (*lst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+}
+
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+bool interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::joinable(const iterator& some, const iterator& next)const
+{
+ // assert: next != end && some++ == next
+ return some->KEY_VALUE.touches(next->KEY_VALUE)
+ && some->CONT_VALUE == next->CONT_VALUE;
+}
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+typename interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::iterator
+ interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::joint_insert(iterator& left_it, const iterator& right_it)
+{
+ // both left and right are in the set and they are neighbours
+ BOOST_ASSERT(right_it != _map.end());
+ BOOST_ASSERT(left_it->KEY_VALUE.exclusive_less(right_it->KEY_VALUE));
+ BOOST_ASSERT(left_it->KEY_VALUE.touches(right_it->KEY_VALUE));
+
+ interval_type interval = left_it->KEY_VALUE;
+ //It has to be a copy, because is location will be erased
+ //JODO: Try optimizing inplace.
+ CodomainT value = left_it->CONT_VALUE;
+ interval.extend(right_it->KEY_VALUE);
+
+ this->_map.erase(left_it);
+ this->_map.erase(right_it);
+
+ std::pair<iterator,bool> insertion = this->_map.insert(make_pair(interval, value));
+ iterator new_it = insertion.ITERATOR;
+ BOOST_ASSERT(insertion.WAS_SUCCESSFUL);
+ BOOST_ASSERT(new_it!=this->_map.end());
+ left_it = new_it;
+ return new_it;
+}
+
+
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+bool interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::join_left(iterator& it)
+{
+ if(it == this->_map.begin())
+ return false;
+
+ // there is a predecessor
+ iterator it_pred = it; it_pred-- ;
+
+ if(joinable(it_pred, it))
+ {
+ iterator it_leftExtended = joint_insert(it_pred, it);
+ //CAUTION: it is now invalidated
+ it = it_leftExtended;
+ return true;
+ }
+
+ return false;
+}
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+bool interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::join_right(iterator& it)
+{
+ if(it == this->_map.end())
+ return false;
+
+ // there is a successor
+ iterator it_succ = it; it_succ++ ;
+
+ if(it_succ != this->_map.end() && joinable(it, it_succ))
+ {
+ joint_insert(it, it_succ);
+ return true;
+ }
+
+ return false;
+}
+
+
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+typename interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::iterator
+interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::fill_join_left(const value_type& value)
+{
+ //collision free insert is asserted
+ if(value.KEY_VALUE.empty())
+ return this->_map.end();
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ return this->_map.end();
+
+ std::pair<iterator,bool> insertion = this->_map.insert(value);
+
+ join_left(insertion.ITERATOR);
+
+ return insertion.ITERATOR; //JODO return value currently unused
+}
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+typename interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::iterator
+interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::fill_join_both(const value_type& value)
+{
+ //collision free insert is asserted
+ if(value.KEY_VALUE.empty())
+ return this->_map.end();
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ return this->_map.end();
+
+ std::pair<iterator,bool> insertion = this->_map.insert(value);
+
+ join_neighbours(insertion.ITERATOR);
+
+ return insertion.ITERATOR;
+}
+
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+typename interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::iterator
+interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::fill_gap_join_left(const value_type& value)
+{
+ static Combinator<CodomainT> combine;
+ //collision free insert is asserted
+ if(value.KEY_VALUE.empty())
+ return this->_map.end();
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ return this->_map.end();
+
+ std::pair<iterator,bool> insertion;
+ if(Traits::emits_neutrons)
+ {
+ CodomainT added_val = CodomainT();
+ combine(added_val, value.CONT_VALUE);
+ insertion = this->_map.insert(value_type(value.KEY_VALUE, added_val));
+ }
+ else
+ insertion = this->_map.insert(value);
+
+ join_left(insertion.ITERATOR);
+
+ return insertion.ITERATOR; //JODO return value currently unused
+}
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+typename interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::iterator
+interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::fill_gap_join_both(const value_type& value)
+{
+ static Combinator<CodomainT> combine;
+ //collision free insert is asserted
+ if(value.KEY_VALUE.empty())
+ return this->_map.end();
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ return this->_map.end();
+
+ std::pair<iterator,bool> insertion;
+ if(Traits::emits_neutrons)
+ {
+ CodomainT added_val = CodomainT();
+ combine(added_val, value.CONT_VALUE);
+ insertion = this->_map.insert(value_type(value.KEY_VALUE, added_val));
+ }
+ else
+ insertion = this->_map.insert(value);
+
+ join_neighbours(insertion.ITERATOR);
+
+ return insertion.ITERATOR;
+}
+
+
+//-----------------------------------------------------------------------------
+// add<Combinator>(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_(const value_type& x)
+{
+ static Combinator<CodomainT> combine;
+
+ const interval_type& x_itv = x.KEY_VALUE;
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ std::pair<iterator,bool> insertion;
+ if(Traits::emits_neutrons)
+ {
+ CodomainT added_val = CodomainT();
+ combine(added_val, x_val);
+ insertion = this->_map.insert(value_type(x_itv, added_val));
+ }
+ else
+ insertion = this->_map.insert(x);
+
+ if(insertion.WAS_SUCCESSFUL)
+ join_neighbours(insertion.ITERATOR);
+ else
+ {
+ // Detect the first and the end iterator of the collision sequence
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ iterator end_it = insertion.ITERATOR;
+ if(end_it != this->_map.end())
+ end_it++;
+ //assert(end_it == this->_map.upper_bound(x_itv));
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE;
+ CodomainT cur_val = (*fst_it).CONT_VALUE;
+
+
+ interval_type leadGap; x_itv.left_surplus(leadGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+ //The first collision interval may grow by joining neighbours after insertion
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid;
+ fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ CodomainT cmb_val = cur_val;
+ combine(cmb_val, x_val);
+
+ iterator snd_it = fst_it; snd_it++;
+
+ if(snd_it == end_it)
+ {
+ // first == last
+
+ interval_type endGap; x_itv.right_surplus(endGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*fst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+
+ this->_map.erase(fst_it);
+ fill_join_left(value_type(leftResid, cur_val));
+
+ if(endGap.empty() && rightResid.empty())
+ fill_join_both(value_type(interSec, cmb_val));
+ else
+ fill_join_left(value_type(interSec, cmb_val));
+
+ if(!leadGap.empty())
+ fill_gap_join_both<Combinator>(value_type(leadGap, x_val));
+ if(!endGap.empty())
+ fill_gap_join_both<Combinator>(value_type(endGap, x_val));
+ else
+ fill_join_left(value_type(rightResid, cur_val));
+ }
+ else
+ {
+ this->_map.erase(fst_it);
+ fill_join_left(value_type(leftResid, cur_val));
+ fill_join_left(value_type(interSec, cmb_val));
+
+ if(!leadGap.empty())
+ fill_gap_join_both<Combinator>(value_type(leadGap, x_val));
+
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(fst_itv);
+
+ add_rest<Combinator>(x_rest, x_val, snd_it, end_it);
+ }
+ }
+}
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it)
+{
+ static Combinator<CodomainT> combine;
+
+ iterator nxt_it = it; nxt_it++;
+ interval_type x_rest = x_itv, left_gap, common, cur_itv;
+
+ while(nxt_it!=end_it)
+ {
+ cur_itv = (*it).KEY_VALUE ;
+ x_rest.left_surplus(left_gap, cur_itv);
+
+ combine(it->CONT_VALUE, x_val);
+ fill_gap_join_left<Combinator>(value_type(left_gap, x_val)); //A posteriori
+
+ if(Traits::absorbs_neutrons && it->CONT_VALUE == CodomainT())
+ this->_map.erase(it++);
+ else
+ {
+ // after filling that gap there may be another joining opportunity
+ join_left(it);
+ it++;
+ }
+
+ // shrink interval
+ x_rest.left_subtract(cur_itv);
+ nxt_it++;
+ }
+
+ add_rear<Combinator>(x_rest, x_val, it);
+}
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_rear(const interval_type& x_rest, const CodomainT& x_val, iterator& it)
+{
+ static Combinator<CodomainT> combine;
+
+ interval_type cur_itv = (*it).KEY_VALUE ;
+ CodomainT cur_val = (*it).CONT_VALUE ;
+
+ interval_type lead_gap;
+ x_rest.left_surplus(lead_gap, cur_itv);
+
+ interval_type common;
+ cur_itv.intersect(common, x_rest);
+
+ CodomainT cmb_val = cur_val;
+ combine(cmb_val, x_val);
+
+ interval_type end_gap;
+ x_rest.right_surplus(end_gap, cur_itv);
+
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type right_resid;
+ cur_itv.right_surplus(right_resid, x_rest);
+
+ this->_map.erase(it);
+ if(end_gap.empty() && right_resid.empty())
+ fill_join_both(value_type(common, cmb_val));
+ else
+ fill_join_left(value_type(common, cmb_val));
+
+ if(!lead_gap.empty())
+ fill_gap_join_both<Combinator>(value_type(lead_gap, x_val));
+ if(!end_gap.empty())
+ fill_gap_join_both<Combinator>(value_type(end_gap, x_val));
+ else
+ fill_join_left(value_type(right_resid, cur_val));
+}
+
+
+//-----------------------------------------------------------------------------
+// subtract<Combinator>(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::subtract_(const value_type& x)
+{
+ static Combinator<CodomainT> combine;
+ const interval_type& x_itv = x.KEY_VALUE;
+
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ if(fst_it==this->_map.end()) return;
+ iterator end_it = this->_map.upper_bound(x_itv);
+ if(fst_it==end_it) return;
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+ // must be copies because fst_it will be erased
+ CodomainT fst_val = (*fst_it).CONT_VALUE ;
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid;
+ fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ CodomainT cmb_val = fst_val;
+ combine(cmb_val, x_val);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*fst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+
+ this->_map.erase(fst_it);
+ fill_join_left(value_type(leftResid, fst_val));
+
+ if(rightResid.empty())
+ fill_join_both(value_type(interSec, cmb_val));
+ else
+ fill_join_left(value_type(interSec, cmb_val));
+
+ fill_join_both(value_type(rightResid, fst_val));
+ }
+ else
+ {
+ // first AND NOT last
+ this->_map.erase(fst_it);
+
+ fill_join_left(value_type(leftResid, fst_val));
+ fill_join_left(value_type(interSec, cmb_val));
+
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(fst_itv);
+
+ subtract_rest<Combinator>(x_rest, x_val, snd_it, end_it);
+ }
+}
+
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::subtract_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it)
+{
+ static Combinator<CodomainT> combine;
+ iterator nxt_it=it; nxt_it++;
+
+ while(nxt_it!=end_it)
+ {
+ CodomainT& cur_val = (*it).CONT_VALUE ;
+ combine(cur_val, x_val);
+
+ if(Traits::absorbs_neutrons && cur_val==CodomainT())
+ this->_map.erase(it++);
+ else
+ {
+ join_left(it);
+ it++;
+ }
+
+ nxt_it=it; nxt_it++;
+ }
+
+ // it refers the last overlaying intervals of x_itv
+ const interval_type& cur_itv = (*it).KEY_VALUE ;
+
+ interval_type rightResid;
+ cur_itv.right_surplus(rightResid, x_itv);
+
+ if(rightResid.empty())
+ {
+ CodomainT& cur_val = (*it).CONT_VALUE ;
+ combine(cur_val, x_val);
+ if(Traits::absorbs_neutrons && cur_val==CodomainT())
+ this->_map.erase(it);
+ else
+ {
+ join_left(it);
+ // cur_val is the last -= modified value. There may be an
+ // adjoint right neighbour that is now joinable.
+ if(it != this->_map.end())
+ {
+ iterator out_it = it; out_it++;
+ if(out_it != this->_map.end() && joinable(it, out_it))
+ joint_insert(it,out_it);
+ }
+ }
+ }
+ else
+ {
+ CodomainT cur_val = (*it).CONT_VALUE ;
+ CodomainT cmb_val = cur_val ;
+ combine(cmb_val, x_val);
+ interval_type interSec;
+ cur_itv.intersect(interSec, x_itv);
+
+ this->_map.erase(it);
+ if(rightResid.empty())
+ fill_join_both(value_type(interSec, cmb_val));
+ else
+ fill_join_left(value_type(interSec, cmb_val));
+
+ fill_join_both(value_type(rightResid, cur_val));
+ }
+}
+
+
+
+//-----------------------------------------------------------------------------
+// insert(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::insert_(const value_type& x)
+{
+ const interval_type& x_itv = x.KEY_VALUE;
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ std::pair<typename ImplMapT::iterator,bool>
+ insertion = this->_map.insert(x);
+
+ if(insertion.WAS_SUCCESSFUL)
+ join_neighbours(insertion.ITERATOR);
+ else
+ {
+ // Detect the first and the end iterator of the collision sequence
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ iterator end_it = insertion.ITERATOR;
+ if(end_it != this->_map.end())
+ end_it++;
+ //assert(end_it == this->_map.upper_bound(x_itv));
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+ interval_type leadGap; x_itv.left_surplus(leadGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ //Fill gap after iterator compare bcause iterators are modified by joining
+ if(!leadGap.empty())
+ fill_join_both(value_type(leadGap, x_val));
+
+ interval_type endGap; x_itv.right_surplus(endGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+ fill_join_both(value_type(endGap, x_val));
+ }
+ else
+ {
+ if(!leadGap.empty())
+ fill_join_both(value_type(leadGap, x_val));
+
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(fst_itv);
+
+ insert_rest(x_rest, x_val, snd_it, end_it);
+ }
+ }
+}
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::insert_rest(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it, iterator& end_it)
+{
+ iterator nxt_it = it; nxt_it++;
+ interval_type x_rest = x_itv, gap, common, cur_itv;
+
+ for(; nxt_it!=end_it; ++it, ++nxt_it)
+ {
+ cur_itv = (*it).KEY_VALUE ;
+ x_rest.left_surplus(gap, cur_itv);
+
+ if(!gap.empty())
+ {
+ fill_join_left(value_type(gap, x_val));
+ // after filling that gap there may be another joining opportunity
+ join_left(it);
+ }
+
+ // shrink interval
+ x_rest.left_subtract(cur_itv);
+ }
+
+ insert_rear(x_rest, x_val, it);
+}
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::insert_rear(const interval_type& x_rest, const CodomainT& x_val,
+ iterator& it)
+{
+ interval_type cur_itv = (*it).KEY_VALUE ;
+
+ interval_type left_gap;
+ x_rest.left_surplus(left_gap, cur_itv);
+
+ if(!left_gap.empty())
+ {
+ fill_join_left(value_type(left_gap, x_val));
+ // after filling that gap there may be another joining opportunity
+ join_left(it);
+ }
+
+ interval_type common;
+ cur_itv.intersect(common, x_rest);
+
+ interval_type end_gap;
+ x_rest.right_surplus(end_gap, cur_itv);
+
+ fill_join_both(value_type(end_gap, x_val));
+}
+
+
+//-----------------------------------------------------------------------------
+// erase(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::erase_(const value_type& x)
+{
+ const interval_type& x_itv = x.KEY_VALUE;
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ if(fst_it==this->_map.end()) return;
+ iterator end_it = this->_map.upper_bound(x_itv);
+ if(fst_it==end_it) return;
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+ // must be copies because fst_it will be erased
+ CodomainT fst_val = (*fst_it).CONT_VALUE ;
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid;
+ fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*fst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+
+ if(!interSec.empty() && fst_val == x_val)
+ {
+ this->_map.erase(fst_it);
+ insert_(value_type(leftResid, fst_val));
+ // erased: insert(value_type(interSec, cmb_val));
+ insert_(value_type(rightResid, fst_val));
+ }
+ }
+ else
+ {
+ // first AND NOT last
+ if(!interSec.empty() && fst_val == x_val)
+ {
+ this->_map.erase(fst_it);
+ insert_(value_type(leftResid, fst_val));
+ // erased: insert(value_type(interSec, cmb_val));
+ }
+
+ erase_rest(x_itv, x_val, snd_it, end_it);
+ }
+}
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::erase_rest(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it, iterator& end_it)
+{
+ iterator nxt_it=it; nxt_it++;
+
+ // For all intervals within loop: it->KEY_VALUE are contained_in x_itv
+ while(nxt_it!=end_it)
+ {
+ if((*it).CONT_VALUE == x_val)
+ this->_map.erase(it++);
+ else it++;
+
+ nxt_it=it; nxt_it++;
+ }
+
+ // it refers the last overlaying intervals of x_itv
+ interval_type cur_itv = (*it).KEY_VALUE ;
+ // Has to be a copy, cause 'it' will be erased
+ CodomainT cur_val = (*it).CONT_VALUE;
+
+ interval_type rightResid;
+ cur_itv.right_surplus(rightResid, x_itv);
+
+ if(rightResid.empty())
+ {
+ if(cur_val == x_val)
+ this->_map.erase(it);
+ }
+ else
+ {
+ interval_type interSec;
+ cur_itv.intersect(interSec, x_itv);
+
+ if(!interSec.empty() && cur_val == x_val)
+ {
+ this->_map.erase(it);
+ //erased: insert(value_type(interSec, cmb_val));
+ insert_(value_type(rightResid, cur_val));
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// type traits
+//-----------------------------------------------------------------------------
+
+template <class KeyT, class DataT, class Traits>
+struct is_set<itl::interval_map<KeyT,DataT,Traits> >
+{ enum{value = true}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_interval_container<itl::interval_map<KeyT,DataT,Traits> >
+{ enum{value = true}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_interval_splitter<itl::interval_map<KeyT,DataT,Traits> >
+{ enum{value = true}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_neutron_absorber<itl::interval_map<KeyT,DataT,Traits> >
+{ enum{value = Traits::absorbs_neutrons}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_neutron_emitter<itl::interval_map<KeyT,DataT,Traits> >
+{ enum{value = Traits::emits_neutrons}; };
+
+template <class KeyT, class DataT, class Traits>
+struct type_to_string<itl::interval_map<KeyT,DataT,Traits> >
+{
+ static std::string apply()
+ {
+ return "itv_map<"+ type_to_string<KeyT>::apply() + ","
+ + type_to_string<DataT>::apply() + ","
+ + type_to_string<Traits>::apply() +">";
+ }
+};
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/interval_map_algo.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_map_algo.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,146 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_interval_map_algo_JOFA_081026_H__
+#define __itl_interval_map_algo_JOFA_081026_H__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl/type_traits/neutron.hpp>
+
+namespace boost{namespace itl
+{
+
+namespace Map
+{
+
+template<class LeftT, class RightT>
+class interval_map_sequence_tracker
+{
+public:
+ typedef typename LeftT::const_iterator LeftIterT;
+ typedef typename RightT::const_iterator RightIterT;
+
+ interval_map_sequence_tracker(const LeftT& left,
+ const RightT& right)
+ : _left(left), _right(right), _result(false)
+ {}
+
+ enum{nextboth, nextleft, nextright, leftaligned, stop};
+
+ bool result()const{ return _result; }
+
+ int proceed(LeftIterT& left, RightIterT& right)
+ {
+ if(LeftT::key_value(left).upper_equal(RightT::key_value(right)))
+ {
+ ++left;
+ ++right;
+ return nextboth;
+ }
+ else if(LeftT::key_value(left).upper_less(RightT::key_value(right)))
+ {
+ _prior_left = left;
+ ++left;
+ return nextleft;
+ }
+ else
+ {
+ _prior_right = right;
+ ++right;
+ return nextright;
+ }
+ }
+
+ int next_both(LeftIterT& left, RightIterT& right)
+ {
+ if(left == _left.end())
+ {
+ _result = (right == _right.end()) ? true : false;
+ return stop;
+ }
+
+ // left != _left.end()
+ if(right == _right.end())
+ return stop; //_result = false;
+
+ // The starting intervals have to begin equally
+ if(!LeftT::key_value(left).lower_equal(RightT::key_value(right)))
+ return stop; //_result = false;
+
+ if(!(LeftT::data_value(left) == RightT::data_value(right)))
+ return stop; //_result = false;
+
+ return leftaligned;
+ }
+
+ int next_left(LeftIterT& left, RightIterT& right)
+ {
+ if(left == _left.end())
+ return stop;
+ if(!LeftT::key_value(_prior_left).touches(LeftT::key_value(left)))
+ return stop; //_result = false;
+
+ if(!(LeftT::data_value(left) == RightT::data_value(right)))
+ return stop; //_result = false;
+
+ return proceed(left, right);
+ }
+
+ int next_right(LeftIterT& left, RightIterT& right)
+ {
+ if(right == _right.end())
+ return stop;
+ if(!RightT::key_value(_prior_right).touches(RightT::key_value(right)))
+ return stop; //_result = false;
+
+ if(!(LeftT::data_value(left) == RightT::data_value(right)))
+ return stop; //_result = false;
+
+ return proceed(left, right);
+ }
+
+private:
+ const LeftT& _left;
+ const RightT& _right;
+ LeftIterT _prior_left;
+ RightIterT _prior_right;
+ bool _result;
+};
+
+template<class LeftT, class RightT>
+bool is_element_equal(const LeftT& left, const RightT& right)
+{
+ if(left.empty())
+ return right.empty();
+ else if(right.empty())
+ return false;
+
+ typedef interval_map_sequence_tracker<LeftT,RightT> Step;
+ Step step(left, right);
+
+ typename LeftT::const_iterator left_ = left.begin();
+ typename RightT::const_iterator right_ = right.begin();
+
+ int state = Step::nextboth;
+ while(state != Step::stop)
+ {
+ switch(state){
+ case Step::nextboth: state = step.next_both(left_, right_); break;
+ case Step::nextleft: state = step.next_left(left_, right_); break;
+ case Step::nextright: state = step.next_right(left_, right_); break;
+ case Step::leftaligned: state = step.proceed(left_, right_); break;
+ }
+ }
+ return step.result();
+}
+
+} //Map
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl/interval_maps.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_maps.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,512 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_interval_maps_h_JOFA_081008__
+#define __itl_interval_maps_h_JOFA_081008__
+
+#include <boost/itl/interval_base_map.hpp>
+#include <boost/itl/interval_map_algo.hpp>
+
+namespace boost{namespace itl
+{
+
+template
+<
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+>
+class interval_map;
+
+
+//-----------------------------------------------------------------------------
+// addition +=
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator +=
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& operand
+)
+{
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
+ object.add(*elem_);
+
+ return object;
+}
+
+//--- value_type --------------------------------------------------------------
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator +=
+(
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const typename
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>::value_type& operand
+)
+{
+ return object.add(operand);
+}
+
+//--- base_value_type ---------------------------------------------------------
+// Addition (+=) of a base value pair.
+/* Addition of an value pair <tt>x=(I,y)</tt>
+
+ This adds (inserts) a value <tt>y</tt> for an interval <tt>I</tt> into the
+ map, identical member function add.
+
+ If no values are associated already within the range of <tt>I</tt>,
+ <tt>y</tt> will be associated to that interval.
+
+ If there are associated values, in the range of <tt>I</tt>, then all
+ those values within the ranges of their intervals,
+ are incremented by <tt>y</tt>. This is done via operator <tt>+=</tt>
+ which has to be implemented for CodomainT.
+*/
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator +=
+(
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const typename
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>::base_pair_type& operand
+)
+{
+ return object.add(operand);
+}
+
+
+//-----------------------------------------------------------------------------
+// subtraction -=
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator -=
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& operand
+)
+{
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
+ object.subtract(*elem_);
+
+ return object;
+}
+
+//--- value_type --------------------------------------------------------------
+// Subtraction of an interval value pair
+/* Subtraction of an interval value pair <tt>x=(I,y)</tt>.
+ This subtracts a value <tt>y</tt> for an interval <tt>I</tt> from the map.
+
+ If there are associated values, in the range of <tt>I</tt>, all
+ those values within the ranges of their intervals,
+ are decremented by <tt>y</tt>. This is done usign operator -=.
+
+ If <tt>y</tt> becomes the neutral element CodomainT() <tt>k</tt> will
+ also be removed from the map, if the Traits include the property
+ neutron_absorber.
+*/
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator -=
+(
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const typename
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>::value_type& operand
+)
+{
+ return object.subtract(operand);
+}
+
+//--- base_value_type ---------------------------------------------------------
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator -=
+(
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const typename
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>::base_pair_type& operand
+)
+{
+ return object.subtract(operand);
+}
+
+
+//-----------------------------------------------------------------------------
+// erasure -= of elements given by an interval_set
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator -=
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const IntervalSet<DomainT,Interval,Compare,Alloc>& erasure
+)
+{
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> set_type;
+ const_FORALL(typename set_type, interval_, erasure)
+ object.erase(*interval_);
+
+ return object;
+}
+
+//--- value_type --------------------------------------------------------------
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator -=
+(
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const typename
+ IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>::interval_type& operand
+)
+{
+ return object.erase(operand);
+}
+
+
+//-----------------------------------------------------------------------------
+// insert
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ class OperandT
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+insert
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const OperandT& operand
+)
+{
+ const_FORALL(typename OperandT, elem_, operand)
+ object.insert(*elem_);
+ return object;
+}
+
+//-----------------------------------------------------------------------------
+// erase
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ class OperandT
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+erase
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const OperandT& operand
+)
+{
+ const_FORALL(typename OperandT, elem_, operand)
+ object.erase(*elem_);
+ return object;
+}
+
+//-----------------------------------------------------------------------------
+// intersection *=
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ class SectanT
+>
+interval_base_map<SubType,DomainT,CodomainT,Traits,Interval,Compare,Alloc>&
+operator *=
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const SectanT& operand
+)
+{
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> object_type;
+ object_type intersection;
+ object.add_intersection(intersection,operand);
+ object.swap(intersection);
+ return object;
+}
+
+//-----------------------------------------------------------------------------
+// is_element_equal
+//-----------------------------------------------------------------------------
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class LeftIntervalMap,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class RightIntervalMap
+>
+bool is_element_equal
+(
+ const LeftIntervalMap <DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& left,
+ const RightIntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& right
+)
+{
+ return Map::is_element_equal(left, right);
+}
+
+
+//-----------------------------------------------------------------------------
+// is_disjoint
+//-----------------------------------------------------------------------------
+
+//--- IntervalMap -------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+//JODO boost::enable_if
+bool is_disjoint
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> object_type;
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> operand_type;
+ object_type intersection;
+
+ if(operand.empty())
+ return true;
+
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return true;
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ {
+ object.add_intersection(intersection, (it++)->KEY_VALUE);
+ if(!intersection.empty())
+ return false;
+ }
+
+ return true;
+}
+
+//--- IntervalSet -------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+//JODO boost::enable_if
+bool is_disjoint
+(
+ interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& object,
+ const IntervalSet<DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> object_type;
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> operand_type;
+ object_type intersection;
+
+ if(operand.empty())
+ return true;
+
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return true;
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ {
+ object.add_intersection(intersection, *it++);
+ if(!intersection.empty())
+ return false;
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// enclosure
+//-----------------------------------------------------------------------------
+template
+<
+ class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+typename IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::interval_type
+enclosure(const IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc>& object)
+{
+ typedef IntervalMap<DomainT,CodomainT,Traits,Interval,Compare,Alloc> IntervalMapT;
+ typedef typename IntervalMapT::interval_type interval_type;
+ return
+ object.empty() ? neutron<interval_type>::value()
+ : (object.begin()->KEY_VALUE)
+ .span(object.rbegin()->KEY_VALUE);
+}
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/interval_morphism.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_morphism.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,119 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_interval_morphism_H_JOFA_080315__
+#define __itl_interval_morphism_H_JOFA_080315__
+
+#include <boost/itl/notate.hpp>
+namespace boost{namespace itl
+{
+ namespace Interval
+ {
+ template <typename ElementContainerT, typename IntervalContainerT>
+ void atomize(ElementContainerT& result, const IntervalContainerT& src)
+ {
+ const_FORALL(typename IntervalContainerT, itv_, src)
+ {
+ const typename IntervalContainerT::key_type& itv = IntervalContainerT::key_value(itv_);
+ typename IntervalContainerT::codomain_type coval = IntervalContainerT::codomain_value(itv_);
+
+ for(typename IntervalContainerT::domain_type element = itv.first(); element <= itv.last(); element++)
+ {
+ result.insert(ElementContainerT::make_element(element, coval));
+ }
+ }
+ }
+
+ template <typename IntervalContainerT, typename ElementContainerT>
+ void cluster(IntervalContainerT& result, const ElementContainerT& src)
+ {
+ const_FORALL(typename ElementContainerT, element_, src)
+ {
+ const typename ElementContainerT::key_type& key = ElementContainerT::key_value(element_);
+ const typename ElementContainerT::data_type& data = ElementContainerT::data_value(element_);
+
+ result += IntervalContainerT::make_domain_element(key, data);
+ }
+ }
+
+ template <typename AtomizedType, typename ClusteredType>
+ struct Atomize
+ {
+ void operator()(AtomizedType& atomized, const ClusteredType& clustered)
+ {
+ Interval::atomize(atomized, clustered);
+ }
+ };
+
+ template <typename ClusteredType, typename AtomizedType>
+ struct Cluster
+ {
+ void operator()(ClusteredType& clustered, const AtomizedType& atomized)
+ {
+ Interval::cluster(clustered, atomized);
+ }
+ };
+
+ template <typename JointType, typename SplitType>
+ struct Join
+ {
+ void operator()(JointType& joint, SplitType& split)
+ {
+ split.join();
+ FORALL(typename SplitType, split_, split)
+ joint.insert(*split_);
+ }
+ };
+
+ template <typename AbsorberType, typename EnricherType>
+ struct AbsorbNeutrons
+ {
+ void operator()(AbsorberType& absorber, EnricherType& enricher)
+ {
+ enricher.absorb_neutrons();
+ FORALL(typename EnricherType, enricher_, enricher)
+ absorber.insert(*enricher_);
+ }
+ };
+
+ } // namespace Interval
+
+
+ template<>
+ inline std::string binary_template_to_string<Interval::Atomize>::apply() { return "@"; }
+ template<>
+ inline std::string binary_template_to_string<Interval::Cluster>::apply() { return "&"; }
+ template<>
+ inline std::string binary_template_to_string<Interval::Join>::apply() { return "j"; }
+ template<>
+ inline std::string binary_template_to_string<Interval::AbsorbNeutrons>::apply() { return "a0"; }
+}} // namespace boost itl
+
+#endif
+
+
+
Added: sandbox/itl/boost/itl/interval_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,406 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class interval_set
+--------------------------------------------------------------------*/
+#ifndef __itl_interval_set_hpp_JOFA_990223__
+#define __itl_interval_set_hpp_JOFA_990223__
+
+#include <boost/assert.hpp>
+#include <boost/itl/interval_base_set.hpp>
+#include <boost/itl/interval_sets.hpp>
+
+namespace boost{namespace itl
+{
+
+/// Implements a set as a set of intervals - merging adjoining intervals
+/**
+ Template-class <b>interval_set</b>
+ implements a set as a set of intervals - interval bounds are merged if
+ inserted intervals overlap or adjoin.
+
+ Template parameter <b>DomainT</b>: The set's domain-type. Type of the
+ set's elements.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Template parameter <b>Interval=itl::interval</b>: Type of interval used
+ to implement the set. The default <b>itl::interval</b> uses the
+ interval class that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>interval_set</b> implements a set <tt>set<DomainT></tt> as a set of intervals
+ <tt>set<interval<DomainT>></tt>. Intervals will be merged on insertion, if they
+ border each other or overlap.
+
+ interval_base_set<DomainT> can thus be used like a set. As it is known from mathematics
+ the union over a set of intervls is a set itself.
+
+ <b>Class <tt>interval_set</tt> yields the following benefits: </b>
+
+ <ul>
+ <li>
+ A set of intervals is conceived as a set. The complexity involved with
+ operations on intervals and sets of intervals is encapsulated.
+ The user of the class who
+ wants to perform set operations on sets of intervals is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_set</b> gives an efficient implementation of sets consisting
+ of larger contiguous chunks. Very large, even uncountably infinite sets of
+ elements can be represented in a compact way and handled efficiently.
+ </ul>
+
+ Intervals in <b>interval_sets</b> are always unified, if intervals are adjoint. So the number
+ of interval in an <b>interval_set</b> is always minimal. So informations about bounds
+ of inserted intervals are lost if those intervals are adjoint to or overlapping
+ with intervals within the <b>interval_set</b>.
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+ These functions are tagged in the documentation.
+
+ @author Joachim Faulhaber
+*/
+
+/* JODO Using such functions
+ for continuous domain datatypes yields compiletime errors. E.g. getting
+ the <tt>first()</tt> element of a left open interval makes sense for intervals of
+ int but not for intervals of double.
+*/
+
+template
+<
+ typename DomainT,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+>
+class interval_set:
+ public interval_base_set<interval_set<DomainT,Interval,Compare,Alloc>,
+ DomainT,Interval,Compare,Alloc>
+{
+public:
+
+ /// The base_type of this class
+ typedef interval_base_set<itl::interval_set<DomainT,Interval,Compare,Alloc>,
+ DomainT,Interval,Compare,Alloc> base_type;
+
+ typedef interval_set<DomainT,Interval,Compare,Alloc> type;
+ typedef type joint_type;
+
+ /// The domain type of the set
+ typedef DomainT domain_type;
+ /// The codomaintype is the same as domain_type
+ typedef DomainT codomain_type;
+
+ /// The interval type of the set
+ typedef Interval<DomainT> interval_type;
+
+ /// Comparison functor for domain values
+ typedef Compare<DomainT> domain_compare;
+ /// Comparison functor for intervals
+ typedef exclusive_less<interval_type> interval_compare;
+
+ /// Comparison functor for keys
+ typedef exclusive_less<interval_type> key_compare;
+
+ /// The allocator type of the set
+ typedef Alloc<interval_type> allocator_type;
+
+ /// allocator type of the corresponding element set
+ typedef Alloc<DomainT> domain_allocator_type;
+
+ /// The type of the set of elements that is equivalent to the set of intervals
+ typedef typename itl::set<DomainT,Compare,Alloc> element_set;
+
+ /// The corresponding atomized type representing this interval container of elements
+ typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
+
+ /// Container type for the implementation
+ typedef typename itl::set<interval_type,exclusive_less,Alloc> ImplSetT;
+
+ /// key type of the implementing container
+ typedef typename ImplSetT::key_type key_type;
+ /// data type of the implementing container
+ typedef typename ImplSetT::data_type data_type;
+ /// value type of the implementing container
+ typedef typename ImplSetT::value_type value_type;
+
+ /// iterator for iteration over intervals
+ typedef typename ImplSetT::iterator iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplSetT::const_iterator const_iterator;
+
+
+
+ // B: Constructors, destructors, assignment
+ /// Default constructor for the empty set
+ interval_set(): base_type() {}
+ /// Copy constructor
+ interval_set(const interval_set& src): base_type(src) {}
+
+ /// Copy constructor for base_type
+ template<class SubType>
+ explicit interval_set
+ (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ { assign(src); }
+
+ /// Constructor for a single element
+ explicit interval_set(const domain_type& value): base_type()
+ { add(interval_type(value)); }
+ /// Constructor for a single interval
+ explicit interval_set(const interval_type& itv): base_type()
+ { add(itv); }
+
+ /// Assignment operator
+ template<class SubType>
+ interval_set& operator =
+ (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ { assign(src); return *this; }
+
+
+ /// Assignment from a base interval_set.
+ template<class SubType>
+ void assign(const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ {
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> base_set_type;
+ this->clear();
+ // Has to be implemented via add. there might be touching borders to be joined
+ const_FORALL(typename base_set_type, it, src)
+ this->add(*it);
+ }
+
+ /// Does the set contain the interval <tt>x</tt>?
+ bool contains_(const interval_type& x)const;
+
+ /// Insertion of an interval <tt>x</tt>
+ void add_(const value_type& x);
+
+ /// Removal of an interval <tt>x</tt>
+ void subtract_(const value_type& x);
+
+ /// Treatment of adjoint intervals on insertion
+ void handle_neighbours(const iterator& it);
+
+protected:
+ iterator joint_insert(const iterator& left_it, const iterator& right_it);
+} ;
+
+
+
+
+template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+bool interval_set<DomainT,Interval,Compare,Alloc>::contains_(const interval_type& x)const
+{
+ // Emptiness is contained in everything
+ if(x.empty())
+ return true;
+ else if (this->empty())
+ return false;
+ else if(x.upper() < this->lower())
+ return false;
+ else if(this->upper() < x.lower())
+ return false;
+ {
+ typename ImplSetT::const_iterator it = this->_set.find(x);
+ if(it == this->_set.end())
+ return false;
+ else
+ return x.contained_in(*it);
+ }
+}
+
+
+template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_set<DomainT,Interval,Compare,Alloc>::handle_neighbours(const iterator& it)
+{
+ if(it == this->_set.begin())
+ {
+ iterator it_nxt=it; it_nxt++;
+ if(it_nxt!=this->_set.end() && (*it).touches(*it_nxt))
+ joint_insert(it, it_nxt);
+ }
+ else
+ {
+ // there is a predecessor
+ iterator it_pred = it; it_pred-- ;
+
+ if((*it_pred).touches(*it))
+ {
+ iterator it_extended = joint_insert(it_pred, it);
+
+ iterator it_succ=it_extended; it_succ++;
+ if(it_succ!=this->_set.end())
+ {
+ // it's a non border element that might have two touching neighbours
+ if((*it_extended).touches(*it_succ))
+ joint_insert(it_extended, it_succ);
+ }
+ }
+ else
+ {
+ iterator it_succ=it; it_succ++;
+ if(it_succ!=this->_set.end())
+ {
+ // it's a non border element that might have a right touching neighbours
+ if((*it).touches(*it_succ))
+ joint_insert(it, it_succ);
+ }
+ }
+ }
+}
+
+
+
+template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+typename interval_set<DomainT,Interval,Compare,Alloc>::iterator
+ interval_set<DomainT,Interval,Compare,Alloc>
+ ::joint_insert(const iterator& left_it, const iterator& right_it)
+{
+ // both left and right are in the set and they are neighbours
+ BOOST_ASSERT((*left_it).excl_less(*right_it));
+ BOOST_ASSERT((*left_it).touches(*right_it));
+
+ interval_type curItv = (*left_it);
+ curItv.extend(*right_it);
+
+ this->_set.erase(left_it);
+ this->_set.erase(right_it);
+
+ iterator new_it = this->_set.insert(curItv).ITERATOR;
+ BOOST_ASSERT(new_it!=this->_set.end());
+ return new_it;
+}
+
+
+template<class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_set<DomainT,Interval,Compare,Alloc>::add_(const value_type& x)
+{
+ if(x.empty()) return;
+
+ std::pair<typename ImplSetT::iterator,bool> insertion = this->_set.insert(x);
+
+ if(insertion.WAS_SUCCESSFUL)
+ handle_neighbours(insertion.ITERATOR);
+ else
+ {
+ typename ImplSetT::iterator fst_it = this->_set.lower_bound(x);
+ typename ImplSetT::iterator end_it = this->_set.upper_bound(x);
+
+ typename ImplSetT::iterator it=fst_it, nxt_it=fst_it, victim;
+ Interval<DomainT> leftResid; (*it).left_surplus(leftResid,x);
+ Interval<DomainT> rightResid;
+
+ while(it!=end_it)
+ {
+ if((++nxt_it)==end_it)
+ (*it).right_surplus(rightResid,x);
+ victim = it; it++; this->_set.erase(victim);
+ }
+
+ Interval<DomainT> extended = x;
+ extended.extend(leftResid).extend(rightResid);
+ extended.extend(rightResid);
+ add(extended);
+ }
+}
+
+
+template<class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void interval_set<DomainT,Interval,Compare,Alloc>::subtract_(const value_type& x)
+{
+ if(x.empty()) return;
+ typename ImplSetT::iterator fst_it = this->_set.lower_bound(x);
+ if(fst_it==this->_set.end()) return;
+ typename ImplSetT::iterator end_it = this->_set.upper_bound(x);
+
+ typename ImplSetT::iterator it=fst_it, nxt_it=fst_it, victim;
+ interval_type leftResid; (*it).left_surplus(leftResid,x);
+ interval_type rightResid;
+
+ while(it!=end_it)
+ {
+ if((++nxt_it)==end_it) (*it).right_surplus(rightResid,x);
+ victim = it; it++; this->_set.erase(victim);
+ }
+
+ add(leftResid);
+ add(rightResid);
+}
+
+
+//-----------------------------------------------------------------------------
+// equality of elements
+//-----------------------------------------------------------------------------
+template <typename DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+inline bool is_element_equal(const interval_set<DomainT,Interval,Compare,Alloc>& lhs,
+ const interval_set<DomainT,Interval,Compare,Alloc>& rhs)
+{
+ return &lhs == &rhs || Set::lexicographical_equal(lhs, rhs);
+}
+
+template <class Type>
+struct is_set<itl::interval_set<Type> >
+{ enum{value = true}; };
+
+template <class Type>
+struct is_interval_container<itl::interval_set<Type> >
+{ enum{value = true}; };
+
+template <class Type>
+struct is_interval_splitter<itl::interval_set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct is_neutron_absorber<itl::interval_set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct is_neutron_emitter<itl::interval_set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct type_to_string<itl::interval_set<Type> >
+{
+ static std::string apply()
+ { return "interval_set<"+ type_to_string<Type>::apply() +">"; }
+};
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/interval_set_algo.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_set_algo.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,183 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_interval_set_algo_JOFA_081005_H__
+#define __itl_interval_set_algo_JOFA_081005_H__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl/type_traits/neutron.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class IntervalContainerT>
+typename IntervalContainerT::size_type continuous_cardinality(const IntervalContainerT& object)
+{
+ typedef typename IntervalContainerT::size_type size_type;
+
+ size_type size = neutron<size_type>::value();
+ size_type interval_size;
+ const_FORALL(typename IntervalContainerT, it, object)
+ {
+ interval_size = IntervalContainerT::key_value(it).continuous_cardinality();
+ if(interval_size == std::numeric_limits<size_type>::infinity())
+ return interval_size;
+ else
+ size += interval_size;
+ }
+ return size;
+}
+
+template <class IntervalContainerT>
+typename IntervalContainerT::size_type discrete_cardinality(const IntervalContainerT& object)
+{
+ typedef typename IntervalContainerT::size_type size_type;
+
+ size_type size = neutron<size_type>::value();
+ const_FORALL(typename IntervalContainerT, it, object)
+ size += IntervalContainerT::key_value(it).discrete_cardinality();
+ return size;
+}
+
+struct continuous_interval_container
+{
+ template<class IntervalContainerT>
+ static typename IntervalContainerT::size_type
+ cardinality(const IntervalContainerT& cont)
+ { return continuous_cardinality(cont); }
+};
+
+struct discrete_interval_container
+{
+ template<class IntervalContainerT>
+ static typename IntervalContainerT::size_type
+ cardinality(const IntervalContainerT& cont)
+ { return discrete_cardinality(cont); }
+};
+
+
+namespace Set
+{
+
+template<class LeftIntervalSetT, class RightIntervalSetT>
+class interval_set_sequence_tracker
+{
+public:
+ typedef typename LeftIntervalSetT::const_iterator LeftIterT;
+ typedef typename RightIntervalSetT::const_iterator RightIterT;
+
+ interval_set_sequence_tracker(const LeftIntervalSetT& left,
+ const RightIntervalSetT& right)
+ : _left(left), _right(right), _result(false)
+ {}
+
+ enum{nextboth, nextleft, nextright, leftaligned, stop};
+
+ bool result()const{ return _result; }
+
+ int proceed(LeftIterT& left, RightIterT& right)
+ {
+ if((*left).upper_equal(*right))
+ {
+ ++left;
+ ++right;
+ return nextboth;
+ }
+ else if((*left).upper_less(*right))
+ {
+ _prior_left = left;
+ ++left;
+ return nextleft;
+ }
+ else
+ {
+ _prior_right = right;
+ ++right;
+ return nextright;
+ }
+ }
+
+ int next_both(LeftIterT& left, RightIterT& right)
+ {
+ if(left == _left.end())
+ {
+ _result = (right == _right.end()) ? true : false;
+ return stop;
+ }
+
+ // left != _left.end()
+ if(right == _right.end())
+ return stop; //_result = false;
+
+ // The starting intervals have to begin equally
+ if(!(*left).lower_equal(*right))
+ return stop; //_result = false;
+
+ return leftaligned;
+ }
+
+ int next_left(LeftIterT& left, RightIterT& right)
+ {
+ if(left == _left.end())
+ return stop;
+ if(!(*_prior_left).touches(*left))
+ return stop; //_result = false;
+
+ return proceed(left, right);
+ }
+
+ int next_right(LeftIterT& left, RightIterT& right)
+ {
+ if(right == _right.end())
+ return stop;
+ if(!(*_prior_right).touches(*right))
+ return stop; //_result = false;
+
+ return proceed(left, right);
+ }
+
+private:
+ const LeftIntervalSetT& _left;
+ const RightIntervalSetT& _right;
+ LeftIterT _prior_left;
+ RightIterT _prior_right;
+ bool _result;
+};
+
+template<class LeftT, class RightT>
+bool is_element_equal(const LeftT& left, const RightT& right)
+{
+ if(left.empty())
+ return right.empty();
+ else if(right.empty())
+ return false;
+
+ typedef interval_set_sequence_tracker<LeftT,RightT> Step;
+ Step step(left, right);
+
+ typename LeftT::const_iterator left_ = left.begin();
+ typename RightT::const_iterator right_ = right.begin();
+
+ int state = Step::nextboth;
+ while(state != Step::stop)
+ {
+ switch(state){
+ case Step::nextboth: state = step.next_both(left_, right_); break;
+ case Step::nextleft: state = step.next_left(left_, right_); break;
+ case Step::nextright: state = step.next_right(left_, right_); break;
+ case Step::leftaligned: state = step.proceed(left_, right_); break;
+ }
+ }
+ return step.result();
+}
+
+} //Set
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl/interval_sets.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/interval_sets.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,468 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_interval_sets_hpp_JOFA_080930__
+#define __itl_interval_sets_hpp_JOFA_080930__
+
+#include <boost/itl/interval_base_set.hpp>
+#include <boost/itl/interval_set_algo.hpp>
+
+namespace boost{namespace itl
+{
+
+template<typename, template<class>class,
+ template<class>class, template<class>class>
+class interval_set;
+
+//-----------------------------------------------------------------------------
+// addition +=
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>&
+operator +=
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> set_type;
+ const_FORALL(typename set_type, elem_, operand)
+ object.add(*elem_);
+
+ return object;
+}
+
+//--- interval_type -----------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+IntervalSet<DomainT,Interval,Compare,Alloc>&
+operator +=
+(
+ IntervalSet<DomainT,Interval,Compare,Alloc>& object,
+ const typename IntervalSet<DomainT,Interval,Compare,Alloc>::interval_type& interval
+)
+{
+ return object.add(interval);
+}
+
+//--- domain_type -------------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+IntervalSet<DomainT,Interval,Compare,Alloc>&
+operator +=
+(
+ IntervalSet<DomainT,Interval,Compare,Alloc>& object,
+ const typename IntervalSet<DomainT,Interval,Compare,Alloc>::domain_type& value
+)
+{
+ return object.add(value);
+}
+
+
+//-----------------------------------------------------------------------------
+// difference -=
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>&
+operator -=
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
+ object.subtract(*elem_);
+
+ return object;
+}
+
+//--- interval_type -----------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+IntervalSet<DomainT,Interval,Compare,Alloc>&
+operator -=
+(
+ IntervalSet<DomainT,Interval,Compare,Alloc>& object,
+ const typename IntervalSet<DomainT,Interval,Compare,Alloc>::interval_type& interval
+)
+{
+ return object.subtract(interval);
+}
+
+//--- domain_type -------------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+IntervalSet<DomainT,Interval,Compare,Alloc>&
+operator -=
+(
+ IntervalSet<DomainT,Interval,Compare,Alloc>& object,
+ const typename IntervalSet<DomainT,Interval,Compare,Alloc>::domain_type& value
+)
+{
+ return object.subtract(value);
+}
+
+
+//-----------------------------------------------------------------------------
+// intersection *=
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>&
+operator *=
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> object_type;
+ typedef IntervalSet <DomainT,Interval,Compare,Alloc> operand_type;
+ object_type intersection;
+
+ if(operand.empty())
+ {
+ object.clear();
+ return object;
+ }
+
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ {
+ object.clear();
+ return object;
+ }
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ object.add_intersection(intersection, *it++);
+
+ object.swap(intersection);
+
+ return object;
+}
+
+//--- interval_type -----------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+IntervalSet<DomainT,Interval,Compare,Alloc>&
+operator *=
+(
+ IntervalSet<DomainT,Interval,Compare,Alloc>& object,
+ const typename IntervalSet<DomainT,Interval,Compare,Alloc>::interval_type& interval
+)
+{
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> object_type;
+ object_type intersection;
+
+ if(interval.empty())
+ {
+ object.clear();
+ return object;
+ }
+
+ object.add_intersection(intersection, interval);
+ object.swap(intersection);
+ return object;
+}
+
+//--- domain_type -------------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+IntervalSet<DomainT,Interval,Compare,Alloc>&
+operator *=
+(
+ IntervalSet<DomainT,Interval,Compare,Alloc>& object,
+ const typename IntervalSet<DomainT,Interval,Compare,Alloc>::domain_type& value
+)
+{
+ typedef typename IntervalSet<DomainT,Interval,Compare,Alloc>
+ ::interval_type interval_type;
+ return object *= interval_type(value);
+}
+
+//-----------------------------------------------------------------------------
+// is_element_equal
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+bool is_element_equal
+(
+ const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ return Set::is_element_equal(object, operand);
+}
+
+
+
+//-----------------------------------------------------------------------------
+// is_disjoint
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+bool is_disjoint
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> object_type;
+ typedef IntervalSet <DomainT,Interval,Compare,Alloc> operand_type;
+ object_type intersection;
+
+ if(operand.empty())
+ return true;
+
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return true;
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ {
+ object.add_intersection(intersection, *it++);
+ if(!intersection.empty())
+ return false;
+ }
+
+ return true;
+}
+
+template
+<
+ class SubType, class DomainT, class CodomainT,
+ class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, class, class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalMap
+>
+bool is_disjoint
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& operand
+)
+{
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> object_type;
+ typedef IntervalMap<DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> operand_type;
+ object_type intersection;
+
+ if(operand.empty())
+ return true;
+
+ typename operand_type::const_iterator common_lwb;
+ typename operand_type::const_iterator common_upb;
+
+ if(!Set::common_range(common_lwb, common_upb, operand, object))
+ return true;
+
+ typename operand_type::const_iterator it = common_lwb;
+ while(it != common_upb)
+ {
+ //JODO operand_type::key_value not working with gcc_3.4.4 (cygwin)
+ //object.add_intersection(intersection, operand_type::key_value(it++));
+ object.add_intersection(intersection, (it++)->KEY_VALUE);
+ if(!intersection.empty())
+ return false;
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// insert
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>&
+insert
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ return object += operand;
+}
+
+//-----------------------------------------------------------------------------
+// erase
+//-----------------------------------------------------------------------------
+template
+<
+ class SubType, class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+interval_base_set<SubType,DomainT,Interval,Compare,Alloc>&
+erase
+(
+ interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& object,
+ const IntervalSet <DomainT,Interval,Compare,Alloc>& operand
+)
+{
+ return object -= operand;
+}
+
+
+//-----------------------------------------------------------------------------
+// enclosure
+//-----------------------------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc,
+ template
+ <
+ class, template<class>class,
+ template<class>class, template<class>class
+ >
+ class IntervalSet
+>
+typename IntervalSet<DomainT,Interval,Compare,Alloc>::interval_type
+enclosure(const IntervalSet<DomainT,Interval,Compare,Alloc>& object)
+{
+ typedef IntervalSet<DomainT,Interval,Compare,Alloc> IntervalSetT;
+ typedef typename IntervalSetT::interval_type interval_type;
+ return
+ object.empty() ? neutron<interval_type>::value()
+ : (*object.begin()).span(*object.rbegin());
+}
+
+
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/map.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,551 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class itl::map
+ a general map class that extends stl-maps
+ for concepts InplaceAddable and InplaceSubtractable
+--------------------------------------------------------------------*/
+#ifndef __itl_map_h_JOFA_070519__
+#define __itl_map_h_JOFA_070519__
+
+#include <string>
+#include <boost/itl/notate.hpp>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/functors.hpp>
+#include <boost/itl/predicates.hpp>
+#include <boost/itl/set.hpp>
+#include <boost/itl/map_algo.hpp>
+#include <map>
+
+
+namespace boost{namespace itl
+{
+
+ struct neutron_absorber
+ {
+ enum { absorbs_neutrons = true };
+ enum { emits_neutrons = false };
+ };
+
+ template<>
+ inline std::string type_to_string<neutron_absorber>::apply() { return "@0"; }
+
+
+ struct neutron_enricher
+ {
+ enum { absorbs_neutrons = false };
+ enum { emits_neutrons = false };
+
+ };
+
+ template<>
+ inline std::string type_to_string<neutron_enricher>::apply() { return "e0"; }
+
+ struct neutron_emitter
+ {
+ enum { absorbs_neutrons = true };
+ enum { emits_neutrons = true };
+ };
+
+ template<>
+ inline std::string type_to_string<neutron_emitter>::apply() { return "^0"; }
+
+ struct neutron_emitter_and_enricher
+ {
+ enum { absorbs_neutrons = false };
+ enum { emits_neutrons = true };
+ };
+
+ template<>
+ inline std::string type_to_string<neutron_emitter_and_enricher>::apply() { return "e^0"; }
+
+
+ /*JODO move this comment to concept InplaceAddable, InplaceSubtractable, InplaceCombinable
+
+ Many features of the itl are based on the concept, that instances of
+ template parameter are InplaceAddable(InplaceSubtractible). That is,
+ operators += and -= are implemented.
+ */
+
+ /// an stl based map implementing inplace addition and subtraction operators += and -=
+ //JODO 1_0_1 documentation
+ /**
+
+ @author Joachim Faulhaber
+ */
+ template
+ <
+ typename KeyT,
+ typename DataT,
+ class Traits = itl::neutron_absorber,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+ >
+ class map: private std::map<KeyT, DataT, Compare<KeyT>,
+ Alloc<std::pair<const KeyT, DataT> > >
+ {
+ public:
+ typedef Alloc<typename std::pair<const KeyT, DataT> > allocator_type;
+
+ typedef typename itl::map<KeyT, DataT, Traits, Compare, Alloc> type;
+ typedef typename std::map<KeyT, DataT, Compare<KeyT>,
+ allocator_type> base_type;
+ typedef typename itl::set<KeyT, Compare, Alloc > set_type;
+
+ typedef itl::map<KeyT, DataT, itl::neutron_absorber, Compare, Alloc>
+ neutron_absorber_type;
+
+ typedef Traits traits;
+
+ public:
+ typedef KeyT key_type;
+ typedef KeyT domain_type;
+ typedef DataT mapped_type;
+ typedef DataT data_type;
+ typedef DataT codomain_type;
+ typedef std::pair<const KeyT, DataT> value_type;
+ typedef Compare<KeyT> key_compare;
+ typedef typename base_type::value_compare value_compare;
+
+ public:
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::size_type size_type;
+ typedef typename base_type::difference_type difference_type;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
+
+ public:
+ map(){}
+ map(const key_compare& comp): base_type(comp){}
+
+ template <class InputIterator>
+ map(InputIterator f, InputIterator l): base_type(f,l) {}
+
+ template <class InputIterator>
+ map(InputIterator f, InputIterator l, const key_compare& comp): base_type(f,l,comp) {}
+
+ map(const map& src): base_type::map(src){}
+
+ map& operator=(const map& src) { base_type::operator=(src); return *this; }
+ void swap(map& src) { base_type::swap(src); }
+
+ using base_type::begin;
+ using base_type::end;
+ using base_type::rbegin;
+ using base_type::rend;
+
+ using base_type::size;
+ using base_type::max_size;
+ using base_type::empty;
+
+ using base_type::key_comp;
+ using base_type::value_comp;
+
+ using base_type::insert;
+ using base_type::erase;
+ using base_type::clear;
+ using base_type::find;
+ using base_type::count;
+
+ using base_type::lower_bound;
+ using base_type::upper_bound;
+ using base_type::equal_range;
+
+ using base_type::operator[];
+
+ public:
+ inline static bool has_symmetric_difference()
+ { return itl::is_set<codomain_type>::value || !traits::absorbs_neutrons || traits::emits_neutrons; }
+
+ public:
+ // --------------------------------------------------------------------
+ // itl specific extensions
+
+ //JODO concept set
+ /** Checks if a key element is in the map */
+ bool contains(const KeyT& x)const { return !(find(x) == end()); }
+
+ /** Is <tt>*this</tt> contained in <tt>super</tt>? */
+ bool contained_in(const map& super)const
+ { return Map::contained_in(*this, super); }
+
+ /** Does <tt>*this</tt> contain <tt>sub</tt>? */
+ bool contains(const map& sub)const
+ { return Map::contained_in(sub, *this); }
+
+ std::pair<iterator,bool> insert(const value_type& value_pair)
+ {
+ if(Traits::absorbs_neutrons && value_pair.CONT_VALUE == DataT())
+ return std::pair<iterator,bool>(end(),true);
+ else
+ return base_type::insert(value_pair);
+ }
+
+ /** \c add inserts \c value_pair into the map if it's key does
+ not exist in the map.
+ If \c value_pairs's key value exists in the map, it's data
+ value is added to the data value already found in the map. */
+ iterator add(const value_type& value_pair) { return add<inplace_plus>(value_pair); }
+
+ template<template<class>class Combinator>
+ iterator add(const value_type& value_pair);
+
+ iterator operator += (const value_type& value_pair) { return add(value_pair); }
+
+ /** If the \c value_pair's key value is in the map, it's data value is
+ subtraced from the data value stored in the map. */
+ iterator subtract(const value_type& value_pair);
+
+ /** Add a map \c x2 to this map. If an element of \c x2 already exists
+ in \c *this, add up the contents using <tt>operator +=</tt>. */
+ map& operator += (const map& x2) { Set::add(*this, x2); return *this; }
+
+ /** Subtract a map \c x2 from this map. If an element of \c x2 already exists
+ in \c *this, subtract the contents using <tt>operator -=</tt>. */
+ map& operator -= (const map& x2)
+ {
+ if(Traits::emits_neutrons)
+ const_FORALL(typename map, it_, x2)
+ this->add<inplace_minus>(*it_);
+ else Set::subtract(*this, x2);
+ return *this;
+ }
+
+ /** Subtract a set \c x2 from this map. Every element of \c this map that
+ has a key that is element of \c x2 is deleted from the map. */
+ map& operator -= (const set_type& x2) { Set::erase(*this, x2); return *this; }
+
+ //JODO
+ /** erase the value pair \c pair(key,val) from the map.
+ Erase only if, the exact value content \c val is stored at key \key. */
+ size_type erase(const value_type& value);
+
+ //JODO
+ /** Intersect map \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+ map& operator *= (const map& x2)
+ { Map::intersect(*this, x2); return *this; }
+
+ /** Intersect set \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+ map& operator *= (const set_type& x2)
+ { Map::intersect(*this, x2); return *this; }
+
+ /** \c key_value allows for a uniform access to \c key_values which is
+ is used for common algorithms on sets and maps. */
+ template<typename IteratorT>
+ static const key_type& key_value(IteratorT& value_)
+ { return (*value_).first; }
+
+ /** \c data_value allows for a uniform access to \c data_values which is
+ is used for common algorithms on sets and maps. */
+ template<typename IteratorT>
+ static const data_type& data_value(IteratorT& value_){ return (*value_).second; }
+
+ /** \c key_less allows for a uniform notation of key comparison which
+ is used for common algorithms on sets and maps. */
+ template<typename LeftIterT, typename RightIterT>
+ static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
+ { return key_compare()((*lhs_).first,(*rhs_).first); }
+
+ /** \c iterative_size() yields the number of elements that is visited
+ throu complete iteration. For interval sets \c iterative_size() is
+ different from \c size(). */
+ static value_type make_element(const key_type& key_val, const data_type& data_val)
+ { return value_type(key_val, data_val); }
+
+ /** \c iterative_size() yields the number of elements that is visited
+ throu complete iteration. For interval sets \c iterative_size() is
+ different from \c size(). */
+ size_t iterative_size()const { return size(); }
+
+ void absorb_neutrons()
+ {
+ //content_is_neutron<key_type, data_type> neutron_dropper;
+ if(!Traits::absorbs_neutrons)
+ erase_if<content_is_neutron>();
+ }
+
+ /** Erase the elements in *this map to which property \c hasProperty applies.
+ Keep all the rest. */
+ template<template<class>class Predicate>
+ map& erase_if();
+
+ /** Copy the elements in map \c src to which property \c hasProperty applies
+ into \c *this map. */
+ template<template<class>class Predicate>
+ map& assign_if(const map& src);
+
+ /** Represent this map as string */
+ std::string as_string()const;
+ };
+
+
+ /** Standard equality, which is lexicographical equality of the sets
+ as sequences, that are given by their Compare order. */
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ inline bool operator == (const itl::map<KeyT,DataT,Traits,Compare,Alloc>& lhs,
+ const itl::map<KeyT,DataT,Traits,Compare,Alloc>& rhs)
+ {
+ typedef std::map<KeyT,DataT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ //JODO comment...
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ inline bool is_element_equal(const itl::map<KeyT,DataT,Traits,Compare,Alloc>& lhs,
+ const itl::map<KeyT,DataT,Traits,Compare,Alloc>& rhs)
+ {
+ typedef std::map<KeyT,DataT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ /** Protonic equality is equality on all elements that do not carry a neutron as content. */
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ inline bool is_protonic_equal (const itl::map<KeyT,DataT,Traits,Compare,Alloc>& lhs,
+ const itl::map<KeyT,DataT,Traits,Compare,Alloc>& rhs)
+ {
+ //JODO: Efficient implementation.
+ typedef std::map<KeyT,DataT,Compare<KeyT>,Alloc<KeyT> > base_type;
+
+ itl::map<KeyT,DataT,Traits,Compare,Alloc> lhs0 = lhs;
+ itl::map<KeyT,DataT,Traits,Compare,Alloc> rhs0 = rhs;
+ lhs0.absorb_neutrons();
+ rhs0.absorb_neutrons();
+ return operator==((const base_type&)lhs0, (const base_type&)rhs0);
+ }
+
+ /** Strict weak less ordering which is given by the Compare order */
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ inline bool operator < (const itl::map<KeyT,DataT,Traits,Compare,Alloc>& lhs,
+ const itl::map<KeyT,DataT,Traits,Compare,Alloc>& rhs)
+ {
+ typedef std::map<KeyT,DataT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator<((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ /** Partial ordering which is induced by Compare */
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ inline bool operator <= (const itl::map<KeyT,DataT,Traits,Compare,Alloc>& lhs,
+ const itl::map<KeyT,DataT,Traits,Compare,Alloc>& rhs)
+ {
+ typedef std::map<KeyT,DataT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator<=((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ template <template<class>class Combinator>
+ typename map<KeyT,DataT,Traits,Compare,Alloc>::iterator
+ map<KeyT,DataT,Traits,Compare,Alloc>::add(const value_type& val)
+ {
+ if(Traits::absorbs_neutrons && val.CONT_VALUE == DataT())
+ return end();
+
+ std::pair<iterator, bool> insertion;
+ if(Traits::emits_neutrons)
+ {
+ DataT added_val = DataT();
+ Combinator<DataT>()(added_val, val.CONT_VALUE);
+ insertion = insert(value_type(val.KEY_VALUE, added_val));
+ }
+ else // Existential case
+ insertion = insert(val);
+
+ if( insertion.WAS_SUCCESSFUL )
+ return insertion.ITERATOR ;
+ else
+ {
+ iterator it = insertion.ITERATOR;
+ Combinator<DataT>()((*it).CONT_VALUE, val.CONT_VALUE);
+
+ if(Traits::absorbs_neutrons && (*it).CONT_VALUE == DataT())
+ {
+ erase(it);
+ return end();
+ }
+ else
+ return it ;
+ }
+ }
+
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ typename map<KeyT,DataT,Traits,Compare,Alloc>::size_type
+ map<KeyT,DataT,Traits,Compare,Alloc>
+ ::erase(const value_type& value_pair)
+ {
+ if(Traits::absorbs_neutrons && value_pair.CONT_VALUE == DataT())
+ return 0; // neutrons are never contained 'substantially'
+ // only 'virually'.
+
+ iterator it_ = find(value_pair.KEY_VALUE);
+ if(it_ != end() && value_pair.CONT_VALUE == it_->CONT_VALUE)
+ {
+ erase(it_);
+ return 1;
+ }
+
+ return 0;
+ }
+
+
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ typename map<KeyT,DataT,Traits,Compare,Alloc>::iterator
+ map<KeyT,DataT,Traits,Compare,Alloc>::subtract(const value_type& val)
+ {
+ if(Traits::emits_neutrons)
+ return add<inplace_minus>(val);
+ else
+ {
+ iterator it_ = find(val.KEY_VALUE);
+ if(it_ != end())
+ {
+ (*it_).CONT_VALUE -= val.CONT_VALUE;
+
+ if(Traits::absorbs_neutrons && (*it_).CONT_VALUE == DataT())
+ {
+ erase(it_);
+ return end();
+ }
+ else
+ return it_;
+ }
+ return it_;
+ }
+ }
+
+
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ std::string map<KeyT,DataT,Traits,Compare,Alloc>::as_string()const
+ {
+ std::string repr;
+ const_FORALL_THIS(it) {
+ std::string elem("(");
+ elem += to_string<KeyT>::apply((*it).KEY_VALUE);
+ elem += "->";
+ elem += to_string<DataT>::apply((*it).CONT_VALUE);
+ elem += ")";
+
+ repr += elem;
+ }
+ return repr;
+ }
+
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Predicate>
+ map<KeyT,DataT,Traits,Compare,Alloc>& map<KeyT,DataT,Traits,Compare,Alloc>
+ ::erase_if()
+ {
+ iterator it = begin();
+ while(it != end())
+ if(Predicate<value_type>()(*it))
+ erase(it++);
+ else ++it;
+ return *this;
+ }
+
+
+ template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Predicate>
+ map<KeyT,DataT,Traits,Compare,Alloc>& map<KeyT,DataT,Traits,Compare,Alloc>
+ ::assign_if(const map<KeyT,DataT,Traits,Compare,Alloc>& src)
+ {
+ clear();
+ const_iterator it = src.begin();
+ while(it != src.end()) {
+ if(Predicate<value_type>(*it))
+ add(*it++);
+ }
+ return *this;
+ }
+ //-------------------------------------------------------------------------
+ template <typename KeyT, typename DataT, class Traits,
+ template<class>class Compare, template<class>class Alloc>
+ map<KeyT,DataT,Traits,Compare,Alloc>&
+ insert(map<KeyT,DataT,Traits,Compare,Alloc>& object,
+ const map<KeyT,DataT,Traits,Compare,Alloc>& insertee)
+ {
+ typedef map<KeyT,DataT,Traits,Compare,Alloc> map_type;
+
+ const_FORALL(typename map_type, elem_, insertee)
+ object.insert(*elem_);
+
+ return object;
+ }
+
+ template <typename KeyT, typename DataT, class Traits,
+ template<class>class Compare, template<class>class Alloc>
+ map<KeyT,DataT,Traits,Compare,Alloc>&
+ erase(map<KeyT,DataT,Traits,Compare,Alloc>& object,
+ const map<KeyT,DataT,Traits,Compare,Alloc>& erasee)
+ {
+ typedef map<KeyT,DataT,Traits,Compare,Alloc> map_type;
+
+ const_FORALL(typename map_type, elem_, erasee)
+ object.erase(*elem_);
+
+ return object;
+ }
+
+ //-------------------------------------------------------------------------
+ template <class KeyT, class DataT, class Traits>
+ struct is_interval_container<itl::map<KeyT,DataT,Traits> >
+ { enum{value = true}; };
+
+ template <class KeyT, class DataT, class Traits>
+ struct is_interval_splitter<itl::map<KeyT,DataT,Traits> >
+ { enum{value = false}; };
+
+ template <class KeyT, class DataT, class Traits>
+ struct is_neutron_absorber<itl::map<KeyT,DataT,Traits> >
+ { enum{value = Traits::absorbs_neutrons}; };
+
+ template <class KeyT, class DataT, class Traits>
+ struct is_neutron_emitter<itl::map<KeyT,DataT,Traits> >
+ { enum{value = Traits::emits_neutrons}; };
+
+ template <class KeyT, class DataT, class Traits>
+ struct type_to_string<itl::map<KeyT,DataT,Traits> >
+ {
+ static std::string apply()
+ {
+ return "map<"+ type_to_string<KeyT>::apply() + ","
+ + type_to_string<DataT>::apply() + ","
+ + type_to_string<Traits>::apply() +">";
+ }
+ };
+
+
+}} // namespace itl boost
+
+#endif // __itl_map_h_JOFA_070519__
+
Added: sandbox/itl/boost/itl/map_algo.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/map_algo.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,163 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_MAPALGO_H_JOFA_080225__
+#define __itl_MAPALGO_H_JOFA_080225__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl/set_algo.hpp>
+
+namespace boost{namespace itl
+{
+ namespace Map
+ {
+ template<class MapType>
+ bool contained_in(const MapType& sub, const MapType& super)
+ {
+ if(&super == &sub) return true;
+ if(sub.empty()) return true;
+ if(super.empty()) return false;
+ if(super.size() < sub.size() ) return false;
+ if(*sub.begin() < *super.begin()) return false;
+ if(*super.rbegin() < *sub.rbegin() ) return false;
+
+ typename MapType::const_iterator common_lwb_;
+ typename MapType::const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, sub, super))
+ return false;
+
+ typename MapType::const_iterator sub_ = sub.begin(), super_;
+ while(sub_ != sub.end())
+ {
+ super_ = super.find((*sub_).KEY_VALUE);
+ if(super_ == super.end())
+ return false;
+ else if(!(sub_->CONT_VALUE == super_->CONT_VALUE))
+ return false;
+ sub_++;
+ }
+ return true;
+ }
+
+ template<class MapType>
+ void intersection(MapType& y, const MapType& x1, const MapType& x2)
+ {
+ MapType tmp;
+ typename MapType::const_iterator i1 = x1.begin(), i2;
+
+ while(i1 != x1.end())
+ {
+ i2 = x2.find(i1->first);
+ if(i2 != x2.end())
+ {
+ tmp += *i1;
+ if(is_set<typename MapType::codomain_type>::value)
+ tmp *= *i2;
+ else
+ tmp += *i2;
+ }
+ i1++;
+ }
+ tmp.swap(y);
+ }
+
+ // optimized version
+ template<class MapType>
+ void intersect(MapType& result, const MapType& x1, const MapType& x2)
+ {
+ typename MapType::const_iterator common_lwb_;
+ typename MapType::const_iterator common_upb_;
+
+ result.clear();
+ if(!Set::common_range(common_lwb_, common_upb_, x1, x2))
+ return;
+
+ typename MapType::const_iterator x1_ = common_lwb_, x2_;
+
+ while(x1_ != common_upb_)
+ {
+ x2_ = x2.find((*x1_).KEY_VALUE);
+ if(x2_ != x2.end())
+ {
+ result.insert(*x1_);
+ if(is_set<typename MapType::data_type>::value)
+ result.template add<inplace_star>(*x2_); //MEMO template cast for gcc
+ else
+ result.template add<inplace_plus>(*x2_);
+ //result.template add<inplace_identity>(*x2_);
+ }
+ x1_++;
+ }
+ }
+
+ template<class MapType>
+ void intersect(MapType& result, const MapType& x2)
+ {
+ // result = result * x2;
+ MapType tmp;
+ intersect(tmp, result, x2);
+ tmp.swap(result);
+ }
+
+ // optimized version
+ template<class MapType, class SetType>
+ void intersect(MapType& result, const MapType& x1, const SetType& x2)
+ {
+ typename MapType::const_iterator common_lwb_;
+ typename MapType::const_iterator common_upb_;
+
+ result.clear();
+ if(!Set::common_range(common_lwb_, common_upb_, x1, x2))
+ return;
+
+ typename MapType::const_iterator x1_ = common_lwb_;
+ typename SetType::const_iterator common_;
+
+ while(x1_ != common_upb_)
+ {
+ common_ = x2.find((*x1_).KEY_VALUE);
+ if(common_ != x2.end())
+ result.insert(*x1_);
+
+ x1_++;
+ }
+ }
+
+ template<class MapType, class SetType>
+ void intersect(MapType& result, const SetType& x2) //JODO TEST
+ {
+ // result = result * x2;
+ MapType tmp;
+ intersect(tmp, result, x2);
+ tmp.swap(result);
+ }
+
+ } // namespace Map
+}} // namespace boost itl
+
+#endif
+
Added: sandbox/itl/boost/itl/notate.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/notate.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------
+ Macro definitions for useful and abstract notations e.g. iteration headers
+-----------------------------------------------------------------------------*/
+#ifndef __itl_NOTATE_H_JOFA_990119__
+#define __itl_NOTATE_H_JOFA_990119__
+
+
+// Iterations over stl or stl-compatible containers:
+#define FORALL(type,iter,obj) for(type::iterator iter=(obj).begin(); (iter)!=(obj).end(); (iter)++)
+#define const_FORALL(type,iter,obj) for(type::const_iterator iter=(obj).begin(); !((iter)==(obj).end()); (iter)++)
+
+#define FORALL_THIS(iter) for(iterator iter=begin(); (iter)!=end(); (iter)++)
+#define const_FORALL_THIS(iter) for(const_iterator iter=this->begin(); (iter)!=this->end(); (iter)++)
+
+// Plain old array iteration (assuming memberfunction VecT::size()!)
+#define FORALL_VEC(idx, vec) for(int idx=0; idx<vec.size(); idx++)
+
+// Parallel iteration
+#define const_FORALL_THIS_2(it, it2, cnt2)\
+ for(const_iterator it=begin(), it2=(cnt2).begin(); (it)!=end() && (it2)!=cnt2.end(); (it)++, (it2)++)
+#define const_FORALL_THIS_PARALLEL(it, it2, cnt2)\
+ for(const_iterator it=begin(), it2=(cnt2).begin(); (it)!=end() && (it2)!=cnt2.end(); (it)++, (it2)++)
+
+// Variants that requires already declared iterators
+#define FOR_ALL(iter,obj) for((iter)=(obj).begin(); (iter)!=(obj).end(); (iter)++)
+#define FOR_ALL_THIS(iter) for((iter)=this->begin(); (iter)!=this->end(); (iter)++)
+
+#define FOR_ALL2(iter1,obj1, iter2,obj2)\
+ for((iter1)=(obj1).begin(), (iter2)=(obj2).begin(); (iter1)!=(obj1).end(); ++(iter1),++(iter2))
+
+// for readability and ease of memory: pair selectors for different contexts
+#define ITERATOR first // x.insert(y).second
+#define WAS_SUCCESSFUL second
+
+#define KEY_VALUE first // for map valuePairs
+#define CONT_VALUE second
+
+// universal and maths
+namespace boost{namespace itl
+{
+ const int UNDEFINED_INDEX = -1;
+}} // namespace itl boost
+
+
+#endif // __itl_NOTATE_H_JOFA_990119__
+
+
Added: sandbox/itl/boost/itl/predicates.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/predicates.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,158 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+Predicates
+ general classes for Predicates
+--------------------------------------------------------------------*/
+#ifndef __itl_predicates_H_JOFA_990224__
+#define __itl_predicates_H_JOFA_990224__
+
+#include <functional>
+#include <boost/itl/type_traits/type_to_string.hpp>
+
+namespace boost{namespace itl
+{
+ // naming convention
+ // predicate: n-ary predicate
+ // property: unary predicate
+ // relation: binary predicate
+
+ // Unary predicates
+
+ template <class Type>
+ class property : public std::unary_function<Type,bool>{};
+
+ template <class Type>
+ class member_property : public property<Type>
+ {
+ public:
+ member_property( bool(Type::* pred)()const ): property<Type>(), m_pred(pred){}
+ bool operator()(const Type& x)const { return (x.*m_pred)(); }
+ private:
+ bool(Type::* m_pred)()const;
+ } ;
+
+ template <class Type>
+ class empty: public property<Type>
+ {
+ public:
+ bool operator() (const Type& x)const { return x.empty(); }
+ } ;
+
+ template <class Type>
+ struct is_neutron: public property<Type>
+ {
+ bool operator() (const Type& x)const { return x == Type(); }
+ } ;
+
+ template <class Type>
+ class content_is_neutron: public property<Type>
+ {
+ public:
+ bool operator() (const Type& x)const
+ { return x.second == Type::second_type(); }
+ } ;
+
+
+ // Binary predicates: relations
+
+ template <class LeftT, class RightT>
+ class relation : public std::binary_function<LeftT,RightT,bool>{};
+
+ template <class Type> struct std_equal : public relation<Type,Type>
+ {
+ bool operator()(const Type& lhs, const Type& rhs)const
+ {
+ return lhs == rhs;
+ }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<itl::std_equal>::apply()
+ { return "=="; }
+
+ template <class Type>
+ struct element_equal : public relation<Type,Type>
+ {
+ bool operator()(const Type& lhs, const Type& rhs)const
+ {
+ return is_element_equal(lhs, rhs);
+ }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<itl::element_equal>::apply()
+ { return "="; }
+
+ template <class Type>
+ struct protonic_equal : public relation<Type,Type>
+ {
+ bool operator()(const Type& lhs, const Type& rhs)const
+ {
+ return is_protonic_equal(lhs, rhs);
+ }
+ };
+
+ template<>
+ inline std::string unary_template_to_string<itl::protonic_equal>::apply()
+ { return "==/0"; }
+
+
+
+ /// Functor class template contained_in implements the subset relation.
+ template<class Type>
+ struct contained_in : public relation<Type,Type>
+ {
+ /// Apply the subset relation.
+ /** <tt>contained_in(sub, super)</tt> is true if <tt>sub</tt>
+ is contained in <tt>super</tt> */
+ bool operator()(const Type& sub, const Type& super)const
+ {
+ return sub.contained_in(super);
+ }
+ };
+
+ /// Functor class template <b>containes</b> implements the superset relation.
+ template<class Type>
+ struct containes : public relation<Type,Type>
+ {
+ /// Apply the superset relation.
+ /** <tt>containes(super, sub)</tt> is true if <tt>super</tt> containes
+ <tt>sub</tt> */
+ bool operator()(const Type& super, const Type& sub)const
+ {
+ return super.containes(sub);
+ }
+ };
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl/ptime.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/ptime.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,75 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------
+itl_ptime provides adapter code for boost::posix_time::ptime.
+It implements incrementation (++) decrementation (--) and a neutral element
+w.r.t. addition (neutron()).
+-----------------------------------------------------------------------------*/
+
+#ifndef __itl_ptime_JOFA_080416_H__
+#define __itl_ptime_JOFA_080416_H__
+
+#include <stdio.h>
+#include <string>
+#include <sstream>
+
+#include <boost/date_time/posix_time/posix_time.hpp>
+
+//JODO Produce a better compietime error here.
+//JODO (Write Macro to reduce codereplication. Generate line info.) not needed if compile-time error is nifty.
+//JODO Make it complete for all date_time classes. check portability.
+#ifdef ITL_NEUTRONS_PROVIDED
+#pragma message("error: No neutral element provided for type boost::posix_time::ptime")
+#pragma message(".. please #include <boost/itl/ptime.hpp> PRIOR TO other itl/* classes")
+"JODO: Compiletime error has to be produced, but in a nicer way."
+#endif
+
+#ifdef ITL_DIFFERENCE_TYPES_PROVIDED
+#pragma message("error: No difference type provided for type boost::posix_time::ptime")
+#pragma message(".. please #include <boost/itl/ptime.hpp> PRIOR TO other itl/* classes")
+#endif
+
+#ifdef ITL_SIZE_TYPES_PROVIDED
+#pragma message("error: No size type provided for type boost::posix_time::ptime")
+#pragma message(".. please #include <boost/itl/ptime.hpp> PRIOR TO other itl/* classes")
+#endif
+
+#define ITL_NEEDS_POSIX_TIME_PTIME_NEUTRON_VALUE
+#define ITL_NEEDS_POSIX_TIME_PTIME_DIFFERENCE_TYPE
+#define ITL_NEEDS_POSIX_TIME_PTIME_SIZE_TYPE
+
+namespace boost{namespace itl
+{
+
+ // ------------------------------------------------------------------------
+ boost::posix_time::ptime operator ++(boost::posix_time::ptime& x)
+ {
+ return x += boost::posix_time::ptime::time_duration_type::unit();
+ }
+
+ boost::posix_time::ptime operator --(boost::posix_time::ptime& x)
+ {
+ return x -= boost::posix_time::ptime::time_duration_type::unit();
+ }
+
+ // ------------------------------------------------------------------------
+ boost::posix_time::time_duration operator ++(boost::posix_time::time_duration& x)
+ {
+ return x += boost::posix_time::ptime::time_duration_type::unit();
+ }
+
+ boost::posix_time::time_duration operator --(boost::posix_time::time_duration& x)
+ {
+ return x -= boost::posix_time::ptime::time_duration_type::unit();
+ }
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/rational.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/rational.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,24 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------
+itl_ptime provides adapter code for boost::posix_time::ptime.
+It implements incrementation (++) decrementation (--) and a neutral element
+w.r.t. addition (neutron()).
+-----------------------------------------------------------------------------*/
+
+#ifndef __itl_rational_JOFA_080913_H__
+#define __itl_rational_JOFA_080913_H__
+
+#include <boost/rational.hpp>
+
+#define ITL_NEEDS_RATIONAL_IS_CONTINUOUS
+
+#endif
+
+
Added: sandbox/itl/boost/itl/separate_interval_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/separate_interval_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,306 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_separate_interval_set_h_JOFA_080608__
+#define __itl_separate_interval_set_h_JOFA_080608__
+
+#include <boost/assert.hpp>
+#include <boost/itl/interval_base_set.hpp>
+#include <boost/itl/interval_set.hpp>
+
+namespace boost{namespace itl
+{
+
+/// Implements a set as a set of intervals - leaving adjoining intervals separate
+/**
+ Template-class <b>split_interval_set</b>
+ implements a set as a set of intervals - bordering interval bounds are not merged
+
+ Template parameter <b>DomainT</b>: The set's domain-type. Type of the
+ set's elements.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Template parameter <b>Interval=itl::interval</b>: Type of interval used
+ to implement the set. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>split_interval_set</b> implements a set <tt>set<DomainT></tt> as a set of intervals
+ <tt>set<interval<DomainT>></tt>. Intervals will not be <b>not</b> merged on
+ insertion, if they border each other or overlap. The inserted intervalls will be
+ be preserved.
+
+ interval_base_set<DomainT> can thus be used like a set. As it is known from mathematics
+ the union over a set of intervls is a set itself.
+
+ <b>Class <tt>interval_set</tt> yields the following benefits: </b>
+
+ <ul>
+ <li>
+ A set of intervals is conceived as a set. The complexity involved with
+ operations on intervals and sets of intervals is encapsulated.
+ The user of the class who
+ wants to perform set operations on sets of intervals is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_set</b> gives an efficient implementation of sets consisting
+ of larger contiguous chunks. Very large, even uncountably infinite sets of
+ elements can be represented in a compact way and handled efficiently.
+ </ul>
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+ These functions are tagged in the documentation.
+
+ @author Joachim Faulhaber
+
+*/
+template
+<
+ typename DomainT,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+>
+class separate_interval_set:
+ public interval_base_set<separate_interval_set<DomainT,Interval,Compare,Alloc>,
+ DomainT,Interval,Compare,Alloc>
+{
+public:
+ // inherit all typedefs
+
+ typedef interval_base_set<itl::separate_interval_set<DomainT,Interval,Compare,Alloc>,
+ DomainT,Interval,Compare,Alloc> base_type;
+
+ typedef separate_interval_set<DomainT,Interval,Compare,Alloc> type;
+
+ typedef interval_set<DomainT,Interval,Compare,Alloc> joint_type;
+
+ /// The domain type of the set
+ typedef DomainT domain_type;
+ /// The codomaintype is the same as domain_type
+ typedef DomainT codomain_type;
+
+ /// The interval type of the set
+ typedef Interval<DomainT> interval_type;
+
+ /// Comparison functor for domain values
+ typedef Compare<DomainT> domain_compare;
+ /// Comparison functor for intervals
+ typedef exclusive_less<interval_type> interval_compare;
+
+ /// Comparison functor for keys
+ typedef exclusive_less<interval_type> key_compare;
+
+ /// The allocator type of the set
+ typedef Alloc<interval_type> allocator_type;
+
+ /// allocator type of the corresponding element set
+ typedef Alloc<DomainT> domain_allocator_type;
+
+ /// The type of the set of elements that is equivalent to the set of intervals
+ typedef typename itl::set<DomainT,Compare,Alloc> element_set;
+
+ /// The corresponding atomized type representing this interval container of elements
+ typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
+
+ /// Container type for the implementation
+ typedef typename itl::set<interval_type,exclusive_less,Alloc> ImplSetT;
+
+ /// key type of the implementing container
+ typedef typename ImplSetT::key_type key_type;
+ /// data type of the implementing container
+ typedef typename ImplSetT::data_type data_type;
+ /// value type of the implementing container
+ typedef typename ImplSetT::value_type value_type;
+
+ /// iterator for iteration over intervals
+ typedef typename ImplSetT::iterator iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplSetT::const_iterator const_iterator;
+
+
+
+
+ // B: Constructors, destructors, assignment
+ /// Default constructor for the empty set
+ separate_interval_set(): base_type() {}
+ /// Copy constructor
+ separate_interval_set(const separate_interval_set& src): base_type(src) {}
+
+ /// Copy constructor for base_type
+ template<class SubType>
+ separate_interval_set
+ (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ { assign(src); }
+
+ /// Constructor for a single element
+ explicit separate_interval_set(const domain_type& elem): base_type() { add(elem); }
+ /// Constructor for a single interval
+ explicit separate_interval_set(const interval_type& itv): base_type() { add(itv); }
+
+ /// Assignment operator
+ template<class SubType>
+ separate_interval_set& operator =
+ (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ { assign(src); return *this; }
+
+ /// Does the set contain the interval <tt>x</tt>?
+ bool contains_(const interval_type& x)const;
+
+ /// Assignment from a base interval_set.
+ template<class SubType>
+ void assign(const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ {
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> base_set_type;
+ this->clear();
+ // Can be implemented via _set.insert: Interval joining not necessary.
+ const_FORALL(typename base_set_type, it, src)
+ this->_set.insert(*it);
+ }
+
+
+ /// Insertion of an interval <tt>x</tt>
+ void add_(const value_type& x);
+
+ /// Removal of an interval <tt>x</tt>
+ void subtract_(const value_type& x);
+
+ /// Treatment of adjoint intervals on insertion
+ void handle_neighbours(const iterator& it){}
+} ;
+
+
+template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+bool separate_interval_set<DomainT,Interval,Compare,Alloc>::contains_(const interval_type& interv)const
+{
+ if(interv.empty())
+ return true;
+
+ type section;
+ add_intersection(section, interv);
+ return is_element_equal(section, type(interv));
+}
+
+
+template<class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void separate_interval_set<DomainT,Interval,Compare,Alloc>::add_(const value_type& x)
+{
+ if(x.empty()) return;
+
+ std::pair<typename ImplSetT::iterator,bool> insertion = this->_set.insert(x);
+
+ if(insertion.WAS_SUCCESSFUL)
+ handle_neighbours(insertion.ITERATOR);
+ else
+ {
+ typename ImplSetT::iterator fst_it = this->_set.lower_bound(x);
+ typename ImplSetT::iterator end_it = this->_set.upper_bound(x);
+
+ typename ImplSetT::iterator it=fst_it, nxt_it=fst_it, victim;
+ Interval<DomainT> leftResid; (*it).left_surplus(leftResid,x);
+ Interval<DomainT> rightResid;
+
+ while(it!=end_it)
+ {
+ if((++nxt_it)==end_it)
+ (*it).right_surplus(rightResid,x);
+ victim = it; it++; this->_set.erase(victim);
+ }
+
+ Interval<DomainT> extended = x;
+ extended.extend(leftResid).extend(rightResid);
+ extended.extend(rightResid);
+ add_(extended);
+ }
+}
+
+
+template<class DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void separate_interval_set<DomainT,Interval,Compare,Alloc>::subtract_(const value_type& x)
+{
+ if(x.empty()) return;
+ typename ImplSetT::iterator fst_it = this->_set.lower_bound(x);
+ if(fst_it==this->_set.end()) return;
+ typename ImplSetT::iterator end_it = this->_set.upper_bound(x);
+
+ typename ImplSetT::iterator it=fst_it, nxt_it=fst_it, victim;
+ interval_type leftResid; (*it).left_surplus(leftResid,x);
+ interval_type rightResid;
+
+ while(it!=end_it)
+ {
+ if((++nxt_it)==end_it) (*it).right_surplus(rightResid,x);
+ victim = it; it++; this->_set.erase(victim);
+ }
+
+ add_(leftResid);
+ add_(rightResid);
+}
+
+
+//-----------------------------------------------------------------------------
+// equality of elements
+//-----------------------------------------------------------------------------
+template
+<
+ class DomainT, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc
+>
+inline bool
+is_element_equal
+(
+ const separate_interval_set<DomainT,Interval,Compare,Alloc>& lhs,
+ const separate_interval_set<DomainT,Interval,Compare,Alloc>& rhs
+)
+{
+ typedef itl::interval_set<DomainT,Interval,Compare,Alloc> joined_type;
+ if(&lhs == &rhs)
+ return true;
+ //OTHERWISE
+ joined_type joined_lhs(lhs);
+ joined_type joined_rhs(rhs);
+ return Set::lexicographical_equal(joined_lhs, joined_rhs);
+}
+
+template <class Type>
+struct is_set<itl::separate_interval_set<Type> >
+{ enum{value = true}; };
+
+template <class Type>
+struct is_interval_container<itl::separate_interval_set<Type> >
+{ enum{value = true}; };
+
+template <class Type>
+struct is_interval_splitter<itl::separate_interval_set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct is_neutron_absorber<itl::separate_interval_set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct is_neutron_emitter<itl::separate_interval_set<Type> >
+{ enum{value = false}; };
+
+template <class Type>
+struct type_to_string<itl::separate_interval_set<Type> >
+{
+ static std::string apply()
+ { return "separate_interval_set<"+ type_to_string<Type>::apply() +">"; }
+};
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,365 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ----------------------------------------------------------------------------
+class itl::set
+a general set class that extends stl-sets
+for concepts InplaceAddable and InplaceSubtractable
+-----------------------------------------------------------------------------*/
+#ifndef __itl_set_h_JOFA_070519__
+#define __itl_set_h_JOFA_070519__
+
+#include <string>
+#include <set>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/type_traits/is_set.hpp>
+#include <boost/itl/type_traits/is_interval_container.hpp>
+#include <boost/itl/type_traits/is_interval_splitter.hpp>
+#include <boost/itl/type_traits/is_neutron_absorber.hpp>
+#include <boost/itl/type_traits/is_neutron_emitter.hpp>
+#include <boost/itl/set_algo.hpp>
+#include <boost/itl/predicates.hpp>
+
+
+namespace boost{namespace itl
+{
+ /// adds inplace addition, subtraction and intersection to std::set
+ /**
+ Class template <b>itl::set</b> extends <b>std::set</b> by inplace operators
+ <b>+=, -= and *=</b>. These operations implement the fundamental set
+ functions union, difference and intersection.
+
+ In contrast to the classic stl style design, template parameters for set
+ ordering <b>Compare</b> and allocation <b>Alloc</b> are passed as template
+ template parameters. This allows for more flexible passing of those
+ parameters to derived types via typedef.
+
+ <b>Note</b> that itl::set provides all functionality of std::set via
+ private inheritence. This can not be seen in the documentation because
+ unfortunately doxygen does not evaluate using statements.
+
+ @author Joachim Faulhaber
+ */
+ template
+ <
+ typename KeyT,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+ >
+ class set: private std::set<KeyT, Compare<KeyT>, Alloc<KeyT> >
+ {
+ public:
+ typedef typename itl::set<KeyT, Compare, Alloc > type;
+ typedef typename std::set<KeyT, Compare<KeyT>, Alloc<KeyT> > base_type;
+
+ public:
+ typedef KeyT key_type;
+ typedef KeyT value_type;
+ typedef KeyT data_type;
+ typedef Compare<KeyT> key_compare;
+ typedef Compare<KeyT> value_compare;
+ typedef Alloc<KeyT> allocator_type;
+
+ public:
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::const_pointer const_pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::size_type size_type;
+ typedef typename base_type::difference_type difference_type;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
+
+ public:
+ set(){}
+ set(const Compare<KeyT>& comp):
+ std::set<KeyT, Compare<KeyT>, Alloc<KeyT> >(comp){}
+
+ template <class InputIterator>
+ set(InputIterator f, InputIterator l): std::set<InputIterator>(f,l) {}
+
+ template <class InputIterator>
+ set(InputIterator f, InputIterator l, const key_compare& comp): std::set<InputIterator>(f,l,comp) {}
+
+ set(const set& src): base_type::set(src){}
+
+ set& operator=(const set& src) { base_type::operator=(src); return *this; }
+ void swap(set& src) { base_type::swap(src); }
+
+ using base_type::begin;
+ using base_type::end;
+ using base_type::rbegin;
+ using base_type::rend;
+
+ using base_type::size;
+ using base_type::max_size;
+ using base_type::empty;
+
+ using base_type::key_comp;
+ using base_type::value_comp;
+
+ using base_type::insert;
+ using base_type::erase;
+ using base_type::clear;
+ using base_type::find;
+ using base_type::count;
+
+ using base_type::lower_bound;
+ using base_type::upper_bound;
+ using base_type::equal_range;
+
+ public:
+ // --------------------------------------------------------------------
+ // itl specific extensions
+
+ //JODO concept set
+ /// Checks if the element \c x is in the set
+ bool contains(const KeyT& x)const { return !(find(x) == end()); }
+
+ /** Is <tt>*this</tt> contained in <tt>super</tt>? */
+ bool contained_in(const set& super)const { return Set::contained_in(*this, super); }
+
+ /** Does <tt>*this</tt> contain <tt>sub</tt>? */
+ bool contains(const set& sub)const { return Set::contained_in(sub, *this); }
+
+ /** <tt>*this</tt> and <tt>x2</tt> are disjoint, if their intersection is empty */
+ bool disjoint(const set& x2)const { return disjoint(*this, x2); }
+
+ iterator add(const value_type& vp) { return insert(vp).ITERATOR; }
+ set& operator += (const value_type& vp) { insert(vp); return *this; }
+
+ // Default subtract-function using -= on CodomTV
+ iterator subtract(const value_type& vp);
+ set& operator -= (const value_type& vp) { subtract(vp); return *this; }
+
+ /// Add a set \c x2 to this set.
+ set& operator += (const set& x2) { Set::add(*this, x2); return *this; }
+
+ /// Subtract a set \c x2 from this set.
+ set& operator -= (const set& x2) { Set::subtract(*this, x2); return *this; }
+
+ /** Intersect set \c x2 \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+ set& operator *= (const set& x) { Set::intersect(*this, x); return *this; }
+
+ /** \c key_value allows for a uniform access to \c key_values which is
+ is used for common algorithms on sets and maps. */
+ template<typename IteratorT>
+ static const key_type& key_value(IteratorT& value_){ return (*value_); }
+
+ /** \c data_value allows for a uniform access to \c data_values which is
+ is used for common algorithms on sets and maps. */
+ template<typename IteratorT>
+ static const data_type& data_value(IteratorT& value_){ return (*value_); }
+
+ /** \c key_less allows for a uniform notation of key comparison which
+ is used for common algorithms on sets and maps. */
+ template<typename LeftIterT, typename RightIterT>
+ static bool key_less(LeftIterT& lhs_, RightIterT& rhs_)
+ { return key_compare()(*lhs_, *rhs_); }
+
+ /** \c make_element allows for a uniform notation of key comparison which
+ is used for common algorithms on sets and maps. */
+ static value_type make_element(const key_type& key_val, const data_type& data_val)
+ { return key_val; }
+
+ /** \c iterative_size() yields the number of elements that is visited
+ throu complete iteration. For interval sets \c iterative_size() is
+ different from \c size(). */
+ size_t iterative_size()const { return size(); }
+
+ /** Erase the elements in *this set to which property \c hasProperty applies.
+ Keep all the rest. */
+ template<template<class>class Predicate>
+ set& erase_if();
+
+ /** Copy the elements in set \c src to which property \c hasProperty applies
+ into \c *this set. */
+ template<template<class>class Predicate>
+ set& assign_if(const set& src);
+
+ /** Represent this set as a string */
+ std::string as_string(const char* sep = " ")const;
+ };
+
+
+ /** Standard equality, which is lexicographical equality of the sets
+ as sequences, that are given by their Compare order. */
+ template <typename KeyT, template<class>class Compare, template<class>class Alloc>
+ inline bool operator == (const itl::set<KeyT,Compare,Alloc>& lhs,
+ const itl::set<KeyT,Compare,Alloc>& rhs)
+ {
+ typedef std::set<KeyT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ /** Element equality. Two sets are equal if they contain the same
+ elements */
+ template <typename KeyT, template<class>class Compare,
+ template<class>class Alloc>
+ inline bool is_element_equal(const itl::set<KeyT,Compare,Alloc>& lhs,
+ const itl::set<KeyT,Compare,Alloc>& rhs)
+ {
+ typedef std::set<KeyT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ /** Strict weak less ordering which is given by the Compare order */
+ template <typename KeyT, template<class>class Compare,
+ template<class>class Alloc>
+ inline bool operator < (const itl::set<KeyT,Compare,Alloc>& lhs,
+ const itl::set<KeyT,Compare,Alloc>& rhs)
+ {
+ typedef std::set<KeyT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator<((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ /** Partial ordering which is induced by Compare */
+ template <typename KeyT, template<class>class Compare,
+ template<class>class Alloc>
+ inline bool operator <= (const itl::set<KeyT,Compare,Alloc>& lhs,
+ const itl::set<KeyT,Compare,Alloc>& rhs)
+ {
+ typedef std::set<KeyT,Compare<KeyT>,Alloc<KeyT> > base_type;
+ return operator<=((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+
+ template <typename KeyT, template<class>class Compare,
+ template<class>class Alloc>
+ typename set<KeyT,Compare,Alloc>::iterator
+ set<KeyT,Compare,Alloc>::subtract(const value_type& val)
+ {
+ iterator it_ = find(val);
+ if(it_ != end())
+ erase(it_);
+
+ return end();
+ }
+
+
+ template <typename KeyT, template<class>class Compare, template<class>class Alloc>
+ std::string set<KeyT,Compare,Alloc>::as_string(const char* sep)const
+ {
+ const_iterator it_ = begin();
+
+ if(it_ == end()) return std::string();
+ else
+ {
+ std::string y = to_string<KeyT>::apply(*it_++);
+ while(it_ != end()) { y += sep; y += to_string<KeyT>::apply(*it_++); }
+ return y;
+ }
+ }
+
+
+ template <typename KeyT, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Predicate>
+ set<KeyT,Compare,Alloc>& set<KeyT,Compare,Alloc>
+ ::erase_if()
+ {
+ iterator it = begin();
+ while(it != end())
+ if(Predicate<value_type>(*it))
+ erase(it++);
+ else ++it;
+ return *this;
+
+ }
+
+ template <typename KeyT, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Predicate>
+ set<KeyT,Compare,Alloc>& set<KeyT,Compare,Alloc>
+ ::assign_if(const set<KeyT,Compare,Alloc>& src)
+ {
+ clear();
+ const_iterator it = src.begin();
+ while(it != src.end()) {
+ if(Predicate<value_type>(*it))
+ add(*it++);
+ }
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ template <typename KeyT,
+ template<class>class Compare, template<class>class Alloc>
+ set<KeyT,Compare,Alloc>&
+ insert( set<KeyT,Compare,Alloc>& object,
+ const set<KeyT,Compare,Alloc>& insertee)
+ {
+ return object += insertee;
+ }
+
+ template <typename KeyT,
+ template<class>class Compare, template<class>class Alloc>
+ set<KeyT,Compare,Alloc>&
+ erase( set<KeyT,Compare,Alloc>& object,
+ const set<KeyT,Compare,Alloc>& erasee)
+ {
+ return object -= erasee;
+ }
+
+
+
+ //-------------------------------------------------------------------------
+ template <class Type>
+ struct is_set<itl::set<Type> >
+ { enum{value = true}; };
+
+ template <class Type>
+ struct is_interval_container<itl::set<Type> >
+ { enum{value = true}; };
+
+ template <class Type>
+ struct is_interval_splitter<itl::set<Type> >
+ { enum{value = false}; };
+
+ template <class Type>
+ struct is_neutron_absorber<itl::set<Type> >
+ { enum{value = false}; };
+
+ template <class Type>
+ struct is_neutron_emitter<itl::set<Type> >
+ { enum{value = false}; };
+
+ template <class Type>
+ struct type_to_string<itl::set<Type> >
+ {
+ static std::string apply()
+ { return "set<"+ type_to_string<Type>::apply() +">"; }
+ };
+
+
+}} // namespace itl boost
+
+#endif // __itl_set_h_JOFA_070519__
+
Added: sandbox/itl/boost/itl/set_algo.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/set_algo.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,262 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_set_algo_H_JOFA_990225__
+#define __itl_set_algo_H_JOFA_990225__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl/predicates.hpp>
+#include <boost/itl/functors.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.
+*/
+
+namespace boost{namespace itl
+{
+
+ namespace Set
+ {
+
+ 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
+ // the common range of x1 and x2.
+ typedef typename ConstObjectT::const_iterator ConstObject_iterator;
+
+ lwb = x1.end();
+ upb = x1.end();
+
+ if(x1.empty() || x2.empty())
+ return false;
+
+ IteratorT x1_fst_ = x1.begin();
+ IteratorT x1_lst_ = x1.end(); x1_lst_--;
+
+ ConstObject_iterator x2_fst_ = x2.begin();
+ 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}
+ return false;
+ if(key_less(ConstObjectT::key_value(x2_lst_), ObjectT::key_value(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_));
+
+ return true;
+ }
+
+ //JODO where to put common algorithms? namespace Collector, Ordered, Sorted, SortedObject
+
+
+ template<class ObjectT>
+ ObjectT& add(ObjectT& result, const ObjectT& x2)
+ {
+ if(&result == &x2)
+ return result;
+
+ typedef typename ObjectT::const_iterator Object_const_iterator;
+ for(Object_const_iterator x2_ = x2.begin(); x2_ != x2.end(); x2_++)
+ result += *x2_;
+
+ return result;
+ }
+
+ template<class ObjectT>
+ ObjectT& operator += (ObjectT& result, const ObjectT& x2)
+ { return Set::add(result, x2); }
+
+ //JODO CL
+ template<class ObjectT, class CoObjectT>
+ ObjectT& subtract(ObjectT& result, const CoObjectT& x2)
+ {
+ typename CoObjectT::const_iterator common_lwb_;
+ typename CoObjectT::const_iterator common_upb_;
+ if(!common_range(common_lwb_, common_upb_, x2, result))
+ return result;
+
+ typename CoObjectT::const_iterator x2_ = common_lwb_;
+ typename ObjectT::iterator common_;
+
+ while(x2_ != common_upb_)
+ result.subtract(*x2_++);
+
+ return result;
+ }
+
+ template<class ObjectT, class CoObjectT>
+ ObjectT& erase(ObjectT& result, const CoObjectT& x2)
+ {
+ typename CoObjectT::const_iterator common_lwb_;
+ typename CoObjectT::const_iterator common_upb_;
+ if(!common_range(common_lwb_, common_upb_, x2, result))
+ return result;
+
+ typename CoObjectT::const_iterator x2_ = common_lwb_;
+ typename ObjectT::iterator common_;
+
+ while(x2_ != common_upb_)
+ result.erase(*x2_++);
+
+ return result;
+ }
+
+
+ /** Function template <tt>contained_in</tt> implements the subset relation.
+ <tt>contained_in(sub, super)</tt> is true if <tt>sub</tt> is contained in <tt>super</tt> */
+ template<class SetType>
+ bool contained_in(const SetType& sub, const SetType& super)
+ {
+ if(&super == &sub) return true;
+ if(sub.empty()) return true;
+ if(super.empty()) return false;
+ if(*sub.begin() < *super.begin()) return false;
+ if(*super.rbegin() < *sub.rbegin() ) return false;
+
+ typename SetType::const_iterator common_lwb_;
+ typename SetType::const_iterator common_upb_;
+ if(!common_range(common_lwb_, common_upb_, sub, super))
+ return false;
+
+ typename SetType::const_iterator sub_ = common_lwb_, super_;
+ while(sub_ != common_upb_)
+ {
+ super_ = super.find(*sub_++);
+ if(super_ == super.end())
+ return false;
+ }
+ return true;
+ }
+
+ /** Function template <tt>lexicographical_equal</tt> implements
+ lexicographical equality. */
+ template<class SetType>
+ bool lexicographical_equal(const SetType& left, const SetType& right)
+ {
+ if(&left == &right) return true;
+ if(left.iterative_size() != right.iterative_size())
+ return false;
+
+ // so we have two sorted containers with equal element counts
+ typename SetType::const_iterator left_ = left.begin();
+ typename SetType::const_iterator right_ = right.begin();
+
+ while(left_ != left.end())
+ {
+ if(!(*left_==*right_))
+ return false;
+
+ ++left_; ++right_;
+ }
+
+ return true;
+ }
+
+
+ /** */
+ template<class SetType>
+ void intersect(SetType& result, const SetType& x1, const SetType& x2)
+ {
+ typename SetType::const_iterator common_lwb_;
+ typename SetType::const_iterator common_upb_;
+
+ result.clear();
+ if(!common_range(common_lwb_, common_upb_, x1, x2))
+ return;
+
+ typename SetType::const_iterator x1_ = common_lwb_, x2_;
+
+ while(x1_ != common_upb_)
+ {
+ x2_ = x2.find(*x1_++);
+ if(x2_ != x2.end())
+ result.insert(*x2_);
+ }
+ }
+
+ template<class SetType>
+ SetType& intersect(SetType& result, const SetType& x2)
+ {
+ SetType aux;
+ intersect(aux, result, x2);
+ aux.swap(result);
+ return result;
+ }
+
+
+ template<class SetType>
+ bool disjoint(const SetType& x1, const SetType& x2)
+ {
+ typename SetType::const_iterator common_lwb_;
+ typename SetType::const_iterator common_upb_;
+
+ if(!common_range(common_lwb_, common_upb_, x1, x2))
+ return true;
+
+ typename SetType::const_iterator x1_ = common_lwb_, x2_;
+
+ while(x1_ != common_upb_)
+ {
+ x2_ = x2.find(*x1_++);
+ if(x2_ != x2.end()) return false; // found a common element
+ }
+ // found no common element
+ return true;
+ }
+
+ template<class SetType>
+ void subtract(SetType& result, const SetType& x1, const SetType& x2)
+ {
+ SetType temp;
+ typename SetType::const_iterator x1_ = x1.begin(), x2_;
+
+ if(&x1 != &x2)
+ while(x1_ != x1.end())
+ {
+ x2_ = x2.find(*x1_);
+ if(x2_ == x2.end())
+ temp.insert(*x1_);
+ ++x1_;
+ }
+ temp.swap(result);
+ }
+
+ } // namespace Set
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl/split_interval_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/split_interval_map.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,833 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/* ------------------------------------------------------------------
+class split_interval_map
+--------------------------------------------------------------------*/
+#ifndef __split_interval_map_h_JOFA_000706__
+#define __split_interval_map_h_JOFA_000706__
+
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl/interval_map.hpp>
+#include <boost/itl/interval_base_map.hpp>
+#include <boost/itl/interval_maps.hpp>
+#include <boost/itl/split_interval_set.hpp>
+
+namespace boost{namespace itl
+{
+
+ /// implements a map as a map of intervals - on insertion overlapping intervals are split and associated values are combined.
+ /**
+ Template-class <b>split_interval_map</b>
+ implements a map as a map of intervals - On insertion overlapping intervals are
+ <b>split</b> and associated values are combined.
+
+ Template parameter <b>DomainT</b>: Domain type of the map. Also type of the
+ map's keys.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Datatypes for the codomain parameter have to <b>implement</b> operations
+ <tt>+=</tt>, <tt>-=</tt>, <tt>==</tt> (equality) and <tt>CodomainT()</tt> (default constructor).
+
+ The default constructor <tt>CodomainT()</tt> has to contruct a neutral element
+ such that the following holds:
+
+ If <tt>x = y; y += CodomainT();</tt> then <tt>x==y;</tt> and
+ If <tt>x = y; y -= CodomainT();</tt> then <tt>x==y;</tt>
+
+ Template parameter <b>Interval=itl::interval</b>: Template type of interval used
+ to implement the map. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>split_interval_map</b> implements a map <tt>map<DomainT, CodomainT></tt> as a map
+ of intervals <tt>map<interval<DomainT>, CodomainT, ExclusiveLessT<Interval> ></tt>
+
+ Interval maps <tt>split_interval_map<DomainT,CodomainT></tt> can be used similar (and in many
+ aspects exactly like) common stl-maps. Unlike to stl-maps where you store
+ a value for every key an interval map stores a contents value for an interval of
+ keys. In it's degenerated form the key intervals contain a single element
+ only. Then the interval map works like a normal stl-map. But if you work in problem
+ domains where you associate values to large contiguous intervals, interval maps
+ are very useful and efficient.
+
+
+ Class <tt>interval_base_map</tt> yields the following benefits:
+
+ <ul>
+ <li> A set of intervals is conceived as the domain set of the map.
+ The complexity involved with
+ operations on intervals maps is encapsulated. The user of the class who
+ wants to perform operations on interval maps is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>split_interval_map</b> gives an efficient implementation of maps consisting
+ of larger contiguous chunks. Very large, even uncountably infinite maps
+ can be represented in a compact way and handled efficiently.
+ <li>
+ <b>split_interval_map</b> serves as a overlay- or collision-computer.
+ </ul>
+
+ <b>split_interval_map as overlay computer</b>
+
+ An object <tt>split_interval_map<int,int> overlays;</tt> computes the overlays or
+ collisions of intervalls which have been inserted into it, if they are
+ associated with the <tt>int</tt>-value <tt>1</tt> as the codommain value.
+
+ If a newly inserted interval overlaps with intervals which are already in the
+ map, the interval is split up at the borders of the collisions. The assiciated
+ values of the overlapping intervals are incremented by 1, thus counting
+ the numbers of overlaps.
+
+ If sets are used as codomain types, interval_maps will compute unions of
+ associated maps in case of interval collisions.
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+
+ These functions are tagged in the documentation. Using such functions
+ for continuous domain datatypes yields compiletime errors. C.f. getting
+ the <tt>first()</tt> element of a left open interval makes sense for intervals of
+ int but not for intervals of double.
+
+ @author Joachim Faulhaber
+ */
+ template
+ <
+ typename DomainT,
+ typename CodomainT,
+ class Traits = itl::neutron_absorber,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+ >
+ class split_interval_map:
+ public interval_base_map<split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>,
+ DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ {
+ public:
+ typedef Traits traits;
+ typedef split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc> type;
+ typedef interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc> joint_type;
+ typedef interval_base_map <split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>,
+ DomainT,CodomainT,Traits,Interval,Compare,Alloc> base_type;
+
+ typedef split_interval_map<DomainT,CodomainT,itl::neutron_absorber,Interval,Compare,Alloc>
+ neutron_absorber_type;
+
+ typedef Interval<DomainT> interval_type;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::base_value_type base_value_type;
+ typedef typename base_type::base_pair_type base_pair_type;
+ typedef typename base_type::ImplMapT ImplMapT;
+
+ typedef interval_set<DomainT,Interval,Compare,Alloc> interval_set_type;
+ typedef interval_set_type set_type;
+
+ /// Default constructor for the empty map
+ split_interval_map(): base_type() {}
+ /// Copy constructor
+ split_interval_map(const split_interval_map& src): base_type(src) {}
+
+ explicit split_interval_map(base_pair_type& base_pair): base_type()
+ { add(base_pair); }
+
+ explicit split_interval_map(const value_type& value_pair): base_type()
+ { add(value_pair); }
+
+ /// Assignment operator
+ template<class SubType>
+ split_interval_map& operator =
+ (const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& src)
+ { assign(src); return *this; }
+
+ /// Assignment from a base interval_map.
+ template<class SubType>
+ void assign(const interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc>& src)
+ {
+ typedef interval_base_map<SubType,DomainT,CodomainT,
+ Traits,Interval,Compare,Alloc> base_map_type;
+ this->clear();
+ // Can be implemented via _map.insert: Interval joining not necessary.
+ const_FORALL(typename base_map_type, it, src)
+ this->_map.insert(*it);
+ }
+
+ bool contains_(const value_type& x)const;
+
+
+ template<template<class>class Combinator>
+ void add_(const value_type&);
+
+ void add_(const value_type& value)
+ { add_<inplace_plus>(value); }
+
+ template<template<class>class Combinator>
+ void subtract_(const value_type&);
+
+ void subtract_(const value_type& value)
+ {
+ if(Traits::emits_neutrons)
+ add_<inplace_minus>(value);
+ else
+ subtract_<inplace_minus>(value);
+ }
+
+ void insert_(const value_type& value);
+ void erase_(const value_type& value);
+
+ void handle_neighbours(const iterator& it){}
+
+ //TESTCODE
+ void getResiduals(const interval_type& x_itv, interval_type& leftResid, interval_type& rightResid);
+
+ private:
+
+ void fill(const value_type&);
+
+ template<template<class>class Combinator>
+ void fill_gap(const value_type&);
+
+ template<template<class>class Combinator>
+ void add_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+
+ template<template<class>class Combinator>
+ void add_rear(const interval_type& x_itv, const CodomainT& x_val, iterator& it);
+
+ template<template<class>class Combinator>
+ void subtract_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+
+ void insert_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+ void insert_rear(const interval_type& x_itv, const CodomainT& x_val, iterator& it);
+
+ void erase_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it);
+ } ;
+
+
+ template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ bool split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::contains_(const value_type& interv_value)const
+ {
+ interval_type interv = interv_value.KEY_VALUE;
+ if(interv.empty())
+ return true;
+
+ type section;
+ add_intersection(section, interv);
+ return is_element_equal(section, type(interv_value));
+ }
+
+
+
+
+ template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>::getResiduals(const interval_type& x_itv, interval_type& leftResid, interval_type& rightResid)
+ {
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ iterator end_it = this->_map.upper_bound(x_itv);
+
+ if(fst_it==end_it)
+ {
+ leftResid.clear();
+ rightResid.clear();
+ return;
+ }
+
+ (*fst_it).KEY_VALUE.left_surplus(leftResid, x_itv);
+ iterator lst_it = fst_it; lst_it++;
+
+ if(lst_it==end_it)
+ {
+ rightResid.clear();
+ return;
+ }
+
+ lst_it=end_it; lst_it--;
+
+ (*lst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+ }
+
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::fill(const value_type& value)
+{
+ //collision free insert is asserted
+ if(value.KEY_VALUE.empty())
+ return;
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ return;
+ this->_map.insert(value);
+}
+
+template <typename DomainT, typename CodomainT, class Traits,
+ template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::fill_gap(const value_type& value)
+{
+ static Combinator<CodomainT> combine;
+ //collision free insert is asserted
+ if(value.KEY_VALUE.empty())
+ return;
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ return;
+
+ if(Traits::emits_neutrons)
+ {
+ CodomainT added_val = CodomainT();
+ combine(added_val, value.CONT_VALUE);
+ this->_map.insert(value_type(value.KEY_VALUE, added_val));
+ }
+ else
+ this->_map.insert(value);
+}
+
+//-----------------------------------------------------------------------------
+// add<Combinator>(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_(const value_type& x)
+{
+ static Combinator<CodomainT> combine;
+ const interval_type& x_itv = x.KEY_VALUE;
+
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ std::pair<iterator,bool> insertion;
+ if(Traits::emits_neutrons)
+ {
+ CodomainT added_val = CodomainT();
+ combine(added_val, x_val);
+ insertion = this->_map.insert(value_type(x_itv, added_val));
+ }
+ else
+ insertion = this->_map.insert(x);
+
+ if(!insertion.WAS_SUCCESSFUL)
+ {
+ // Detect the first and the end iterator of the collision sequence
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ iterator end_it = insertion.ITERATOR;
+ if(end_it != this->_map.end())
+ end_it++;
+ //assert(end_it == this->_map.upper_bound(x_itv));
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+ CodomainT cur_val = (*fst_it).CONT_VALUE ;
+
+
+ interval_type leadGap; x_itv.left_surplus(leadGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+ fill_gap<Combinator>(value_type(leadGap, x_val));
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ CodomainT cmb_val = cur_val;
+ combine(cmb_val, x_val);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // first == last
+
+ interval_type endGap; x_itv.right_surplus(endGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+ fill_gap<Combinator>(value_type(endGap, x_val));
+
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*fst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+
+ this->_map.erase(fst_it);
+ fill(value_type(leftResid, cur_val));
+ fill(value_type(interSec, cmb_val));
+ fill(value_type(rightResid, cur_val));
+ }
+ else
+ {
+ this->_map.erase(fst_it);
+ fill(value_type(leftResid, cur_val));
+ fill(value_type(interSec, cmb_val));
+
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(fst_itv);
+
+ add_rest<Combinator>(x_rest, x_val, snd_it, end_it);
+ }
+ }
+}
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it)
+{
+ static Combinator<CodomainT> combine;
+ iterator nxt_it = it; nxt_it++;
+ interval_type x_rest = x_itv, gap, common, cur_itv;
+
+ while(nxt_it!=end_it)
+ {
+ cur_itv = (*it).KEY_VALUE ;
+ x_rest.left_surplus(gap, cur_itv);
+
+ combine(it->CONT_VALUE, x_val);
+ fill_gap<Combinator>(value_type(gap, x_val));
+
+ if(Traits::absorbs_neutrons && it->CONT_VALUE == CodomainT())
+ this->_map.erase(it++);
+ else it++;
+
+ // shrink interval
+ x_rest.left_subtract(cur_itv);
+ nxt_it++;
+ }
+
+ add_rear<Combinator>(x_rest, x_val, it);
+}
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::add_rear(const interval_type& x_rest, const CodomainT& x_val, iterator& it)
+{
+ static Combinator<CodomainT> combine;
+ interval_type cur_itv = (*it).KEY_VALUE ;
+ CodomainT cur_val = (*it).CONT_VALUE ;
+
+ interval_type left_gap;
+ x_rest.left_surplus(left_gap, cur_itv);
+ fill_gap<Combinator>(value_type(left_gap, x_val));
+
+ interval_type common;
+ cur_itv.intersect(common, x_rest);
+
+ CodomainT cmb_val = cur_val;
+ combine(cmb_val, x_val);
+
+ interval_type end_gap;
+ x_rest.right_surplus(end_gap, cur_itv);
+ fill_gap<Combinator>(value_type(end_gap, x_val));
+
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type right_resid;
+ cur_itv.right_surplus(right_resid, x_rest);
+
+ this->_map.erase(it);
+ fill(value_type(common, cmb_val));
+ fill(value_type(right_resid, cur_val));
+}
+
+
+//-----------------------------------------------------------------------------
+// subtract<Combinator>(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::subtract_(const value_type& x)
+{
+ static Combinator<CodomainT> combine;
+ const interval_type& x_itv = x.KEY_VALUE;
+
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ if(fst_it==this->_map.end()) return;
+ iterator end_it = this->_map.upper_bound(x_itv);
+ if(fst_it==end_it) return;
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+ // must be copies because fst_it will be erased
+ CodomainT fst_val = (*fst_it).CONT_VALUE ;
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid;
+ fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ CodomainT cmb_val = fst_val;
+ combine(cmb_val, x_val);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*fst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+
+ this->_map.erase(fst_it);
+ fill(value_type(leftResid, fst_val));
+ fill(value_type(interSec, cmb_val));
+ fill(value_type(rightResid, fst_val));
+ }
+ else
+ {
+ // first AND NOT last
+ this->_map.erase(fst_it);
+ fill(value_type(leftResid, fst_val));
+ fill(value_type(interSec, cmb_val));
+
+ subtract_rest<Combinator>(x_itv, x_val, snd_it, end_it);
+ }
+}
+
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ template<template<class>class Combinator>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::subtract_rest(const interval_type& x_itv, const CodomainT& x_val, iterator& it, iterator& end_it)
+{
+ static Combinator<CodomainT> combine;
+ iterator nxt_it=it; nxt_it++;
+
+ while(nxt_it!=end_it)
+ {
+ CodomainT& cur_val = (*it).CONT_VALUE ;
+ combine(cur_val, x_val);
+
+ if(Traits::absorbs_neutrons && cur_val==CodomainT())
+ this->_map.erase(it++);
+ else it++;
+
+ nxt_it=it; nxt_it++;
+ }
+
+ // it refers the last overlaying intervals of x_itv
+ const interval_type& cur_itv = (*it).KEY_VALUE ;
+
+ interval_type rightResid;
+ cur_itv.right_surplus(rightResid, x_itv);
+
+ if(rightResid.empty())
+ {
+ CodomainT& cur_val = (*it).CONT_VALUE ;
+ combine(cur_val, x_val);
+ if(Traits::absorbs_neutrons && cur_val==CodomainT())
+ this->_map.erase(it);
+ }
+ else
+ {
+ CodomainT cur_val = (*it).CONT_VALUE ;
+ CodomainT cmb_val = cur_val ;
+ combine(cmb_val, x_val);
+ interval_type interSec;
+ cur_itv.intersect(interSec, x_itv);
+
+ this->_map.erase(it);
+ fill(value_type(interSec, cmb_val));
+ fill(value_type(rightResid, cur_val));
+ }
+}
+
+
+
+//-----------------------------------------------------------------------------
+// insert(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::insert_(const value_type& x)
+{
+ const interval_type& x_itv = x.KEY_VALUE;
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ std::pair<typename ImplMapT::iterator,bool>
+ insertion = this->_map.insert(x);
+
+ if(!insertion.WAS_SUCCESSFUL)
+ {
+ // Detect the first and the end iterator of the collision sequence
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ iterator end_it = insertion.ITERATOR;
+ if(end_it != this->_map.end())
+ end_it++;
+ //assert(end_it == this->_map.upper_bound(x_itv));
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+
+ interval_type leadGap; x_itv.left_surplus(leadGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+ fill_gap<inplace_plus>(value_type(leadGap, x_val));
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ interval_type endGap; x_itv.right_surplus(endGap, fst_itv);
+ // this is a new Interval that is a gap in the current map
+ fill_gap<inplace_plus>(value_type(endGap, x_val));
+ }
+ else
+ {
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(fst_itv);
+
+ insert_rest(x_rest, x_val, snd_it, end_it);
+ }
+ }
+}
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::insert_rest(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it, iterator& end_it)
+{
+ iterator nxt_it = it; nxt_it++;
+ interval_type x_rest = x_itv, gap, common, cur_itv;
+
+ for(; nxt_it!=end_it; ++it, ++nxt_it)
+ {
+ cur_itv = (*it).KEY_VALUE ;
+ x_rest.left_surplus(gap, cur_itv);
+ fill_gap<inplace_plus>(value_type(gap, x_val));
+ // shrink interval
+ x_rest.left_subtract(cur_itv);
+ }
+
+ insert_rear(x_rest, x_val, it);
+}
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval,
+ template<class>class Compare, template<class>class Alloc>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::insert_rear(const interval_type& x_rest, const CodomainT& x_val,
+ iterator& it)
+{
+ interval_type cur_itv = (*it).KEY_VALUE ;
+
+ interval_type left_gap;
+ x_rest.left_surplus(left_gap, cur_itv);
+ fill_gap<inplace_plus>(value_type(left_gap, x_val));
+
+ interval_type common;
+ cur_itv.intersect(common, x_rest);
+
+ interval_type end_gap;
+ x_rest.right_surplus(end_gap, cur_itv);
+ fill_gap<inplace_plus>(value_type(end_gap, x_val));
+}
+
+
+//-----------------------------------------------------------------------------
+// erase(pair(interval,value)):
+//-----------------------------------------------------------------------------
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::erase_(const value_type& x)
+{
+ const interval_type& x_itv = x.KEY_VALUE;
+ if(x_itv.empty())
+ return;
+
+ const CodomainT& x_val = x.CONT_VALUE;
+ if(Traits::absorbs_neutrons && x_val==CodomainT())
+ return;
+
+ iterator fst_it = this->_map.lower_bound(x_itv);
+ if(fst_it==this->_map.end()) return;
+ iterator end_it = this->_map.upper_bound(x_itv);
+ if(fst_it==end_it) return;
+
+ interval_type fst_itv = (*fst_it).KEY_VALUE ;
+ // must be copies because fst_it will be erased
+ CodomainT fst_val = (*fst_it).CONT_VALUE ;
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid;
+ fst_itv.left_surplus(leftResid, x_itv);
+
+ // handle special case for first
+
+ interval_type interSec;
+ fst_itv.intersect(interSec, x_itv);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*fst_it).KEY_VALUE.right_surplus(rightResid, x_itv);
+
+ if(!interSec.empty() && fst_val == x_val)
+ {
+ this->_map.erase(fst_it);
+ fill(value_type(leftResid, fst_val));
+ // erased: fill(value_type(interSec, cmb_val));
+ fill(value_type(rightResid, fst_val));
+ }
+ }
+ else
+ {
+ // first AND NOT last
+ if(!interSec.empty() && fst_val == x_val)
+ {
+ this->_map.erase(fst_it);
+ fill(value_type(leftResid, fst_val));
+ // erased: fill(value_type(interSec, cmb_val));
+ }
+
+ erase_rest(x_itv, x_val, snd_it, end_it);
+ }
+}
+
+
+template <typename DomainT, typename CodomainT, class Traits, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+void split_interval_map<DomainT,CodomainT,Traits,Interval,Compare,Alloc>
+ ::erase_rest(const interval_type& x_itv, const CodomainT& x_val,
+ iterator& it, iterator& end_it)
+{
+ iterator nxt_it=it; nxt_it++;
+
+ // For all intervals within loop: it->KEY_VALUE are contained_in x_itv
+ while(nxt_it!=end_it)
+ {
+ if((*it).CONT_VALUE == x_val)
+ this->_map.erase(it++);
+ else it++;
+
+ nxt_it=it; nxt_it++;
+ }
+
+ // it refers the last overlaying intervals of x_itv
+ interval_type cur_itv = (*it).KEY_VALUE ;
+ // Has to be a copy, cause 'it' will be erased
+ CodomainT cur_val = (*it).CONT_VALUE;
+
+ interval_type rightResid;
+ cur_itv.right_surplus(rightResid, x_itv);
+
+ if(rightResid.empty())
+ {
+ if(cur_val == x_val)
+ this->_map.erase(it);
+ }
+ else
+ {
+ interval_type interSec;
+ cur_itv.intersect(interSec, x_itv);
+
+ if(!interSec.empty() && cur_val == x_val)
+ {
+ this->_map.erase(it);
+ //erased: fill(value_type(interSec, cmb_val));
+ fill(value_type(rightResid, cur_val));
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// type traits
+//-----------------------------------------------------------------------------
+
+template <class KeyT, class DataT, class Traits>
+struct is_set<itl::split_interval_map<KeyT,DataT,Traits> >
+{ enum{value = true}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_interval_container<itl::split_interval_map<KeyT,DataT,Traits> >
+{ enum{value = true}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_interval_splitter<itl::split_interval_map<KeyT,DataT,Traits> >
+{ enum{value = true}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_neutron_absorber<itl::split_interval_map<KeyT,DataT,Traits> >
+{ enum{value = Traits::absorbs_neutrons}; };
+
+template <class KeyT, class DataT, class Traits>
+struct is_neutron_emitter<itl::split_interval_map<KeyT,DataT,Traits> >
+{ enum{value = Traits::emits_neutrons}; };
+
+template <class KeyT, class DataT, class Traits>
+struct type_to_string<itl::split_interval_map<KeyT,DataT,Traits> >
+{
+ static std::string apply()
+ {
+ return "sp_itv_map<"+ type_to_string<KeyT>::apply() + ","
+ + type_to_string<DataT>::apply() + ","
+ + type_to_string<Traits>::apply() +">";
+ }
+};
+
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl/split_interval_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/split_interval_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,480 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __split_interval_set_JOFA_990223__
+#define __split_interval_set_JOFA_990223__
+
+#include <boost/itl/interval_base_set.hpp>
+#include <boost/itl/interval_set.hpp>
+
+namespace boost{namespace itl
+{
+
+ /// implements a set as a set of intervals - on insertion overlapping intervals are split
+ /**
+ Template-class <b>split_interval_set</b>
+ implements a set as a set of intervals - bordering interval bounds are not merged
+
+ Template parameter <b>DomainT</b>: The set's domain-type. Type of the
+ set's elements.
+
+ Suitable as domain types are all datatypes that posess a partial order.
+ In particular all discrete atomic datatypes like <tt>int, short, long</tt> and
+ atomic pseudo-continuous datatypes <tt>float, double</tt> may be instantiated.
+
+ Template parameter <b>Interval=itl::interval</b>: Type of interval used
+ to implement the set. The default <b>itl::interval</b> uses the
+ interval class template that comes with this library. Own implementation of interval
+ classes are possible (but not trivial).
+
+ <b>split_interval_set</b> implements a set <tt>set<DomainT></tt> as a set of intervals
+ <tt>set<interval<DomainT>></tt>. Intervals will not be <b>not</b> merged on
+ insertion, if they border each other or overlap. The inserted intervalls will be
+ be preserved.
+
+ interval_base_set<DomainT> can thus be used like a set. As it is known from mathematics
+ the union over a set of intervls is a set itself.
+
+ <b>Class <tt>interval_set</tt> yields the following benefits: </b>
+
+ <ul>
+ <li>
+ A set of intervals is conceived as a set. The complexity involved with
+ operations on intervals and sets of intervals is encapsulated.
+ The user of the class who
+ wants to perform set operations on sets of intervals is no more concerned
+ with questions of overlapping, joining and bordering intervals.
+ <li>
+ <b>interval_set</b> gives an efficient implementation of sets consisting
+ of larger contiguous chunks. Very large, even uncountably infinite sets of
+ elements can be represented in a compact way and handled efficiently.
+ </ul>
+
+ <b>Restrictions: </b>
+
+ A small number of functions can only be used for <b>discrete</b> domain datatypes
+ (<tt>short, int, Date</tt> etc.) that implement operators <tt>++</tt> and <tt>--</tt>.
+ These functions are tagged in the documentation.
+
+ @author Joachim Faulhaber
+
+ */
+ template
+ <
+ typename DomainT,
+ template<class>class Interval = itl::interval,
+ template<class>class Compare = std::less,
+ template<class>class Alloc = std::allocator
+ >
+ class split_interval_set:
+ public interval_base_set<split_interval_set<DomainT,Interval,Compare,Alloc>,
+ DomainT,Interval,Compare,Alloc>
+ {
+ public:
+ typedef interval_base_set<itl::split_interval_set<DomainT,Interval,Compare,Alloc>,
+ DomainT,Interval,Compare,Alloc> base_type;
+
+ typedef split_interval_set<DomainT,Interval,Compare,Alloc> type;
+ typedef interval_set<DomainT,Interval,Compare,Alloc> joint_type;
+
+ /// The domain type of the set
+ typedef DomainT domain_type;
+ /// The codomaintype is the same as domain_type
+ typedef DomainT codomain_type;
+
+ /// The interval type of the set
+ typedef Interval<DomainT> interval_type;
+
+ /// Comparison functor for domain values
+ typedef Compare<DomainT> domain_compare;
+ /// Comparison functor for intervals
+ typedef exclusive_less<interval_type> interval_compare;
+
+ /// Comparison functor for keys
+ typedef exclusive_less<interval_type> key_compare;
+
+ /// The allocator type of the set
+ typedef Alloc<interval_type> allocator_type;
+
+ /// allocator type of the corresponding element set
+ typedef Alloc<DomainT> domain_allocator_type;
+
+ /// The type of the set of elements that is equivalent to the set of intervals
+ typedef typename itl::set<DomainT,Compare,Alloc> element_set;
+
+ /// The corresponding atomized type representing this interval container of elements
+ typedef typename itl::set<DomainT,Compare,Alloc> atomized_type;
+
+ /// Container type for the implementation
+ typedef typename itl::set<interval_type,exclusive_less,Alloc> ImplSetT;
+
+ /// key type of the implementing container
+ typedef typename ImplSetT::key_type key_type;
+ /// data type of the implementing container
+ typedef typename ImplSetT::data_type data_type;
+ /// value type of the implementing container
+ typedef typename ImplSetT::value_type value_type;
+
+ /// iterator for iteration over intervals
+ typedef typename ImplSetT::iterator iterator;
+ /// const_iterator for iteration over intervals
+ typedef typename ImplSetT::const_iterator const_iterator;
+
+
+
+ // B: Constructors, destructors, assignment
+ /// Default constructor for the empty set
+ split_interval_set(): base_type() {}
+ /// Copy constructor
+ split_interval_set(const split_interval_set& src): base_type(src) {}
+
+ /// Copy constructor for base_type
+ template<class SubType>
+ split_interval_set
+ (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ { assign(src); }
+
+ /// Constructor for a single element
+ explicit split_interval_set(const interval_type& elem): base_type() { add(elem); }
+ /// Constructor for a single interval
+ explicit split_interval_set(const domain_type& itv): base_type() { add(itv); }
+
+ /// Assignment operator
+ template<class SubType>
+ split_interval_set& operator =
+ (const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ { assign(src); return *this; }
+
+ /// Assignment from a base interval_set.
+ template<class SubType>
+ void assign(const interval_base_set<SubType,DomainT,Interval,Compare,Alloc>& src)
+ {
+ typedef interval_base_set<SubType,DomainT,Interval,Compare,Alloc> base_set_type;
+ this->clear();
+ // Can be implemented via _set.insert: Interval joining not necessary.
+ const_FORALL(typename base_set_type, it, src)
+ this->_set.insert(*it);
+ }
+
+ /// Does the set contain the interval <tt>x</tt>?
+ bool contains_(const interval_type& x)const;
+
+ /// Insertion of an interval <tt>x</tt>
+ void add_(const value_type& x);
+
+ /// Removal of an interval <tt>x</tt>
+ void subtract_(const value_type& x);
+
+ /// Treatment of adjoint intervals on insertion
+ void handle_neighbours(const iterator& it){}
+
+ private:
+ void insert_rest(const interval_type& x_itv, iterator& it, iterator& end_it);
+ void subtract_rest(const interval_type& x_itv, iterator& it, iterator& end_it);
+ } ;
+
+ /*
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ bool split_interval_set<DomainT,Interval,Compare,Alloc>::contains_(const interval_type& x)const
+ {
+ if(x.empty()) return true;
+
+ typename ImplSetT::const_iterator fst_it = this->_set.lower_bound(x);
+ typename ImplSetT::const_iterator end_it = this->_set.upper_bound(x);
+
+ interval_set<DomainT,Interval,Compare,Alloc> matchSet;
+ for(typename ImplSetT::const_iterator it=fst_it; it!=end_it; it++)
+ matchSet.add(*it);
+
+ interval_set<DomainT,Interval,Compare,Alloc> x_asSet;
+ x_asSet.add(x);
+ return x_asSet.contained_in(matchSet);
+ }
+ */
+
+
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ bool split_interval_set<DomainT,Interval,Compare,Alloc>::contains_(const interval_type& interv)const
+ {
+ if(interv.empty())
+ return true;
+
+ type section;
+ add_intersection(section, interv);
+ return is_element_equal(section, type(interv));
+ }
+
+
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ void split_interval_set<DomainT,Interval,Compare,Alloc>::add_(const value_type& x)
+ {
+ if(x.empty()) return;
+
+ std::pair<typename ImplSetT::iterator,bool> insertion = this->_set.insert(x);
+
+ if(!insertion.WAS_SUCCESSFUL)
+ {
+ iterator fst_it = this->_set.lower_bound(x);
+ iterator end_it = this->_set.upper_bound(x);
+
+ if(fst_it == this->_set.end())
+ fst_it = end_it;
+
+ iterator cur_it = fst_it ;
+ interval_type cur_itv = *cur_it;
+
+ interval_type leadGap; x.left_surplus(leadGap, cur_itv);
+ // this is a new Interval that is a gap in the current map
+ add_(leadGap);
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; cur_itv.left_surplus(leftResid, x);
+
+ // handle special case for first
+ interval_type interSec;
+ cur_itv.intersect(interSec, x);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // first == last
+
+ interval_type endGap; x.right_surplus(endGap, cur_itv);
+ // this is a new Interval that is a gap in the current map
+ add_(endGap);
+
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*cur_it).right_surplus(rightResid, x);
+
+ this->_set.erase(cur_it);
+ add_(leftResid);
+ add_(interSec);
+ add_(rightResid);
+ }
+ else
+ {
+ this->_set.erase(cur_it);
+ add_(leftResid);
+ add_(interSec);
+
+ // shrink interval
+ interval_type x_rest(x);
+ x_rest.left_subtract(cur_itv);
+
+ insert_rest(x_rest, snd_it, end_it);
+ }
+ }
+ }
+
+
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ void split_interval_set<DomainT,Interval,Compare,Alloc>::insert_rest(const interval_type& x_itv, iterator& it, iterator& end_it)
+ {
+ iterator nxt_it = it; nxt_it++;
+
+ interval_type cur_itv = *it;
+
+ interval_type newGap; x_itv.left_surplus(newGap, cur_itv);
+ // this is a new Interval that is a gap in the current map
+ add_(newGap);
+
+ interval_type interSec;
+ cur_itv.intersect(interSec, x_itv);
+
+ if(nxt_it==end_it)
+ {
+ interval_type endGap; x_itv.right_surplus(endGap, cur_itv);
+ // this is a new Interval that is a gap in the current map
+ add_(endGap);
+
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; cur_itv.right_surplus(rightResid, x_itv);
+
+ this->_set.erase(it);
+ add_(interSec);
+ add_(rightResid);
+ }
+ else
+ {
+ this->_set.erase(it);
+ add_(interSec);
+
+ // shrink interval
+ interval_type x_rest(x_itv);
+ x_rest.left_subtract(cur_itv);
+
+ insert_rest(x_rest, nxt_it, end_it);
+ }
+ }
+
+
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ void split_interval_set<DomainT,Interval,Compare,Alloc>::subtract_(const value_type& x)
+ {
+ if(x.empty()) return;
+ if(this->_set.empty()) return;
+
+ iterator fst_it;
+ if(x.exclusive_less(*(this->_set.begin())))
+ return;
+ if(x.lower() < this->_set.begin()->upper())
+ fst_it = this->_set.begin();
+ else
+ fst_it = this->_set.lower_bound(x);
+
+ if(fst_it==this->_set.end()) return;
+ iterator end_it = this->_set.upper_bound(x);
+ if(fst_it==end_it) return;
+
+ iterator cur_it = fst_it ;
+ interval_type cur_itv = *cur_it ;
+
+ // only for the first there can be a leftResid: a part of *it left of x
+ interval_type leftResid; cur_itv.left_surplus(leftResid, x);
+
+ // handle special case for first
+ interval_type interSec;
+ cur_itv.intersect(interSec, x);
+
+ iterator snd_it = fst_it; snd_it++;
+ if(snd_it == end_it)
+ {
+ // first == last
+ // only for the last there can be a rightResid: a part of *it right of x
+ interval_type rightResid; (*cur_it).right_surplus(rightResid, x);
+
+ this->_set.erase(cur_it);
+ add_(leftResid);
+ add_(rightResid);
+ }
+ else
+ {
+ // first AND NOT last
+ this->_set.erase(cur_it);
+ add_(leftResid);
+ subtract_rest(x, snd_it, end_it);
+ }
+ return;
+ }
+
+
+
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ void split_interval_set<DomainT,Interval,Compare,Alloc>::subtract_rest(const interval_type& x_itv, iterator& snd_it, iterator& end_it)
+ {
+ iterator it=snd_it, nxt_it=snd_it; nxt_it++;
+
+ while(nxt_it!=end_it)
+ {
+ { iterator victim; victim=it; it++; this->_set.erase(victim); }
+ nxt_it=it; nxt_it++;
+ }
+
+ // it refers the last overlaying intervals of x_itv
+ const interval_type& cur_itv = *it ;
+
+ interval_type rightResid; cur_itv.right_surplus(rightResid, x_itv);
+
+ if(rightResid.empty())
+ this->_set.erase(it);
+ else
+ {
+ interval_type interSec; cur_itv.intersect(interSec, x_itv);
+ this->_set.erase(it);
+ this->_set.insert(rightResid);
+ }
+ }
+
+
+
+
+
+ /** Equality on discrete interval sets. Discrete interval sets are equal, if
+ their elements are equal and their fragmentation is equal.
+ NOTE: This is not inline with the mathematical view.
+ We have a distiction between 'element equality' and 'lexicographical
+ equality'. */
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ inline bool operator == (const split_interval_set<DomainT,Interval,Compare,Alloc>& lhs,
+ const split_interval_set<DomainT,Interval,Compare,Alloc>& rhs)
+ {
+ //MEMO PORT: This implemetation worked with stlport, sgi and gnu
+ // implementations of the stl. But using MSVC-implementation
+ // results in runtime error! So I had to provide an independent
+ // safe implemetation.
+ //return std::equal(lhs.begin(), lhs.end(), rhs.begin());
+ return Set::lexicographical_equal(lhs, rhs);
+ }
+
+
+ template <typename DomainT, template<class>class Interval, template<class>class Compare, template<class>class Alloc>
+ inline bool operator < (const split_interval_set<DomainT,Interval,Compare,Alloc>& lhs,
+ const split_interval_set<DomainT,Interval,Compare,Alloc>& rhs)
+ {
+ split_interval_set<DomainT,Interval,Compare,Alloc> lhs_joined = lhs, rhs_joined = rhs;
+ lhs_joined.join(); rhs_joined.join();
+ return std::lexicographical_compare(
+ lhs_joined.begin(), lhs_joined.end(),
+ rhs_joined.begin(), rhs_joined.end(),
+ Compare<Interval<DomainT> >());
+ }
+
+ template <class Type>
+ struct is_set<itl::split_interval_set<Type> >
+ { enum{value = true}; };
+
+ template <class Type>
+ struct is_interval_container<itl::split_interval_set<Type> >
+ { enum{value = true}; };
+
+ template <class Type>
+ struct is_interval_splitter<itl::split_interval_set<Type> >
+ { enum{value = true}; };
+
+ template <class Type>
+ struct is_neutron_absorber<itl::split_interval_set<Type> >
+ { enum{value = false}; };
+
+ template <class Type>
+ struct is_neutron_emitter<itl::split_interval_set<Type> >
+ { enum{value = false}; };
+
+ template <class Type>
+ struct type_to_string<itl::split_interval_set<Type> >
+ {
+ static std::string apply()
+ { return "sp_itv_set<"+ type_to_string<Type>::apply() +">"; }
+ };
+
+}} // namespace itl boost
+
+#endif
+
+
+
Added: sandbox/itl/boost/itl/type_traits/difference.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/difference.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,40 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_difference_JOFA_080911_H__
+#define __itl_type_traits_difference_JOFA_080911_H__
+
+// I DO NOT #include boost/itl/itl_<date_time_adapter>.hpp here, because it
+// HAS TO be included by client code prior to this location.
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct difference;
+
+#ifdef ITL_NEEDS_GREGORIAN_DATE_DIFFERENCE_TYPE
+#define ITL_HAS_GREGORIAN_DATE_DIFFERENCE_TYPE
+ template<>
+ struct difference<boost::gregorian::date>
+ { typedef boost::gregorian::date_duration type; };
+#endif
+
+#ifdef ITL_NEEDS_POSIX_TIME_PTIME_DIFFERENCE_TYPE
+#define ITL_HAS_POSIX_TIME_PTIME_DIFFERENCE_TYPE
+ template<>
+ struct difference<boost::posix_time::ptime>
+ { typedef boost::posix_time::time_duration type; };
+#endif
+
+ template <class Type> struct difference{ typedef Type type; };
+
+}} // namespace boost itl
+
+#define ITL_DIFFERENCE_TYPES_PROVIDED
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/is_continuous.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_continuous.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_is_continuous_JOFA_080910_H__
+#define __itl_type_traits_is_continuous_JOFA_080910_H__
+
+#include <string>
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct is_continuous;
+
+ template<> struct is_continuous<float> { enum {value = true}; };
+ template<> struct is_continuous<double> { enum {value = true}; };
+ template<> struct is_continuous<std::string> { enum {value = true}; };
+
+#ifdef ITL_NEEDS_RATIONAL_IS_CONTINUOUS
+#define ITL_HAS_RATIONAL_IS_CONTINUOUS
+ template<class Integral>
+ struct is_continuous<boost::rational<Integral> > { enum {value = true}; };
+#endif
+
+ template <class Type> struct is_continuous{ enum {value = false}; };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/is_interval_container.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_interval_container.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,21 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_is_interval_container_JOFA_081004_H__
+#define __itl_type_traits_is_interval_container_JOFA_081004_H__
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct is_interval_container;
+
+ template <class Type> struct is_interval_container{ enum {value = false}; };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_interval_splitter.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,21 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_is_interval_splitter_JOFA_081004_H__
+#define __itl_type_traits_is_interval_splitter_JOFA_081004_H__
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct is_interval_splitter;
+
+ template <class Type> struct is_interval_splitter{ enum {value = false}; };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/is_neutron_absorber.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_neutron_absorber.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,21 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_is_neutron_absorber_JOFA_081004_H__
+#define __itl_type_traits_is_neutron_absorber_JOFA_081004_H__
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct is_neutron_absorber;
+
+ template <class Type> struct is_neutron_absorber{ enum {value = false}; };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/is_neutron_emitter.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_neutron_emitter.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,21 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_is_neutron_emitter_JOFA_081004_H__
+#define __itl_type_traits_is_neutron_emitter_JOFA_081004_H__
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct is_neutron_emitter;
+
+ template <class Type> struct is_neutron_emitter{ enum {value = false}; };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/is_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/is_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,21 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_is_set_JOFA_081004_H__
+#define __itl_type_traits_is_set_JOFA_081004_H__
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct is_set;
+
+ template <class Type> struct is_set{ enum {value = false}; };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/neutron.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/neutron.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,67 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_neutron_JOFA_080912_H__
+#define __itl_type_traits_neutron_JOFA_080912_H__
+
+#include <boost/itl/type_traits/type_to_string.hpp>
+
+// I DO NOT #include boost/itl/itl_<date_time_adapter>.hpp here, because it
+// HAS TO be included by client code prior to this location.
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct neutron
+ {
+ static Type value();
+ inline Type operator()()const { return value(); } //JODO everything static??
+ };
+
+#ifdef ITL_NEEDS_GREGORIAN_DATE_NEUTRON_VALUE
+#define ITL_HAS_GREGORIAN_DATE_NEUTRON_VALUE
+ template<>
+ inline boost::gregorian::date neutron<boost::gregorian::date>::value()
+ {
+ return boost::gregorian::date(boost::gregorian::min_date_time);
+ }
+
+ template<>
+ struct neutron<boost::gregorian::date_duration>
+ {
+ static boost::gregorian::date_duration value()
+ {
+ return boost::gregorian::date(boost::gregorian::min_date_time)
+ - boost::gregorian::date(boost::gregorian::min_date_time);
+ }
+ };
+#endif
+
+#ifdef ITL_NEEDS_POSIX_TIME_PTIME_NEUTRON_VALUE
+#define ITL_HAS_POSIX_TIME_PTIME_NEUTRON_VALUE
+ template<>
+ inline boost::posix_time::ptime neutron<boost::posix_time::ptime>::value()
+ {
+ return boost::posix_time::ptime(boost::posix_time::min_date_time);
+ }
+#endif
+
+ template <class Type>
+ inline Type neutron<Type>::value()
+ {
+ return Type();
+ }
+
+ template<>
+ inline std::string unary_template_to_string<neutron>::apply() { return "0"; }
+
+}} // namespace boost itl
+
+#define ITL_NEUTRONS_PROVIDED
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/size.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/size.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,39 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_size_JOFA_080911_H__
+#define __itl_type_traits_size_JOFA_080911_H__
+
+// I DO NOT #include boost/itl/itl_<date_time_adapter>.hpp here, because it
+// HAS TO be included by client code prior to this location.
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct size;
+
+#ifdef ITL_NEEDS_GREGORIAN_DATE_SIZE_TYPE
+#define ITL_HAS_GREGORIAN_DATE_SIZE_TYPE
+ template<>
+ struct size<boost::gregorian::date>
+ { typedef boost::gregorian::date_duration type; };
+#endif
+
+#ifdef ITL_NEEDS_POSIX_TIME_PTIME_SIZE_TYPE
+#define ITL_HAS_POSIX_TIME_PTIME_SIZE_TYPE
+ template<>
+ struct size<boost::posix_time::ptime>
+ { typedef boost::posix_time::time_duration type; };
+#endif
+
+ template <class Type> struct size{ typedef std::size_t type; };
+}} // namespace boost itl
+
+#define ITL_SIZE_TYPES_PROVIDED
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/succ_pred.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/succ_pred.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,23 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_succ_pred_JOFA_080913_H__
+#define __itl_type_traits_succ_pred_JOFA_080913_H__
+
+namespace boost{ namespace itl
+{
+ template <class IncrementableT>
+ inline static IncrementableT succ(IncrementableT x) { return ++x; }
+
+ template <class DecrementableT>
+ inline static DecrementableT pred(DecrementableT x) { return --x; }
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/to_string.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/to_string.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,111 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------------------
+Function-templates for discrete Datatypes like int, unsigned or
+ any class that provides a ++ operator c.f. iterators
+-----------------------------------------------------------------------------*/
+
+#ifndef __itl_TO_STRING_JOFA_000712_H__
+#define __itl_TO_STRING_JOFA_000712_H__
+
+#include <stdio.h>
+#include <string>
+#include <sstream>
+#pragma warning(disable: 4996) //warns against usage of printf other format-functions
+
+namespace boost{ namespace itl
+{
+
+/// static class template for the string representation of values
+/**
+ <b>value</b> serves as a base to for the representation
+ of atomic types and classes as strings.
+
+ The function <tt>toString</tt> is defined for all atomic (built in) types
+ like <tt>int, double etc.</tt>. For types other than atomic ones namely
+ classes the function template <tt>toString</tt> calls a member function
+ <tt>as_string</tt> on the class-type passed to the template.
+
+ Thereby we can implement a general string representation for template classes
+ which is independent of the template parameter being an atomic or a class type.
+ For every object, including atomic the string converter function toString can
+ be called, provides new classes implement a memberfunction <tt>as_string</tt>
+
+ @author Joachim Faulhaber
+*/
+template <class Type>
+struct to_string
+{
+ /** String converter for all types <tt>Type</tt>
+
+ E.g.: <tt>int i=5; string s = to_string<int>::apply(i);</tt>
+ */
+ static const std::string apply(const Type&);
+};
+
+
+typedef char * CharPT;
+
+#define RETURN_AS_STRING(format, atomicValue) \
+ std::stringstream repr; \
+ repr << atomicValue; \
+ return repr.str();
+
+/* Alternative macro using formated sprintf output
+#define RETURN_AS_STRING(format, atomicValue) \
+ char stringRepr[512]; \
+ sprintf(stringRepr, format, atomicValue); \
+ return stringRepr;
+*/
+
+template<> inline const std::string to_string<bool>::apply(const bool& x){ return x ? "true" : "false"; }
+template<> inline const std::string to_string<char>::apply(const char& x){ RETURN_AS_STRING("%c", x); }
+template<> inline const std::string to_string<short>::apply(const short& x) { RETURN_AS_STRING("%d", x); }
+template<> inline const std::string to_string<int>::apply(const int& x) { RETURN_AS_STRING("%d", x); }
+template<> inline const std::string to_string<long>::apply(const long& x) { RETURN_AS_STRING("%ld", x); }
+template<> inline const std::string to_string<unsigned char>::apply(const unsigned char& x) { RETURN_AS_STRING("%uc", x); }
+template<> inline const std::string to_string<unsigned short>::apply(const unsigned short& x) { RETURN_AS_STRING("%hu", x); }
+template<> inline const std::string to_string<unsigned int>::apply(const unsigned int& x) { RETURN_AS_STRING("%u", x); }
+template<> inline const std::string to_string<unsigned long>::apply(const unsigned long& x) { RETURN_AS_STRING("%lu", x); }
+template<> inline const std::string to_string<float>::apply(const float& x) { RETURN_AS_STRING("%f", x); }
+template<> inline const std::string to_string<double>::apply(const double& x) { RETURN_AS_STRING("%lf", x); }
+template<> inline const std::string to_string<CharPT>::apply(const CharPT & x) { RETURN_AS_STRING("%s", x); }
+template<> inline const std::string to_string<std::string>::apply(const std::string& x) { return x; }
+
+template <class Type>
+inline const std::string to_string<Type>::apply(const Type& x) { return x.as_string(); }
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/type_to_string.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/type_to_string.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,95 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_TYPE_TO_STRING_JOFA_080416_H__
+#define __itl_TYPE_TO_STRING_JOFA_080416_H__
+
+#include <stdio.h>
+#include <string>
+#include <sstream>
+
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_float.hpp>
+#include <boost/mpl/if.hpp>
+
+namespace boost{ namespace itl
+{
+ //--------------------------------------------------------------------------
+ template<class Type>
+ struct type_to_string
+ {
+ /** Convert the type to it's typestring */
+ static std::string apply();
+ };
+
+
+ //--------------------------------------------------------------------------
+ template<>
+ inline std::string type_to_string<int>::apply() { return "int"; }
+ template<>
+ inline std::string type_to_string<double>::apply() { return "double"; }
+ template<>
+ inline std::string type_to_string<std::string>::apply() { return "string"; }
+
+ //-------------------------------------------------------------------------
+ template<template<class> class Templ>
+ struct unary_template_to_string
+ {
+ static std::string apply();
+ };
+
+ template <template<class>class Unary, class Type>
+ struct type_to_string<Unary<Type> >
+ {
+ static std::string to_string()
+ {
+ return unary_template_to_string<Unary>::apply()+"<"+type_to_string<Type>::apply()+">";
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ template<template<class,class>class Templ>
+ struct binary_template_to_string
+ {
+ static std::string apply();
+ };
+
+ template <template<class Type1, class Type2>class Binary, class Type1, class Type2>
+ struct type_to_string<Binary<Type1, Type2> >
+ {
+ static std::string apply()
+ {
+ return binary_template_to_string<Binary>::apply()+
+ "<"+type_to_string<Type1>::apply()+","+type_to_string<Type2>::apply()+">";
+ }
+ };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/unon.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/unon.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_type_traits_unon_JOFA_080912_H__
+#define __itl_type_traits_unon_JOFA_080912_H__
+
+#include <string>
+#include <boost/itl/type_traits/neutron.hpp>
+#include <boost/itl/type_traits/succ_pred.hpp>
+
+namespace boost{ namespace itl
+{
+ template <class Type> struct unon{ static Type value(); };
+
+ template<> inline float unon<float>::value() { return 1.0; }
+ template<> inline double unon<double>::value() { return 1.0; }
+
+ // Smallest 'visible' string that is greater than than the empty string.
+ template <>
+ inline std::string unon<std::string>::value(){ return std::string(" "); };
+
+ template <class Type>
+ inline Type unon<Type>::value(){ return succ(neutron<Type>::value()); };
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl/type_traits/value_size.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/type_traits/value_size.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------------------
+Function-templates for discrete Datatypes like int, unsigned or
+ any class that provides a ++ operator c.f. iterators
+-----------------------------------------------------------------------------*/
+
+#ifndef __itl_VALUE_SIZE_JOFA_081004_H__
+#define __itl_VALUE_SIZE_JOFA_081004_H__
+
+namespace boost{ namespace itl
+{
+
+template <typename Type>
+Type abs(Type val) { return val < 0 ? -val : val; }
+
+
+/// static class template for the size of a type's value
+/** This function is needed to be able to order values according
+ to their size. This is used to e.g. prefer simple test
+ instances and to express this simplicity independent of the
+ type of the test case.
+
+ @author Joachim Faulhaber
+*/
+template <class Type>
+struct value_size
+{
+ /** The size of a value is used to be able to order values according to
+ their simplicity */
+ static std::size_t apply(const Type& val);
+};
+
+
+
+template<> inline std::size_t value_size<int>::apply(const int& value)
+{ return abs(value); }
+template<> inline std::size_t value_size<double>::apply(const double& value)
+{ return static_cast<int>(abs(value)); }
+
+template <typename Type>
+inline std::size_t value_size<Type>::apply(const Type& value)
+{ return static_cast<int>(value.iterative_size()); }
+
+
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/enum_bitset.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/enum_bitset.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,61 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_enum_bitset_JOFA_021204_H__
+#define __itl_enum_bitset_JOFA_021204_H__
+
+#include <bitset>
+#include <boost/itl/notate.hpp>
+namespace boost{namespace itl
+{
+
+
+ template <class EnumT, size_t EnumSize>
+ class enum_bitset: public std::bitset<EnumSize>
+ {
+ public:
+ /// Default Ctor
+ enum_bitset() : std::bitset<EnumSize>(){}
+
+ /// Copy Ctor
+ enum_bitset(const enum_bitset& src): std::bitset<EnumSize>(src){}
+
+ /// Construct from unsigned
+ enum_bitset(unsigned long val): std::bitset<EnumSize>(val){}
+
+ /** Add the bit 'bit' to the set. This enables shorthand notation
+ myBitSet.add(bit_1).add(bit_2). ... .add(bit_n); */
+ enum_bitset& add(int bit){this->set(bit); return *this;}
+ };
+
+}} // namespace itl boost
+
+
+#endif // __itl_enum_bitset_JOFA_021204_H__
+
Added: sandbox/itl/boost/itl_xt/episode_product.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/episode_product.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,297 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_episode_product_hpp_JOFA_011005_H__
+#define __itl_episode_product_hpp_JOFA_011005_H__
+
+#include <boost/itl/map.hpp>
+#include <boost/itl_xt/episode_set.hpp>
+
+namespace boost{namespace itl
+{
+
+/// A collection (product) of episodes of different types that do not change for a period of time
+/**
+ <b>Eine Klasse zur Sammlung von Episoden unterschiedlichen Typs</b>
+
+ episode_product ist so benannt nach dem mathematischen Ding
+ (T1 e1, ... Tn en), was gelegentlich Produkt oder Tupel (in der Informatik
+ auch struct (c), record (pascal)) genannt wird. Beim EpisodenProdukt
+ sind Ti Typen und ei Episoden-Mengen. Die Elemente der Episodenmengen sind
+ vom Typ Ti. Implementiert wird das Ganze als Map
+
+ { T1->e1, ... , Tn->en }. Es müssen also nicht alle Komponenten vorhanden sein.
+
+ Template-Parameter <b>TimeT</b>: Domain-Typ der Episoden-Intervalle
+ (z.B. Tage, Sekunden, Monate, int u.ä.). Episoden haben ja ein Intervall, das
+ Anfang und Ende der Episode angibt.
+
+ Template-Parameter <b>TypeDomain</b>: TypeDomain ist der Definitionsbereich (Domain)
+ der Typen von Episoden, die in der Produkt-Historie verwendet werden können.
+
+ Ein Episoden-Produkt ist ein Map (partielle Abbildung). Der Definitionbereich
+ des Map ist ein Aufzählungstyp TypeDomain::DomainET. Das Map ist hierdurch auf ganz
+ spezifische Werte und eine maximale Anzahl beschränkt.
+
+ Der Wertebereich (CoDomain) sind Mengen von Episoden. Diese Episoden sind
+ 'getypte' \ref typed_episode, die ihren Typ kennen. Eine Episode aus einer
+ Episodenmenge ei
+ hat immer den gleichen Typ aus TypeDomain::DomainET wie ihr Schlüssels Ti
+ eines Wertepaares (Ti, ei).
+
+ Im Kontext von Produkthistorien repräsentieren die Episoden-Mengen die
+ Episoden eines Typs, die sich überlappen. Eine einelementige Menge ist
+ eine nichtüberlappende Episode eines Typs.
+
+
+ Im Kontext von Produkthistorien kann man das EpisodenProdukt auch als
+ <b>Episoden-Aufsammelobjekt für zeitliche Überlappung</b> betrachten:
+
+ Eine Episodenmenge mit mehreren Elementen repräsentiert zeiliche Überlappung
+ von Episoden gleichen Typs: Beispiel:
+
+ { KUE -> { kueEpi_Bfa, kueEpi_Aok } }
+
+ Episoden unterschiedlichen Typs repräsentieren Überlappung von Episoden
+ unterschidlichen Typs: Beispiel:
+
+ { AUFENTH -> {aufentEpi}, KUE -> {kueEpi} }
+
+
+ @author Joachim Faulhaber
+*/
+
+template <class TimeT, class TypeDomain>
+class episode_product : public boost::itl::map<typename TypeDomain::DomainET, episode_set<TimeT,TypeDomain> >
+{
+public:
+ typedef boost::itl::map<typename TypeDomain::DomainET, episode_set<TimeT,TypeDomain> > base_type;
+ typedef typename base_type::value_type value_type;
+ typedef typename base_type::data_type data_type;
+ typedef typename base_type::data_type EpisodeSetTD;
+ typedef typename episode_set<TimeT,TypeDomain>::value_type EpisodePTD;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+
+public:
+
+ /// Zu einem Episoden-Typ wird ein Pointer auf die erste Episode einer Episoden-Menge
+ /// zurückgegeben. Wenn die Menge leer ist liefert die Funktion NULL.
+ EpisodePTD getFirst(typename TypeDomain::DomainET type)const
+ {
+ const_iterator epiSet_ = find(type);
+ if(epiSet_ == this->end())
+ return NULL;
+ else return *((*epiSet_).CONT_VALUE.begin());
+ }
+
+ EpisodePTD getLast(typename TypeDomain::DomainET type)const
+ {
+ const_iterator epiSet_ = find(type);
+ if(epiSet_ == this->end())
+ return NULL;
+ else return *((*epiSet_).CONT_VALUE.rbegin());
+ }
+
+ EpisodeSetTD* getEpisodeSetPtr(typename TypeDomain::DomainET type)
+ {
+ iterator epiSet_ = find(type);
+ if(epiSet_ == this->end())
+ return NULL;
+ else return &((*epiSet_).CONT_VALUE);
+ }
+
+ int size(typename TypeDomain::DomainET type)const
+ {
+ const_iterator epiSet_ = find(type);
+ if(epiSet_ == this->end())
+ return 0;
+ else return (*epiSet_).CONT_VALUE.size();
+ }
+
+ bool insert(EpisodePTD pEpisode)
+ {
+ EpisodeSetTD sglSet;
+ sglSet.insert(pEpisode);
+ typename TypeDomain::DomainET type = pEpisode->type();
+ return base_type::insert(value_type(type,sglSet)).WAS_SUCCESSFUL;
+ }
+
+ void leftAlignedEpisodes(episode_product& syncProd, const TimeT& start)
+ {
+ const_FORALL_THIS(elem_)
+ {
+ TypeDomain type = (*elem_).KEY_VALUE;
+ EpisodeSetTD& epiSet = (*elem_).KEY_VALUE;
+
+ EpisodeSetTD syncSet;
+ const_FORALL(typename EpisodeSetTD, epi_, epiSet)
+ {
+ if((*epi_)->interval().first()==start)
+ syncSet.insert(*epi_);
+ }
+ syncProd.insert(episode_product::value_type(type, syncSet));
+ }
+ }
+
+
+ std::string as_string()const
+ {
+ std::string str;
+ const_iterator it = this->begin();
+
+ if(it == this->end())
+ return std::string("");
+ else
+ {
+ std::string str( TypeDomain::as_string((*it).KEY_VALUE) );
+ str += ("{"+((*it).CONT_VALUE).as_string()+"}");
+ it++;
+
+ while(it != this->end()) {
+ str += ", "; str += TypeDomain::as_string((*it).KEY_VALUE);
+ str += ("{"+((*it).CONT_VALUE).as_string()+"}");
+ it++;
+ }
+ return str;
+ }
+ }
+
+};
+
+
+/* KEEP Eigentlich bessere Implementierung exemplarisch für 'using' in Verbindung
+ private inheritence. Müsste aber wg. Rückwärtskompatibilität sorgfältig
+ eingepflegt werden (eigentlich nur StatPflege)
+NOTE MEMO DESIGN USING PRIVATE INHERITENCE
+
+template <class TimeT, class TypeDomain>
+class episode_product : private itl::MapT<TypeDomain::DomainET, episode_set<TimeT,TypeDomain> >
+{
+public:
+ typedef itl::MapT<TypeDomain::DomainET, episode_set<TimeT,TypeDomain> > BaseTD;
+ typedef BaseTD::value_type value_type;
+ typedef BaseTD::data_type data_type;
+ typedef BaseTD::data_type EpisodeSetTD;
+ typedef episode_set<TimeT,TypeDomain>::value_type EpisodePTD;
+
+ typedef BaseTD::iterator iterator;
+ typedef BaseTD::const_iterator const_iterator;
+
+public:
+
+ using BaseTD::find;
+ using BaseTD::begin;
+ using BaseTD::end;
+
+ using BaseTD::contains;
+
+ episode_product& operator += (const episode_product& rhs) { BaseTD::operator += (rhs); return *this; }
+ episode_product& operator -= (const episode_product& rhs) { BaseTD::operator -= (rhs); return *this; }
+
+ /// Zu einem Episoden-Typ wird ein Pointer auf die erste Episode einer Episoden-Menge
+ /// zurückgegeben. Wenn die Menge leer ist liefert die Funktion NULL.
+ EpisodePTD getFirst(TypeDomain::DomainET type)const
+ {
+ const_iterator epiSet_ = find(type);
+ if(epiSet_==end()) return NULL;
+ else return *((*epiSet_).CONT_VALUE.begin());
+ }
+
+ int size()const { return BaseTD::size(); }
+
+ int size(TypeDomain::DomainET type)const
+ {
+ const_iterator epiSet_ = find(type);
+ if(epiSet_==end()) return 0;
+ else return (*epiSet_).CONT_VALUE.size();
+ }
+
+
+
+ bool insert(EpisodePTD pEpisode)
+ {
+ EpisodeSetTD sglSet;
+ sglSet.insert(pEpisode);
+ TypeDomain::DomainET type = pEpisode->type();
+ return BaseTD::insert(value_type(type,sglSet)).WAS_SUCCESSFUL;
+ }
+
+ std::string as_string()const
+ {
+ std::string str;
+ const_iterator it = begin();
+
+ if(it==end()) return std::string("");
+ else
+ {
+ std::string str( TypeDomain::as_string((*it).KEY_VALUE) );
+ str += ("{"+((*it).CONT_VALUE).as_string()+"}");
+ it++;
+
+ while(it != end()) {
+ str += ", "; str += TypeDomain::as_string((*it).KEY_VALUE);
+ str += ("{"+((*it).CONT_VALUE).as_string()+"}");
+ it++;
+ }
+ return str;
+ }
+ }
+
+};
+
+
+template <class TimeT, class TypeDomain>
+inline bool operator == (const episode_product<TimeT,TypeDomain>& lhs,
+ const episode_product<TimeT,TypeDomain>& rhs)
+{
+ if(lhs.size() != rhs.size())
+ return false;
+
+ episode_product<TimeT,TypeDomain>::const_iterator lhs_ = lhs.begin(), rhs_ = rhs.begin();
+
+ while(lhs_ != lhs.end())
+ {
+ if(!((*lhs_).KEY_VALUE == (*rhs_).KEY_VALUE))
+ return false;
+ else if (!((*lhs_).CONT_VALUE == (*rhs_).CONT_VALUE))
+ return false;
+
+ lhs_++; rhs_++;
+ }
+
+ return true;
+}
+*/
+
+}} // namespace itl boost
+
+#endif // __itl_episode_product_hpp_JOFA_011005_H__
+
+
Added: sandbox/itl/boost/itl_xt/episode_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/episode_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,128 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_episode_set_hpp_JOFA_011015_H__
+#define __itl_episode_set_hpp_JOFA_011015_H__
+
+#include <string>
+#include <boost/itl/set.hpp>
+#include <boost/itl_xt/typed_episode.hpp>
+
+namespace boost{namespace itl
+{
+ template <typename EpisodePointer>
+ class Less_TypedEpisodeATP
+ {
+ public:
+ bool operator ()(const EpisodePointer& rhs, const EpisodePointer& lhs)const
+ {
+ return rhs->isLess(lhs);
+ }
+ };
+
+/// A set of episodes
+/**
+ <b>Eine Menge von Episoden</b>
+
+ Template-Parameter <b>TimeT</b>: Domain-Typ der Episoden-Intervalle
+ (z.B. Tage, Sekunden, Monate, int u.ä.). Episoden haben ja ein Intervall, das
+ Anfang und Ende der Episode angibt.
+
+ Template-Parameter <b>TypeDomain</b>: TypeDomain ist der Definitionsbereich (Domain)
+ der Typen von Episoden, die in der Menge verwendet werden können.
+
+ Die Episonden-Menge darf nur Episoden enthalten, die vom gleichen
+ Episoden-Typ sind. Dieser Episodentyp wird durch einen Wert aus dem
+ Template-Parameter TypeDomain repräsentiert.
+
+ JODO: Diese Eigenschaft sollte man durch eine geeignete Implementierung
+ der Klasse sicherstellen. Enfällt bislang wg. Zeitmangels
+
+ @author Joachim Faulhaber
+*/
+template <class TimeT, class TypeDomain>
+class episode_set : public itl::set<typed_episode<TimeT, TypeDomain>*, Less_TypedEpisodeATP >
+{
+ // all elements must have the same type from TypeDomain
+public:
+ typedef itl::set<typed_episode<TimeT, TypeDomain>*, Less_TypedEpisodeATP > base_type;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+
+public:
+ bool isMonoTyped()const;
+
+ std::string as_string(const char* sep = " ")const
+ {
+ const_iterator it = this->begin();
+
+ if(it == this->end()) return std::string("");
+ else
+ {
+ std::string y = (**it).as_string(); it++;
+ while(it != this->end())
+ {
+ y += sep;
+ y += (**it).as_string();
+ it++;
+ }
+ return y;
+ }
+ }
+};
+
+
+//JODO Aufrufmechnismus für stl::container operator ==.verstehen. Eigener
+// == operator sollte überflüssig sein. Korrektes Type-Konzept für Pointertypen etc.
+template <class TimeT, class TypeDomain>
+inline bool operator == (const episode_set<TimeT,TypeDomain>& lhs,
+ const episode_set<TimeT,TypeDomain>& rhs)
+{
+ if(lhs.size() != rhs.size())
+ return false;
+
+ typename episode_set<TimeT,TypeDomain>::const_iterator
+ lhs_ = lhs.begin(),
+ rhs_ = rhs.begin();
+
+ while(lhs_ != lhs.end())
+ {
+ if(!(**lhs_ == **rhs_))
+ return false;
+ lhs_++; rhs_++;
+ }
+
+ return true;
+}
+
+}} // namespace itl boost
+
+#endif // __itl_episode_set_hpp_JOFA_011015_H__
+
+
Added: sandbox/itl/boost/itl_xt/fixtupelconst.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/fixtupelconst.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,48 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+#ifndef __itl_FixTupelConstT_JOFA_040621_H__
+#define __itl_FixTupelConstT_JOFA_040621_H__
+
+#include <boost/itl/notate.hpp>
+
+#define FOREACH_VAR(idx) for(VarEnumTD idx=0; idx < varCountV; idx++)
+#define FOREACH_VAR_TO(idx, upb) for(VarEnumTD idx=0; idx < upb; idx++)
+
+namespace boost{namespace itl
+{
+ typedef int VarEnumTD;
+ typedef int StatVarTD;
+ typedef int GroupVarTD;
+
+ const GroupVarTD UNDEFINED_GROUP = -1;
+}} // namespace itl boost
+
+#endif // __itl_FixTupelConstT_JOFA_040621_H__
+
+
Added: sandbox/itl/boost/itl_xt/gentorit.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/gentorit.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,58 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class GentorT
+--------------------------------------------------------------------*/
+#ifndef __GENTORIT_H_JOFA_000714__
+#define __GENTORIT_H_JOFA_000714__
+
+
+#include <boost/itl_xt/random.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class TypeT> class RandomGentorProfile{};
+
+template <class TypeTV> class GentorIT
+{
+public:
+ virtual ~GentorIT(){}
+ //JODO virtual void calibrate(const RandomGentorProfile& profile);
+ virtual void some(TypeTV& x)=0;
+};
+
+
+template <class TypeTV> class RandomGentorAT : public GentorIT<TypeTV>
+{
+};
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl_xt/group_order.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/group_order.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,92 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+#ifndef __group_order_JOFA_040621_H__
+#define __group_order_JOFA_040621_H__
+
+#include <functional>
+#include <boost/itl_xt/fixtupelconst.hpp>
+#include <boost/itl/map.hpp>
+
+namespace boost{namespace itl
+{
+ template <int VarCount> class var_tuple;
+
+ /// Strict weak ordering on var_tuple that defines grouping via induced equivalence
+ /** Gruppierung kann man so ausdrücken, dass alle Werte, die in gleiche Gruppen
+ zusammenfallen, äquivalent sind.
+
+ Werte, die nicht in Gruppen zusammenfallen sind nicht äquivalent.
+
+ Wir erhalten diese Äquivalenz auch durch eine strikt schwachen Ordnung <.
+ Denn wenn !(x < y) && !(y < x) dann gilt x ~= y. Wenn also zwei Werte weder
+ kleiner noch grösser bzgl. einer strikt schwachen Ordnung sind, dann sind sie
+ äquivalent.
+
+ Diesen Zusammenhang machen wir uns zunutze, um möglichst viel (wenn nicht sogar
+ alles) was mit Äquivalenzen zu tun hat auch durch strikt schwache Ordnungen und
+ stl-containern ausdrücken zu können.
+
+ Wegen des allgemeinen Falls, einer bedingten Gruppierung, bei dem die
+ Gruppierung einer Variable von den Werten anderer Variablen abhängt,
+ definieren wir die GroupOrder nicht als
+
+ binary_function<StatVarTD, StatVarTD, bool> sondern als
+ binary_function<var_tuple, var_tuple, bool>
+ */
+ template <int VarCount>
+ class group_order : public std::binary_function<var_tuple<VarCount>, var_tuple<VarCount>, bool>
+ {
+ public:
+ typedef var_tuple<VarCount> var_tupleD;
+ public:
+ /** Die strikt schwache Ordnung, die auch die Äquivalenz induziert! Sie wird
+ in abgeleiteten Klassen implementiert. */
+ virtual bool operator() (const var_tupleD& lhs, const var_tupleD& rhs)const=0;
+
+ /// Get the index of the variable that is grouped by the order.
+ virtual VarEnumTD getVarIndex()const=0;
+
+ /** Die Äquivalenz ergibt sich aus der Ordnung (operator()). Deshalb
+ besitzt die Funktion eine entsprechende Default-implementierung.
+ Wir können aber oft eine effizientere Implementierung in der
+ abgeleiteten Klasse angeben.
+ */
+ virtual bool areEquivalent(const var_tupleD& lhs, const var_tupleD& rhs)const
+ {
+ return !operator()(lhs, rhs) && !operator()(rhs, lhs);
+ }
+ };
+
+}} // namespace itl boost
+
+#endif // __group_order_JOFA_040621_H__
+
+
Added: sandbox/itl/boost/itl_xt/grouping.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/grouping.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,86 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+#ifndef __grouping_JOFA_040621_H__
+#define __grouping_JOFA_040621_H__
+
+#include <functional>
+#include <boost/itl_xt/fixtupelconst.hpp>
+#include <boost/itl_xt/group_order.hpp>
+#include <boost/itl/map.hpp>
+
+namespace boost{namespace itl
+{
+ template <int varCountV>
+ class grouping
+ {
+ public:
+ typedef group_order<varCountV> group_orderT;
+ public:
+ grouping();
+ grouping(const grouping&);
+ grouping& operator = (const grouping&);
+
+ const group_orderT* operator[] (StatVarTD permIdx)const { return m_GroupOrder[permIdx]; }
+ void setGrouper(group_orderT* grouper, int idx) { m_GroupOrder[idx] = grouper; }
+
+ private:
+ group_orderT* m_GroupOrder[varCountV];
+ };
+
+ template <int varCountV>
+ itl::grouping<varCountV>::grouping ()
+ {
+ FOREACH_VAR(idx)
+ m_GroupOrder[idx] = NULL;
+ }
+
+
+ template <int varCountV>
+ itl::grouping<varCountV>::grouping (const grouping<varCountV>& src)
+ {
+ FOREACH_VAR(idx)
+ m_GroupOrder[idx] = src.m_GroupOrder[idx];
+ }
+
+ template <int varCountV>
+ grouping<varCountV>& itl::grouping<varCountV>::operator = (const grouping<varCountV>& src)
+ {
+ if(&src != this)
+ {
+ FOREACH_VAR(idx)
+ m_GroupOrder[idx] = src.m_GroupOrder[idx];
+ }
+ return *this;
+ }
+
+
+}} // namespace itl boost
+
+#endif // __grouping_JOFA_040621_H__
+
Added: sandbox/itl/boost/itl_xt/itvgentor.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/itvgentor.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,92 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class ItvGentorT
+--------------------------------------------------------------------*/
+#ifndef __ITVGENTOR_H_JOFA_000714__
+#define __ITVGENTOR_H_JOFA_000714__
+
+
+#include <boost/itl_xt/gentorit.hpp>
+#include <boost/itl_xt/numbergentor.hpp>
+#include <boost/itl_xt/seqgentor.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class ItvDomTV, class ItvTV=interval<ItvDomTV> >
+class ItvGentorT: public RandomGentorAT<ItvTV>
+{
+public:
+ virtual void some(ItvTV& x);
+
+ void setValueRange(ItvDomTV low, ItvDomTV up)
+ { m_valueRange.set(low,up, ItvTV::RIGHT_OPEN); }
+
+ void setMaxIntervalLength(ItvDomTV len) { m_maxIntervalLength=len; }
+ void setProbDerivation();
+
+
+private:
+ NumberGentorT<ItvDomTV> m_ItvDomTVGentor;
+
+ interval<ItvDomTV> m_valueRange;
+ ItvDomTV m_maxIntervalLength;
+};
+
+
+template <class ItvDomTV, class ItvTV>
+void ItvGentorT<ItvDomTV,ItvTV>::some(ItvTV& x)
+{
+ NumberGentorT<unsigned> NATGentor;
+ ItvDomTV x1 = m_ItvDomTVGentor(m_valueRange);
+ ITV_BOUNDTYPES bndTypes = NATGentor(4);
+ unsigned upOrDown = NATGentor(1);
+ unsigned decideEmpty = NATGentor(2);
+
+ if(decideEmpty==0)
+ {
+ ItvDomTV x2 = m_ItvDomTVGentor(m_valueRange);
+ x.set(x1, x1-x2, bndTypes); //JODO this should be done smarter
+ }
+ else if(upOrDown==0) {
+ ItvDomTV up
+ = m_ItvDomTVGentor(x1, static_cast<ItvDomTV>(std::min(m_valueRange.upper(), x1+m_maxIntervalLength)));
+ x.set(x1, up, bndTypes);
+ } else {
+ ItvDomTV low
+ = m_ItvDomTVGentor(static_cast<ItvDomTV>(std::max(m_valueRange.lower(), x1-m_maxIntervalLength)), x1);
+ x.set(low, x1, bndTypes);
+ }
+};
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/list.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/list.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,440 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class itl::list
+ a general list class that extends stl-lists
+ for concepts InplaceAddable and InplaceSubtractable
+--------------------------------------------------------------------*/
+#ifndef __itl_list_h_JOFA_070519__
+#define __itl_list_h_JOFA_070519__
+
+#include <string>
+#include <list>
+#include <algorithm>
+#include <boost/assert.hpp>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/set_algo.hpp>
+#include <boost/itl/predicates.hpp>
+
+
+namespace boost{namespace itl
+{
+ //JODO 1_0_1 documentation
+ /// an stl based list implementing inplace addition operators +=
+ /**
+
+ @author Joachim Faulhaber
+ */
+ template <typename DataT, template<class>class Alloc = std::allocator>
+ class list: private std::list<DataT, Alloc<DataT> >
+ {
+ public:
+ typedef DataT value_type;
+ typedef Alloc<DataT> allocator_type;
+
+ private:
+ typedef typename itl::list<DataT, Alloc> type;
+ typedef typename std::list<DataT, allocator_type> base_type;
+
+ public:
+ typedef typename base_type::pointer pointer;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::size_type size_type;
+ typedef typename base_type::difference_type difference_type;
+ typedef typename base_type::reverse_iterator reverse_iterator;
+ typedef typename base_type::const_reverse_iterator const_reverse_iterator;
+
+ public:
+ list(){}
+ list(size_type size): base_type(size){}
+ list(size_type size, const DataT value): base_type(size, value){}
+
+ template <class InputIterator>
+ list(InputIterator f, InputIterator l): base_type(f,l) {}
+
+ list(const list& src): base_type::list(src){}
+
+ list& operator=(const list& src) { base_type::operator=(src); return *this; }
+ void swap(list& src) { base_type::swap(src); }
+
+ using base_type::begin;
+ using base_type::end;
+ using base_type::rbegin;
+ using base_type::rend;
+
+ using base_type::size;
+ using base_type::max_size;
+ using base_type::empty;
+
+ using base_type::front;
+ using base_type::back;
+ using base_type::push_front;
+ using base_type::push_back;
+ using base_type::pop_front;
+ using base_type::pop_back;
+
+ using base_type::insert;
+ using base_type::erase;
+ using base_type::clear;
+
+ using base_type::resize;
+ using base_type::splice;
+
+ using base_type::remove;
+ using base_type::unique;
+ using base_type::merge;
+ using base_type::sort;
+
+ public:
+ // --------------------------------------------------------------------
+ // itl specific extensions
+ // --------------------------------------------------------------------
+
+ /** Find the element \c x and return a \c const_iterator to that element,
+ if it exists. If \c is not found in the list return <tt>const_iterator
+ end()</tt> */
+ const_iterator find(const DataT& x)const { return std::find(begin(), end(), x); }
+
+ /** Find the element \c x and return a \c iterator to that element,
+ if it exists. If \c is not found in the list return <tt>iterator
+ end()</tt> */
+ iterator find(const DataT& x) { return std::find(begin(), end(), x); }
+
+ /// Checks if the element \c x is in the list
+ bool contains(const DataT& x)const { return !(find(x) == end()); }
+
+ /** <tt>this->contained_in(super)</tt>, if \c *this is a list that is contained as
+ sublist in the list \c super */
+ bool contained_in(const list& super)const { return is_subsequence(super); }
+
+ //JODO concept InplaceAddable
+ /// Add a list \c tail to this list.
+ list& operator += (const list& tail) { splice(end(), list(tail)); return *this; }
+
+ /** yields true if any of the elements in \c *this has the property \c prop */
+ bool any(const property<DataT>& prop)const;
+
+ //JODO concept StringRepresentable
+ /** Represent this list as a string */
+ std::string as_string(const char* sep = " ")const;
+
+ /** Function add is mainly a convenience function allowing for a compact
+ denotation of lists like in:
+ <code>
+ list<std::string> note;
+ note.add("A").add("compact").add("denotation").add("for").add("lists");
+ </code>
+ */
+ list& add(const DataT& val) { push_back(val); return *this; }
+
+
+ // --------------------------------------------------------------------
+ //JODO: sequence specific algorithms should be moved to a file seq_algo
+ // just as this has been done for sets. seq_algos can then be applied
+ // to other containers, that share sequence properties, like e.g. vectors
+
+ /** Check, if every element of the list occurs only once */
+ bool is_unique()const;
+
+ /** Insert sequence \c seq as a \e consequent subsequence into \c *this.
+
+ Whereby \c sub is a <em>consequent subsequence</em> of \c super, if
+ \c sub is contained as a (possibly non contingent) subsequence of
+ \c super without permuting elements:
+
+ <code>
+ super: my big new ball is light and blue
+ sub1 : my new ball is blue
+ sub2 : my big ball is light
+ nosub: my ball is big // NO consequent subsequence
+ </code>
+ */
+ void interlace(const list& seq);
+
+
+ /** \c *this is supersequence of \c subSeq, if \c subSeq is
+ contained in \c *this without permutations of elements. */
+ bool is_supersequence(const list& subSeq)const;
+
+ /** \c *this is subsequence of \c superSeq, if \c *this is
+ contained in \c superSeq without permutations of elements. */
+ bool is_subsequence(const list& superSeq)const
+ { return superSeq.is_supersequence(*this); }
+
+ /** \c *this is consequent to \c seq, if there are no elements in \c *this that
+ occur in different order in \c seq */
+ bool is_consequent(const list& seq)const;
+
+ /** \c perm is a permutation of \c seq that is consequent to \c *this */
+ void consequent_permutation(list& perm, list& seq);
+
+ iterator first_common_element(iterator& beg1_, iterator& end1_,
+ iterator& beg2_, iterator& end2_)const;
+
+ private:
+ void interlace(list& seq, typename list::iterator& inPos);
+ bool is_supersequence(list& seq, typename list::const_iterator& pos)const;
+ bool is_consequent(list& seq, typename list::const_iterator& pos)const;
+ void consequent_permutation(list& perm, iterator& perm_, list& seq, iterator& seq_);
+
+ };
+
+
+ template <typename DataT, template<class>class Alloc>
+ inline bool operator == (const itl::list<DataT,Alloc>& lhs,
+ const itl::list<DataT,Alloc>& rhs)
+ {
+ typedef std::list<DataT,Alloc<DataT> > base_type;
+ return operator==((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ inline bool operator < (const itl::list<DataT,Alloc>& lhs,
+ const itl::list<DataT,Alloc>& rhs)
+ {
+ typedef std::list<DataT,Alloc<DataT> > base_type;
+ return operator<((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ inline bool operator <= (const itl::list<DataT,Alloc>& lhs,
+ const itl::list<DataT,Alloc>& rhs)
+ {
+ typedef std::list<DataT,Alloc<DataT> > base_type;
+ return operator<=((const base_type&)lhs, (const base_type&)rhs);
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ bool list<DataT,Alloc>::is_unique()const
+ {
+ //JODO implement via std-algorithm of directly
+ list self = *this;
+ self.unique();
+ return (*this) == self;
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ bool list<DataT,Alloc>::is_supersequence(const list& subSeq)const
+ {
+ list sub = subSeq;
+ typename list::const_iterator pos = begin();
+ return is_supersequence(sub, pos);
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ bool list<DataT,Alloc>::is_supersequence(list& subtee, const_iterator& pos)const
+ {
+ if(subtee.empty())
+ return true;
+ else
+ {
+ DataT fst = *subtee.begin();
+ const_iterator val_ = std::find(pos, end(), fst);
+ if(val_==end())
+ return false;
+ else
+ {
+ subtee.pop_front();
+ return is_supersequence(subtee, ++val_);
+ }
+ }
+ }
+
+
+ template <typename DataT, template<class>class Alloc>
+ bool list<DataT,Alloc>::is_consequent(const list& conSeq)const
+ {
+ list seq = conSeq;
+ typename list::const_iterator pos = begin();
+ return is_consequent(seq, pos);
+ }
+
+
+ template <typename DataT, template<class>class Alloc>
+ bool list<DataT,Alloc>::is_consequent(list& seq, const_iterator& pos)const
+ {
+ if(seq.empty())
+ return true;
+ else
+ {
+ DataT fst = *seq.begin();
+ const_iterator val_ = std::find(begin(), pos, fst);
+ if(val_==end())
+ {
+ seq.pop_front();
+ return this->is_consequent(seq, ++val_);
+ }
+ else
+ return false;
+
+ }
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ void list<DataT,Alloc>::consequent_permutation(list& perm, list& seq)
+ {
+ perm.clear();
+ iterator this_ = begin();
+ iterator seq_ = seq.begin();
+ consequent_permutation(perm, this_, seq, seq_);
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ void list<DataT,Alloc>::consequent_permutation(list& perm, iterator& this_, list& seq, iterator& seq_)
+ {
+ if(seq_ == seq.end())
+ return;
+ else
+ {
+ DataT cand = *seq_;
+ iterator cur_ = std::find(begin(), this_, cand);
+ if(cur_ == this_)
+ {
+ // Next cand is not found in 'front' of *this. Oh happy day.
+ // No element swapping is necessary. We can collect 'cand'
+ perm.push_back(cand); seq_++;
+
+ // See if 'cand' is found in rear
+ cur_ = std::find(this_, end(), cand);
+
+ if(cur_ == end())
+ consequent_permutation(perm, this_, seq, seq_);
+ else
+ {
+ this_ = cur_;
+ consequent_permutation(perm, this_, seq, seq_);
+ }
+ }
+ else
+ {
+ iterator fromThis_ = cur_; fromThis_++;
+ DataT dbg_from = *fromThis_;
+ iterator perm_ = first_common_element(fromThis_, end(), perm.begin(), perm.end());
+ if(perm_ == perm.end())
+ perm.push_front(cand);
+ else
+ perm.insert(perm_, cand);
+ seq_++;
+ consequent_permutation(perm, this_, seq, seq_);
+ }
+ }
+ }
+
+
+ template <typename DataT, template<class>class Alloc>
+ typename list<DataT,Alloc>::iterator list<DataT,Alloc>::first_common_element
+ (iterator& beg1_, iterator& end1_, iterator& beg2_, iterator& end2_)const
+ {
+ iterator it1_, it2_ = beg2_;
+ for(it1_=beg1_; it1_ != end1_; it1_++)
+ for(it2_=beg2_; it2_ != end2_; it2_++)
+ if(*it1_ == *it2_)
+ return it2_;
+
+ return it2_;
+ }
+
+
+ template <typename DataT, template<class>class Alloc>
+ void list<DataT,Alloc>::interlace(const list& inList)
+ {
+ BOOST_ASSERT(is_unique());
+ BOOST_ASSERT(inList.is_unique());
+ list seq = inList;
+ iterator inPos = begin();
+ interlace(seq, inPos);
+ }
+
+ template <typename DataT, template<class>class Alloc>
+ void list<DataT,Alloc>::interlace(list& seq, iterator& inPos)
+ {
+ if(seq.empty())
+ return;
+ else
+ {
+ const DataT& cand = *seq.begin();
+ iterator cur_ = std::find(inPos, end(), cand);
+
+ if(cur_ == end())
+ {
+ // cand war nirgends in *this Liste
+ insert(inPos, cand);
+ seq.pop_front();
+ interlace(seq, inPos);
+ }
+ else
+ {
+ // cand ist schon in rear also auch in master. Die Einfuegeposition
+ // wird hinter das eingefuegte Element cand hochgezogen. Dabei ueberspringen
+ // wir allerdings Elemente, die spaeter in front gesucht werden muessen
+ seq.pop_front();
+ interlace(seq, ++cur_);
+ }
+ }
+ }
+
+
+ // THINK: here codereplication occurs at the next level of abstraction (cf. SetT)
+ template <typename DataT, template<class>class Alloc>
+ bool list<DataT,Alloc>::any(const property<DataT>& pred)const
+ {
+ const_iterator it = begin();
+ while(it != end() && ! pred(*it)) ++it;
+ if(it==end()) return false; else return true;
+ }
+
+
+ template <typename DataT, template<class>class Alloc>
+ std::string list<DataT,Alloc>::as_string(const char* sep /* =" " */)const
+ {
+ const_iterator it=begin();
+ if(it == end()) return std::string("");
+ else
+ {
+ std::string y = to_string<DataT>::apply(*it);
+ it++;
+ while(it != end())
+ {
+ y+=sep;
+ y += to_string<DataT>::value(*it);
+ it++;
+ }
+ return y;
+ }
+ }
+
+
+}} // namespace itl boost
+
+#endif // __itl_list_h_JOFA_070519__
+
Added: sandbox/itl/boost/itl_xt/mapgentor.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/mapgentor.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,160 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+
+/* ------------------------------------------------------------------
+class MapGentorT
+ A random generator for Maps.
+ ContainerGentorT does not cover maps, because its
+ value_type contains const parts so void some(value_type& x)
+ can NOT be implemented
+--------------------------------------------------------------------*/
+#ifndef __MAPGENTOR_H_JOFA_000724__
+#define __MAPGENTOR_H_JOFA_000724__
+
+#include <boost/itl_xt/list.hpp>
+#include <boost/itl_xt/gentorit.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class MapTV>
+class MapGentorT: public RandomGentorAT<MapTV>
+{
+public:
+ typedef typename MapTV::value_type ValueTypeTD;
+ typedef typename MapTV::key_type DomainTD;
+ typedef typename MapTV::data_type CodomainTD;
+ typedef list<ValueTypeTD> SampleTypeTD;
+
+ MapGentorT(): p_domainGentor(NULL), p_codomainGentor(NULL) {}
+ ~MapGentorT() { delete p_domainGentor; delete p_codomainGentor; }
+
+ virtual void some(MapTV& x);
+ void last(MapTV& x)const;
+ void last_permuted(MapTV& x)const;
+
+ void setDomainGentor(RandomGentorAT<DomainTD>* gentor)
+ {
+ if(p_domainGentor)
+ delete p_domainGentor;
+ p_domainGentor = gentor;
+ }
+ void setCodomainGentor(RandomGentorAT<CodomainTD>* gentor)
+ {
+ if(p_codomainGentor)
+ delete p_codomainGentor;
+ p_codomainGentor = gentor;
+ }
+
+ void setRangeOfSampleSize(int lwb, int upb)
+ { m_sampleSizeRange = rightopen_interval(lwb,upb); }
+ void setRangeOfSampleSize(const interval<int>& szRange)
+ { BOOST_ASSERT(szRange.is_rightopen()); m_sampleSizeRange = szRange; }
+
+private:
+ RandomGentorAT<DomainTD>* p_domainGentor;
+ RandomGentorAT<CodomainTD>* p_codomainGentor;
+ interval<int> m_sampleSizeRange;
+ SampleTypeTD m_sample;
+ int m_sampleSize;
+};
+
+
+template <class MapTV>
+void MapGentorT<MapTV>::some(MapTV& x)
+{
+ NumberGentorT<int> intGentor;
+ x.clear();
+ m_sample.clear();
+ m_sampleSize = intGentor(m_sampleSizeRange);
+
+ for(int i=0; i<m_sampleSize; i++)
+ {
+ DomainTD key;
+ p_domainGentor->some(key);
+ CodomainTD val;
+ p_codomainGentor->some(val);
+ x += ValueTypeTD(key,val);
+ m_sample.push_back(ValueTypeTD(key,val));
+ }
+}
+
+
+template <class MapTV>
+void MapGentorT<MapTV>::last(MapTV& x)const
+{
+ x.clear();
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ x += *it;
+}
+
+template <class MapTV>
+void MapGentorT<MapTV>::last_permuted(MapTV& x)const
+{
+ x.clear();
+
+ SampleTypeTD perm;
+
+ NumberGentorT<int> intGentor;
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ {
+ if( 0==intGentor(2) ) perm.push_back(*it);
+ else perm.push_front(*it);
+ }
+
+ const_FORALL(typename SampleTypeTD, pit, perm)
+ x += *pit;
+}
+
+
+/*
+template <class MapTV>
+void MapGentorT<MapTV>::lastSample(SampleTypeTD& sam)const
+{ sam = m_sample; }
+
+
+template <class MapTV>
+void MapGentorT<MapTV>::lastSample_permuted(SampleTypeTD& sam)
+{
+ NumberGentorT<unsigned> intGentor;
+ x.clear();
+ int coin = intGentor.some(2); // gives 0 or 1
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ {
+ if( 0==intGentor.some(2) ) sam.push_back(*it);
+ else sam.push_front(*it);
+ }
+}
+*/
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/numbergentor.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/numbergentor.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,278 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class NumberGentorT
+ A random generator for numbers
+--------------------------------------------------------------------*/
+#ifndef __NUMBERGENTORT_H_JOFA_000725__
+#define __NUMBERGENTORT_H_JOFA_000725__
+
+
+#include <stdlib.h>
+#include <vector>
+#include <boost/itl/type_traits/unon.hpp>
+#include <boost/itl_xt/gentorit.hpp>
+
+using namespace boost::itl;
+
+#define RND_1_TO(y) (1+(int)((double)(y)*rand()/(RAND_MAX+1.0)))
+#define RND_0_TO(y) ((int)((double)((y)+1)*rand()/(RAND_MAX+1.0)))
+#define RND_WITHIN(x,y) ((x)+(int)((double)((y)-(x)+1)*rand()/(RAND_MAX+1.0)))
+
+// -----------------------------------------------------------
+
+#define RND_O_TO_EXCL(y) (((double)(y))*rand()/(RAND_MAX+1.0))
+
+#define RND_WITHIN_EXUPB(x,y) ((x)+((double)((y)-(x))*rand()/(RAND_MAX+1.0)))
+
+namespace boost{namespace itl
+{
+
+template <class NumTV>
+inline NumTV rnd_0_to_excl(NumTV exclusive_upb)
+{ return (NumTV)RND_O_TO_EXCL(exclusive_upb); }
+
+
+template <class NumTV>
+inline NumTV rnd_within_exUpb(NumTV lwb, NumTV exclusive_upb)
+{
+ NumTV some = (NumTV)RND_WITHIN_EXUPB(lwb,exclusive_upb);
+ return some;
+}
+
+template <class NumTV>
+inline NumTV rnd_within(NumTV lwb, NumTV exclusive_upb)
+{
+ NumTV some = (NumTV)RND_WITHIN(lwb,exclusive_upb);
+ return some;
+}
+
+template <class NumT>
+class NumberGentorProfile : public RandomGentorProfile<NumT>
+{
+public:
+private:
+ interval<NumT> _range;
+};
+
+template <class NumTV>
+class NumberGentorT : public RandomGentorAT<NumTV>
+{
+public:
+ NumberGentorT():
+ m_valueRange( NumTV(), unon<NumTV>::value(), interval<NumTV>::RIGHT_OPEN ) {}
+
+ NumTV operator() (NumTV upb) { return rnd_0_to_excl<NumTV>(upb); }
+ NumTV operator() (NumTV lwb, NumTV upb) { return rnd_within_exUpb<NumTV>(lwb,upb); }
+ NumTV operator() (interval<NumTV> rng)
+ {
+ BOOST_ASSERT(rng.is_rightopen() || rng.is_closed());
+ if(rng.is_rightopen())
+ return rnd_within_exUpb<NumTV>(rng.lower(), rng.upper());
+ else
+ return rnd_within<NumTV>(rng.lower(), rng.upper());
+ }
+
+ void setRange(interval<NumTV> rng) { m_valueRange = rng; }
+ void setRange(NumTV lwb, NumTV upb) { m_valueRange = rightopen_interval(lwb,upb); }
+
+ void calibrate(const RandomGentorProfile<NumTV>& profile)
+ {
+ m_valueRange = profile.getValueRange();
+ }
+
+ void some(NumTV& x) { x = (*this)(m_valueRange); }
+
+ std::string as_string()const { return "NumberGentorT";}
+
+private:
+ interval<NumTV> m_valueRange;
+};
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+template <typename WeightsT>
+class WeightedNumberGentor : public RandomGentorAT<int>
+{
+public:
+ WeightedNumberGentor(): _size(0), _maxWeights(0){}
+
+ WeightedNumberGentor(int size, WeightsT maxWeights):
+ _size(size), _maxWeights(maxWeights),
+ _weights(size, WeightsT()), _kumWeights(size+1, WeightsT()),
+ _typeNames(size, std::string())
+ {}
+
+ WeightedNumberGentor(int size):
+ _size(size), _maxWeights(1000),
+ _weights(size, WeightsT()), _kumWeights(size+1, WeightsT()),
+ _typeNames(size, std::string())
+ {}
+
+ void setSize(int size);
+ int size()const { return _size; }
+
+ void setMaxWeights(int maxWeights) { _maxWeights = maxWeights; }
+ WeightsT maxWeights()const { return _maxWeights; }
+ WeightsT chosenValue()const { return _chosenValue; }
+
+ void setTypeNames(const std::vector<std::string>& names)
+ { _typeNames = names ; }
+
+ void setTypeNames(const char* denotation[])
+ {
+ for(int idx=0; idx < size(); idx++)
+ _typeNames[idx] = std::string(denotation[idx]);
+ }
+
+ WeightsT& operator[](int idx)
+ { BOOST_ASSERT(0<=idx && idx<_size); return _weights[idx]; }
+
+ void setWeight(int idx, WeightsT val) { BOOST_ASSERT(0<=idx && idx<_size); _weights[idx] = val; }
+
+ WeightsT getKumWeight(int idx)const { return _kumWeights[idx]; }
+
+ WeightsT sumOfWeights()const;
+
+ void init();
+
+ int some();
+ void some(int& index){ index = some(); }
+
+ int lower_bound_index(int low, int up, WeightsT val);
+
+ bool isRangeValid()const
+ { return _kumWeights[_chosenIndex] <= _chosenValue && _chosenValue < _kumWeights[_chosenIndex+1]; }
+
+ std::string asString()const;
+
+ bool is_consistent()const { return sumOfWeights() == _maxWeights; }
+
+ std::string inconsitencyMessage(const std::string& location)const;
+
+private:
+ int _size;
+ WeightsT _maxWeights;
+ std::vector<WeightsT> _weights;
+ std::vector<WeightsT> _kumWeights;
+ NumberGentorT<int> _numgentor;
+ WeightsT _chosenValue;
+ int _chosenIndex;
+ std::vector<std::string> _typeNames;
+};
+
+
+template <typename WeightsT>
+void WeightedNumberGentor<WeightsT>::setSize(int size)
+{
+ _size = size;
+ _weights.resize(_size, WeightsT());
+ _kumWeights.resize(_size+1, WeightsT());
+}
+
+
+template <typename WeightsT>
+void WeightedNumberGentor<WeightsT>::init()
+{
+ _kumWeights[0] = WeightsT();
+ for(int idx=1; idx < _size; idx++)
+ _kumWeights[idx] = static_cast<WeightsT>(std::min(_kumWeights[idx-1]+_weights[idx-1], _maxWeights));
+
+ _kumWeights[_size] = _maxWeights;
+}
+
+template <typename WeightsT>
+WeightsT WeightedNumberGentor<WeightsT>::sumOfWeights()const
+{
+ WeightsT weightSum = WeightsT();
+ for(int idx=0; idx < _size; idx++)
+ weightSum += _weights[idx];
+
+ return weightSum;
+}
+
+template <typename WeightsT>
+int WeightedNumberGentor<WeightsT>::some()
+{
+ _chosenValue = _numgentor(_maxWeights);
+ _chosenIndex = lower_bound_index(0, _size, _chosenValue);
+ return _chosenIndex;
+}
+
+template <typename WeightsT>
+int WeightedNumberGentor<WeightsT>::lower_bound_index(int low, int up, WeightsT val)
+{
+ int mid = (low+up)/2;
+ if(_kumWeights[mid] <= val && val < _kumWeights[mid+1])
+ return mid;
+ else if(val < _kumWeights[mid])
+ return lower_bound_index(low, mid, val);
+ else
+ return lower_bound_index(mid+1, up, val);
+}
+
+
+template <typename WeightsT>
+std::string WeightedNumberGentor<WeightsT>::asString()const
+{
+ std::string result;
+ for(int idx=0; idx < size(); idx++)
+ {
+ result += to_string<int>::apply(idx);
+ result += ":";
+ result += _typeNames[idx];
+ result += "(";
+ result += to_string<int>::apply(_weights[idx]);
+ result += ")\n";
+ }
+ return result;
+}
+
+template <typename WeightsT>
+std::string WeightedNumberGentor<WeightsT>::inconsitencyMessage(const std::string& location)const
+{
+ std::string message;
+ message += "Inconsistent typechoice in ";
+ message += location + ":\n";
+ message += "The sum of weights must be ";
+ message += to_string<int>::apply(maxWeights());
+ message += " but is ";
+ message += to_string<int>::apply(sumOfWeights());
+ message += "\n";
+ message += "The weights defined are:\n";
+ message += asString();
+ return message;
+}
+
+}} // namespace itl boost
+
+#endif // __NUMBERGENTORT_H_JOFA_000725__
+
+
+
+
Added: sandbox/itl/boost/itl_xt/ordered_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/ordered_type.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,147 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __ordered_type_h_JOFA_011005_H__
+#define __ordered_type_h_JOFA_011005_H__
+
+#include <string>
+
+namespace boost{namespace itl
+{
+
+/// an enumeration ordered class type
+/**
+ class template <b>ordered_type</b> defines objects
+ that can be ordered by an enumeration type that
+ is associated to the template parameter TypeDomain.
+ Every object of this class exposes a value of
+ that enumeration type by a function <b>type()</b>
+
+ @author Joachim Faulhaber
+*/
+template <class TypeDomain>
+class ordered_type
+{
+public:
+ typedef ordered_type* OrderedTypePIT;
+
+public:
+ /// virtual destructors to avoid memory leaks
+ virtual ~ordered_type(){}
+ /// the objects type
+ virtual typename TypeDomain::DomainET type()const=0;
+
+ /// the objects value
+ virtual const typename TypeDomain::ValueBaseTD* value()const=0;
+
+ /// Comparison on type level
+ virtual bool isLessOnType(const ordered_type* x2)const=0;
+ /// Equivalece relation <tt>this->type()==x2->type()</tt>
+ virtual bool isTypeEquivalent(const ordered_type* x2)const=0;
+
+ /// comparisons on value level
+ virtual bool isEqual(const ordered_type* x2)const=0;
+
+ virtual bool isLess(const ordered_type* x2)const=0;
+
+ /// equality on value-level using == operator
+ virtual bool operator == (const ordered_type& x2)const=0;
+
+ //JODO Aufrufmechnismus für stl::container operator ==.verstehen
+ //virtual bool operator == (const OrderedTypePIT& x2)const=0;
+
+ //KEEP JODO einpflegen
+ // virtual bool isLess(const ordered_type* x2)const=0;
+ // virtual bool operator < (const ordered_type& x2)const=0;
+
+ /// string representation
+ virtual std::string as_string()const=0 ;
+};
+
+
+template <class TypeDomain>
+class ordered_type_base : public ordered_type<TypeDomain>
+{
+public:
+ typedef ordered_type<TypeDomain>* OrderedTypeOfDomPIT;
+
+public:
+ virtual bool isLessOnType (const ordered_type<TypeDomain>* x2)const
+ { return this->type() < x2->type(); }
+ virtual bool isTypeEquivalent (const ordered_type<TypeDomain>* x2)const
+ { return this->type() == x2->type(); }
+
+ // comparisons on value level
+ bool isEqual(const ordered_type<TypeDomain>* x2)const
+ {
+ return isTypeEquivalent(x2) && isValueEqual(x2);
+ }
+
+ bool operator == (const ordered_type<TypeDomain>& x2)const
+ {
+ return isEqual(&x2);
+ }
+
+ bool isLess(const ordered_type<TypeDomain>* x2)const
+ {
+ return this < x2;
+ }
+
+ /*JODO Aufrufmechnismus für stl::container operator ==.verstehen
+ bool operator == (const OrderedTypeOfDomPIT& x2)const
+ {
+ return isEqual(x2);
+ }
+ */
+
+ /*KEEP JODO Einfplegen
+ bool isLess(const ordered_type<TypeDomain>* x2)const
+ {
+ return isLessOnType(x2) && isValueLess(x2);
+ }
+
+ bool operator < (const ordered_type<TypeDomain>& x2)const
+ {
+ return isLess(&x2);
+ }
+ */
+
+protected:
+ /// Gleichheit der Werte
+ virtual bool isValueEqual(const ordered_type<TypeDomain>* x2)const=0;
+
+ //KEEP JODO Einfplegen
+ //virtual bool isValueLess(const ordered_type<TypeDomain>* x2)const=0;
+};
+
+}} // namespace itl boost
+
+#endif // __ordered_type_h_JOFA_011005_H__
+
+
Added: sandbox/itl/boost/itl_xt/prefix_set.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/prefix_set.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#include <stdafx.h>
+#include "prefix_set.h"
+
+using namespace boost::itl;
+
+
+int prefix_set::compareStrings(int& comSize, const char* s1, const char* s2)
+{
+ int i=0;
+ while(s1[i] != NULL && s2[i] != NULL)
+ {
+ if(s1[i] < s2[i])
+ {
+ comSize = i;
+ return -1;
+ }
+ if(s1[i] > s2[i])
+ {
+ comSize = i;
+ return 1;
+ }
+
+ // Gleichheit: weitermachen
+ i++;
+ }
+
+ comSize = i;
+ if(s1[i] == NULL || s2[i] == NULL)
+ return 0; // Gleichheit
+ if (s1[i] != NULL)
+ return 1; // s1 ist größer
+ else
+ return -1; // s2 ist größer
+
+}
+
+
+void prefix_set::insert(const std::string& val)
+{
+ pair<iterator, bool> insertion = m_.insert(val);
+ if(!insertion.WAS_SUCCESSFUL)
+ {
+ if(val.size() < (*insertion.ITERATOR).size())
+ {
+ m_.erase(insertion.ITERATOR);
+ insert(val);
+ }
+ }
+}
+
+
Added: sandbox/itl/boost/itl_xt/prefix_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/prefix_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,114 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_prefix_set_JOFA_040902_H__
+#define __itl_prefix_set_JOFA_040902_H__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl/string_set.hpp>
+
+namespace boost{namespace itl
+{
+
+ template <typename StringT>
+ struct PrefixLess : public binary_function<StringT, StringT, bool>
+ {
+ // Wenn einer von lhs & rhs ein echter Prefix des anderen ist, ist er kleiner.
+ // Ansonsten lexikografischer Vergleich
+ bool operator() (const StringT& lhs, const StringT& rhs)const;
+ };
+
+ /// represents a set of strings by means of prefixes
+ /** Ein prefix_set repraesentiert eine Menge von Strings mit Hilfe von
+ Prefixen.
+
+ Zum Beispiel repraesentiert das
+ prefix_set {Ha} die Menge {Hans, Hallo, Harald, ...} also alle Strings,
+ die mit 'Ha' beginnen.
+
+ Entsprechend
+ {Har, Hal}.contains(Haribo) == true
+ {Har, Hal}.contains(Hallenbad) == true
+ {Har, Hal}.contains(Hugo) == false
+
+ Einfuegen eines gemeinsamen Praefix, einer PraefixSetT verkleinert es:
+ {Har, Hal}.insert(Ha) == {Ha}
+
+ PrefixSetTs sind sehr praktisch fuer die Behandlung unserer Gruppierungen
+ von Kategoriestrings aus den Cfg-Files, die ja mittels Prefix-Listen
+ ausgedrueckt werden.
+
+ Hierfuer gibt es noch die Klasse StringPatternSetT, die die ensprechenden
+ prefix_set m_Includes;
+ prefix_set m_Excludes;
+ enthaelt.
+ */
+ class prefix_set
+ {
+ public:
+ typedef string_set<PrefixLess> PrefixSetTD;
+ typedef PrefixSetTD::iterator iterator;
+ typedef PrefixSetTD::const_iterator const_iterator;
+
+ public:
+ static int compareStrings(int& comSize, const char* s1, const char* s2);
+
+ public:
+ void insert(const std::string& val);
+
+ const_iterator find(const std::string& val)const { return m_.find(val); }
+ bool contains(const std::string& val)const { return m_.find(val)!=m_.end(); }
+
+ std::string as_string()const { return m_.as_string(); }
+
+ private:
+ string_set<PrefixLess> m_;
+ };
+
+
+
+ template <typename StringT>
+ bool PrefixLess<StringT>::operator() (const StringT& lhs, const StringT& rhs)const
+ {
+ int commonPrefixLength;
+ int compareResult
+ = prefix_set::compareStrings(commonPrefixLength, lhs.c_str(), rhs.c_str());
+
+ if(compareResult == 0) // Gleichheit
+ return false;
+ if(commonPrefixLength == lhs.size())
+ return true; // lhs istEchterPrefix rhs
+ // OTHERWISE
+ return compareResult == -1;
+ }
+
+}} // namespace itl boost
+
+#endif // __itl_prefix_set_JOFA_040902_H__
+
Added: sandbox/itl/boost/itl_xt/product_history.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/product_history.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __product_history_h_JOFA_011005_H__
+#define __product_history_h_JOFA_011005_H__
+
+
+#include <boost/itl/split_interval_map.hpp>
+
+namespace boost{namespace itl
+{
+
+/// composes many episodes of different types into a single history of episode_product s
+/**
+ <b>Eine Klasse zur Verarbeitung von Episoden unterschiedlichen Typs in einer gemeinsamen Historie</b>
+
+ Template-Parameter <b>ItvDomTV</b>: Domain-Typ der History, also Typ der
+ Elemente des Definitionsbereichs (Schlüssel), die die History enthalten kann
+ (z.B. Tage, Sekunden, Monate, int u.ä.).
+
+ Template-Parameter <b>TypeDomTV</b>: TypeDomTV ist der Definitionsbereich (Domain)
+ der Typen von Episoden, die in der Produkt-Historie verwendet werden können.
+
+ TypeDomTV kapselt im wesentlichen einen Aufzählungstyp, der die Typen
+ von Episoden definiert, die möglich sind (Z.B. Aufenthalte, Kostenübernahmen und
+ Bettenbelegungen).
+
+ product_history wird ohne weiere Umschweife direkt aus einem \ref split_interval_map
+ abgeleitet.
+
+ Die Werte dieser Historie sind eine (Auf)sammlung oder Produkt von Episoden
+ verschiedenen Typs \ref episode_product. Die Historie solcher
+ Episodensammlungen teilt sich immer dort auf, wo irgend ein Unterschied
+ in den Episoden eintritt.
+
+ Mit anderen Worten die ProduktHistorie enthält zusammenhängende Intervalle,
+ wo die Anzahl und Werte gesammelter Episonden konstant sind.
+
+ Dies ist ein universelles Werkzeug, um Mengen asynchroner Historien
+ zusammenzufassen und die feinste Darstellung als eine Historie zu
+ erhalten, die alle 'Zustandsänderungen' ihrer Teilhistorien repräsentiert.
+
+ { H<T1>, .. , H<Ti> } -> H<{T1, .. , Ti}>
+
+ @author Joachim Faulhaber
+*/
+template <class ItvDomTV, class TypeDomTV>
+class product_history : public split_interval_map<ItvDomTV, episode_product<ItvDomTV,TypeDomTV> >
+{
+public:
+ typedef episode_product<ItvDomTV,TypeDomTV> EpisodeProductTD;
+ typedef split_interval_map<ItvDomTV, EpisodeProductTD> BaseTypeTD;
+ typedef typename BaseTypeTD::value_type value_type;
+ typedef typename BaseTypeTD::interval_type IntervalTD;
+ typedef typename BaseTypeTD::domain_type DomainTD;
+
+ typedef typename BaseTypeTD::data_type data_type;
+ typedef typename EpisodeProductTD::EpisodePTD EpisodePTD;
+
+public:
+
+ void add(EpisodePTD epi)
+ {
+ EpisodeProductTD epiRec;
+ epiRec.insert(epi);
+ BaseTypeTD::add(value_type(epi->interval(), epiRec));
+ }
+
+ product_history& operator +=(EpisodePTD epi)
+ {
+ add(epi);
+ return *this;
+ }
+
+
+protected:
+
+ void add(const value_type& val)
+ {
+ BaseTypeTD::add(val);
+ }
+};
+
+}} // namespace itl boost
+
+#endif // __product_history_h_JOFA_011005_H__
+
+
Added: sandbox/itl/boost/itl_xt/random.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/random.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,71 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __RANDOM_H_JOFA_990223__
+#define __RANDOM_H_JOFA_990223__
+
+
+#include <functional>
+#include <stdlib.h>
+#include <boost/assert.hpp>
+#include <boost/itl/interval.hpp>
+
+namespace boost{namespace itl
+{
+
+class random
+{
+public:
+ //JODO subtractive_rng random generator is only an sgi extension of std-lib
+ //unsigned rnd(unsigned upb) { return m_random(upb); };
+
+ unsigned rnd(unsigned upb)
+ {
+ return static_cast<int>(upb * (::rand() / static_cast<double>(RAND_MAX)));
+ //JODO return m_random(upb);
+ };
+
+
+ unsigned rnd(unsigned lwb, unsigned upb)
+ {
+ BOOST_ASSERT(0<=lwb && lwb <= upb);
+ unsigned len = upb - lwb ;
+ unsigned some = rnd(len);
+ return some + lwb;
+ }
+
+ unsigned rnd(const itl::interval<unsigned>& rng)
+ { BOOST_ASSERT( rng.is_rightopen() ); return rnd(rng.lower(),rng.upper()); }
+
+private:
+ //JODO subtractive_rng m_random;
+};
+
+}} // namespace itl boost
+
+#endif
+
Added: sandbox/itl/boost/itl_xt/randomnumber.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/randomnumber.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,58 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __RANDOMNUMBER_H_JOFA_990223__
+#define __RANDOMNUMBER_H_JOFA_990223__
+
+
+#include <functional>
+#include <boost/itl/random.hpp>
+namespace boost{namespace itl
+{
+
+ template <class NumTV>
+ class RandomNumberT
+ {
+ public:
+ // JODO later more sophisticated versions!
+ NumTV rnd(NumTV upb)
+ { return _random.rnd(upb);}
+
+ NumTV rnd(NumTV lwb, NumTV upb)
+ { return _random.rnd(lwb, upb);}
+
+ NumTV rnd(const IntervalT<NumTV>& rng)
+ { BOOST_ASSERT( rng.isROpen() ); return rnd(rng.lower(),rng.upper()); }
+
+ private:
+ random _random;
+ };
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/seqgentor.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/seqgentor.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,146 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class SeqGentorT
+ A random generator for Sequences.
+--------------------------------------------------------------------*/
+#ifndef __SeqGentorT_H_JOFA_000724__
+#define __SeqGentorT_H_JOFA_000724__
+
+#include <boost/itl_xt/gentorit.hpp>
+#include <boost/itl_xt/list.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class SeqTV>
+class SeqGentorT: public RandomGentorAT<SeqTV>
+{
+public:
+ typedef typename SeqTV::value_type ValueTypeTD;
+ typedef typename SeqTV::value_type DomainTD;
+ typedef list<ValueTypeTD> SampleTypeTD;
+
+ virtual void some(SeqTV& x);
+ void last(SeqTV& x)const;
+ void last_permuted(SeqTV& x)const;
+
+ void setDomainGentor(RandomGentorAT<DomainTD>* gentor)
+ { m_domainGentor = gentor; }
+
+ void setRangeOfSampleSize(int lwb, int upb)
+ { m_sampleSizeRange = rightopen_interval(lwb,upb); }
+ void setRangeOfSampleSize(const interval<int>& szRange)
+ { BOOST_ASSERT(szRange.isROpen()); m_sampleSizeRange = szRange; }
+
+ void setUnique(bool truth) { m_unique = truth; }
+
+private:
+ RandomGentorAT<DomainTD>* m_domainGentor;
+ interval<int> m_sampleSizeRange;
+ SampleTypeTD m_sample;
+ int m_sampleSize;
+ bool m_unique;
+};
+
+
+template <class SeqTV>
+void SeqGentorT<SeqTV>::some(SeqTV& x)
+{
+ NumberGentorT<int> intGentor;
+ x.clear();
+ m_sample.clear();
+ m_sampleSize = intGentor(m_sampleSizeRange);
+
+ for(int i=0; i<m_sampleSize; i++)
+ {
+ DomainTD key;
+ m_domainGentor->some(key);
+
+ if(m_unique)
+ {
+ typename SeqTV::iterator pos_ = std::find(x.begin(), x.end(), key);
+ if(pos_ == x.end())
+ x.push_back(key);
+ }
+ else x.push_back(key);
+
+ m_sample.push_back(key);
+ }
+}
+
+
+template <class SeqTV>
+void SeqGentorT<SeqTV>::last(SeqTV& x)const
+{
+ x.clear();
+ const_FORALL(typename SampleTypeTD, it, m_sample) x.insert(*it);
+}
+
+template <class SeqTV>
+void SeqGentorT<SeqTV>::last_permuted(SeqTV& x)const
+{
+ x.clear();
+
+ SampleTypeTD perm;
+
+ NumberGentorT<int> intGentor;
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ {
+ if( 0==intGentor(2) ) perm.push_back(*it);
+ else perm.push_front(*it);
+ }
+
+ const_FORALL(typename SampleTypeTD, pit, perm) x.insert(*pit);
+}
+
+
+/*
+template <class SeqTV>
+void SeqGentorT<SeqTV>::lastSample(SampleTypeTD& sam)const
+{ sam = m_sample; }
+
+
+template <class SeqTV>
+void SeqGentorT<SeqTV>::lastSample_permuted(SampleTypeTD& sam)
+{
+ NumberGentorT<unsigned> intGentor;
+ x.clear();
+ int coin = intGentor.some(2); // gives 0 or 1
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ {
+ if( 0==intGentor.some(2) ) sam.push_back(*it);
+ else sam.push_front(*it);
+ }
+}
+*/
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/setgentor.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/setgentor.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,150 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class SetGentorT
+ A random generator for Sets.
+--------------------------------------------------------------------*/
+#ifndef __SETGENTOR_H_JOFA_000724__
+#define __SETGENTOR_H_JOFA_000724__
+
+#include <boost/itl_xt/gentorit.hpp>
+#include <boost/itl_xt/numbergentor.hpp>
+#include <boost/itl_xt/list.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class SetTV>
+class SetGentorT: public RandomGentorAT<SetTV>
+{
+public:
+ typedef typename SetTV::value_type ValueTypeTD;
+ typedef typename SetTV::key_type DomainTD;
+ typedef list<ValueTypeTD> SampleTypeTD;
+ typedef RandomGentorAT<DomainTD> DomainGentorT;
+ typedef DomainGentorT* DomainGentorPT;
+
+ SetGentorT(): p_domainGentor(NULL) {}
+ ~SetGentorT() {}
+
+ virtual void some(SetTV& x);
+ void last(SetTV& x)const;
+ void last_permuted(SetTV& x)const;
+
+ void setDomainGentor(RandomGentorAT<DomainTD>* gentor)
+ {
+ if(p_domainGentor)
+ delete p_domainGentor;
+ p_domainGentor = gentor;
+ }
+
+ void setRangeOfSampleSize(int lwb, int upb)
+ { m_sampleSizeRange = rightopen_interval(lwb,upb); }
+ void setRangeOfSampleSize(const interval<int>& szRange)
+ { BOOST_ASSERT(szRange.is_rightopen()); m_sampleSizeRange = szRange; }
+
+ DomainGentorPT domainGentor()const { return p_domainGentor; }
+
+private:
+ RandomGentorAT<DomainTD>* p_domainGentor;
+ interval<int> m_sampleSizeRange;
+ SampleTypeTD m_sample;
+ int m_sampleSize;
+};
+
+
+template <class SetTV>
+void SetGentorT<SetTV>::some(SetTV& x)
+{
+ NumberGentorT<int> intGentor;
+ x.clear();
+ m_sample.clear();
+ m_sampleSize = intGentor(m_sampleSizeRange);
+
+ for(int i=0; i<m_sampleSize; i++)
+ {
+ DomainTD key;
+ domainGentor()->some(key);
+ x += key;
+ m_sample.push_back(key);
+ }
+}
+
+
+template <class SetTV>
+void SetGentorT<SetTV>::last(SetTV& x)const
+{
+ x.clear();
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ x += *it;
+}
+
+template <class SetTV>
+void SetGentorT<SetTV>::last_permuted(SetTV& x)const
+{
+ x.clear();
+
+ SampleTypeTD perm;
+
+ NumberGentorT<int> intGentor;
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ {
+ if( 0==intGentor(2) ) perm.push_back(*it);
+ else perm.push_front(*it);
+ }
+
+ const_FORALL(typename SampleTypeTD, pit, perm)
+ x += *pit;
+}
+
+
+/*
+template <class SetTV>
+void SetGentorT<SetTV>::lastSample(SampleTypeTD& sam)const
+{ sam = m_sample; }
+
+
+template <class SetTV>
+void SetGentorT<SetTV>::lastSample_permuted(SampleTypeTD& sam)
+{
+ NumberGentorT<unsigned> intGentor;
+ x.clear();
+ int coin = intGentor.some(2); // gives 0 or 1
+ const_FORALL(typename SampleTypeTD, it, m_sample)
+ {
+ if( 0==intGentor.some(2) ) sam.push_back(*it);
+ else sam.push_front(*it);
+ }
+}
+*/
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/statvardesct.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/statvardesct.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,82 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __StatVarDescT_JOFA_040614_H__
+#define __StatVarDescT_JOFA_040614_H__
+
+#include <boost/itl_xt/enum_bitset.hpp>
+namespace boost{namespace itl
+{
+
+ /// Skalenniveau der Skala
+ enum KindOfScaleET { nominal_scale, ordinal_scale, interval_scale, ratio_scale };
+
+ //JODO Noch nicht ganz klar ob wirs so brauchen
+ // Konzept: Zähltupeln sind immer interger-codier
+ /// Werte der Skala
+ enum VarValueET
+ {
+ integer_value,
+ interval_value,
+ string_value,
+ class_value,
+ VarValueET_size
+ };
+
+ /// Flags für eine Variable
+ enum StatVarPropertyET
+ {
+ dependent, // Abhängige Variable
+ // independent, // Unabhängige Variable ?? JODO Können beide gleichzeitig false sein? (nur restricting)
+ restricting, // Restriktionsvariable
+ StatVarPropertyET_size
+ };
+
+ typedef enum_bitset<StatVarPropertyET, StatVarPropertyET_size> StatVarPropertySetTD ;
+
+
+ /* class StatVarDescT: Beschreibung der Eigenschaften von Variablen einer Statistik
+ (auch bekannt als Stochastische Variable).
+
+ Zuständigkeit: Beschreibt wichtige Eigenschaften von Datenbank-Feldern im Kontext
+ von Statistischen Auswertungen.
+
+ Zusammenarbeit:
+ */
+ class StatVarDescT
+ {
+ public:
+ bool isDependent()const;
+
+ private:
+ };
+
+
+}} // namespace itl boost
+
+#endif // __StatVarDescT_JOFA_040614_H__
+
Added: sandbox/itl/boost/itl_xt/string_list.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/string_list.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,177 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------------
+A general list of strings
+---------------------------------------------------------------------------------*/
+#include <boost/itl/string_list.hpp>
+
+using namespace std;
+using namespace boost::itl;
+
+string_list::string_list(const char* const deno[], int nOfDeno): list<std::string>()
+{
+ for(int i=0; i<nOfDeno; i++) push_back(std::string(deno[i]));
+}
+
+int string_list::split(const std::string& arg, const char* sep /* =" " */)
+{
+ clear(); // get rid of old stuff
+ int sepLen = strlen(sep), empty_count = 0;
+ int search_from = 0, idx_fst = 0, cur_len = 0, found_idx = string::npos;
+
+ while((found_idx = arg.find(sep, search_from)) != string::npos)
+ {
+ cur_len = found_idx - idx_fst;
+ if(cur_len == 0) empty_count++;
+ push_back(arg.substr(idx_fst, cur_len));
+ idx_fst = found_idx + sepLen;
+ search_from = idx_fst;
+ }
+
+ cur_len = arg.length()-search_from;
+ if(cur_len == 0) empty_count++;
+ push_back(arg.substr(search_from, cur_len));
+
+ return empty_count;
+}
+
+int string_list::separate(const std::string& arg, const char* sep /* =" " */)
+{
+ clear(); // get rid of old stuff
+ int sepLen = strlen(sep), empty_count = 0;
+ int search_from = 0, idx_fst = 0, cur_len = 0, found_idx = string::npos;
+
+ while((found_idx = arg.find(sep, search_from)) != string::npos)
+ {
+ cur_len = found_idx - idx_fst;
+ if(cur_len > 0)
+ push_back(arg.substr(idx_fst, cur_len));
+ else empty_count++;
+ idx_fst = found_idx + sepLen;
+ search_from = idx_fst;
+ }
+
+ cur_len = arg.length()-search_from;
+ if(cur_len > 0)
+ push_back(arg.substr(search_from, cur_len));
+ else empty_count++;
+
+ return empty_count;
+}
+
+int string_list::separateForAny(const std::string& arg, const char* sep /* =" " */)
+{
+ clear(); // get rid of old stuff
+ int sepLen = 1 /*strlen(sep)*/, empty_count = 0;
+ int search_from = 0, idx_fst = 0, cur_len = 0, found_idx = string::npos;
+
+ while((found_idx = arg.find_first_of(sep, search_from)) != string::npos)
+ {
+ cur_len = found_idx - idx_fst;
+ if(cur_len > 0)
+ push_back(arg.substr(idx_fst, cur_len));
+ else empty_count++;
+ idx_fst = found_idx + sepLen;
+ search_from = idx_fst;
+ }
+
+ cur_len = arg.length()-search_from;
+ if(cur_len > 0)
+ push_back(arg.substr(search_from, cur_len));
+ else empty_count++;
+
+ return empty_count;
+}
+
+int string_list::separateForNull(const char * txtbuf, int maxlen /* = -1 */)
+{
+ clear(); // get rid of old stuff
+ string working_copy;
+ const char * p_start = txtbuf;
+ const char * p_run = NULL;
+ // make a length limited copy terminated by double zero if neccessary
+ if (maxlen != -1)
+ {
+ working_copy.assign(txtbuf, maxlen);
+ // null bytes can be appended this way += "\0" doesnt work
+ working_copy += '\0';
+ working_copy += '\0';
+ p_start = working_copy.c_str();
+ }
+ p_run = p_start;
+
+ while (true)
+ {
+ int curlen = strlen(p_run);
+ if (curlen == 0)
+ // end reached -- 0-byte at start not allowed
+ // no empty strings possible
+ break;
+ push_back(p_run);
+ p_run += curlen + 1;
+ }
+ return size();
+}
+
+std::string string_list::join(const char* sep /* =" " */)const
+{
+ // NOTE: algorithm is homomorphic with StringMapT<X>::domainAsString
+ const_iterator it=begin();
+ if(it == end()) return std::string("");
+ else
+ {
+ std::string y(*it++);
+ while(it != end()) { y+=sep; y += *it++; }
+ return y;
+ }
+}
+
+// like join, but sorting out empty elements
+std::string string_list::merge(const char* sep /* =" "*/)const
+{
+ const_iterator it=begin();
+ if(it == end()) return std::string("");
+ else
+ {
+ while(it != end() && (*it).empty()) it++;
+ if(it == end()) return std::string("");
+ std::string y(*it++);
+
+ while(it != end())
+ {
+ if((*it).empty()) it++;
+ else {y+=sep; y += *it++;}
+ }
+ return y;
+ }
+}
+
+
+
Added: sandbox/itl/boost/itl_xt/string_list.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/string_list.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,115 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class itl::string_list
+ A List of Strings.
+ Can be useful for string split and join.
+ Also simple text-formating can be done.
+--------------------------------------------------------------------*/
+#ifndef __itl_string_list_H_JOFA_990603__
+#define __itl_string_list_H_JOFA_990603__
+
+#include <string>
+#include <list>
+#include <boost/itl/notate.hpp>
+#include <boost/itl/itl_list.hpp>
+
+namespace boost{namespace itl
+{
+
+/// providing split, join and basic text processing
+/** class string_list implements a list of strings that provide split and
+ join functions and basic text formatting.
+
+ @author Joachim Faulhaber
+*/
+class string_list: public itl::list<std::string> //JODO URG no inhertiance from base container
+{
+public:
+ /** Empty string_list (default-Ctor) */
+ string_list(): list<std::string>() {}
+
+ /** Construction from an array of strings and an int 'nOfDeno' which must be the
+ number of array elements */
+ string_list(const char* const deno[], int nOfDeno);
+
+ /** Split stringT arg at spearators 'separator' to buid string_list *this.
+ Returns the number of empty strings within the List
+ */
+ int split(const std::string& arg, const char* separator = " ");
+
+ /** Works like split but sort out empty strings.
+ Returns the number of empty strings that have been sorted out.
+ */
+ int separate(const std::string& arg, const char* separator = " ");
+
+ /** Separates for ANY character, which is found in the separator string. */
+ int separateForAny(const std::string& arg, const char* separator = " ");
+
+ //The resulting list contains the sequence of null-terminated strings
+ //out of the buffer txtbuf, limited by the maximal length maxlen, which
+ //can be omitted by specifying -1
+ //buffer layout: txt1\0txt2\0\txt3\0\0 <-- double null byte marks end
+ //return value: number of strings found
+ int separateForNull(const char * txtbuf, int maxlen = -1);
+
+ /* concatenate all strings of this list inserting 'separator' between elements */
+ std::string join(const char* separator = " ")const;
+ /* concatenate all strings like join but sort out empty elements */
+ std::string merge(const char* separator = " ")const;
+
+ /* split all blank-separated words in stringT text into this list of words.
+ Words exceeding maxLen are seperated and a hyphen (-) is inserted */
+ void wordify(const std::string& text, int maxLen);
+
+ /* break down a list of words into a text paragraph of width maxLen */
+ void lineify(string_list& words, int maxLen);
+
+ /* break down a flat list of words into this text paragraph of width maxLen */
+ void format(const std::string& flatText, int maxLen);
+
+ /** get the 0 based index of that element, compare ignoring case */
+ int index_IgnoreCase(const std::string& text)const;
+
+ /** pop n elements from the front */
+ string_list& popFront(int n);
+
+ /** pop k elements from the front to keep at least n elements from the back*/
+ string_list& keepBack(int n);
+
+ /** Set 'count' tail-Elements to empty strings */
+ string_list& emptyTail(int count);
+} ;
+
+}} // namespace boost itl
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/string_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/string_map.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,61 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_string_map_JOFA_021215_H__
+#define __itl_string_map_JOFA_021215_H__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl/map.hpp>
+#include <string>
+
+namespace boost{namespace itl
+{
+ template <class CodomTV, class CompTV=less<std::string> >
+ class string_map : public MapT<std::string, CodomTV, CompTV>
+ {
+ };
+
+ // Compair class for Strings ingnoring case
+ struct string_ICLess {
+ bool operator() (const std::string& c1, const std::string& c2) const
+ {
+ //return c1.stricmp(c2)<0; //JODO URG
+ return c1 < c2; //JODO URG
+ }
+ };
+
+ // A template map class that's keys are handled case insensitive
+ template <class CodomTV>
+ class ICstring_map : public itl::string_map<CodomTV, string_ICLess>
+ {
+ };
+}} // namespace boost itl
+
+#endif // __itl_string_map_JOFA_021215_H__
+
+
+
Added: sandbox/itl/boost/itl_xt/string_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/string_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,109 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/*---------------------------------------------------------------------------------
+set of strings
+---------------------------------------------------------------------------------*/
+#ifndef __itl_string_set_H_JOFA_990318__
+#define __itl_string_set_H_JOFA_990318__
+
+#include <string>
+#include <string.h>
+#include <boost/itl/set.hpp>
+
+namespace boost{namespace itl
+{
+ typedef std::string StringTD;
+ typedef StringTD (StringTD::* StringSelectorFPD)()const;
+
+ // Compare class for Strings ignoring case
+ template<typename StringT>
+ struct String_ICLess {
+ bool operator() (const StringT& c1, const StringT& c2) const
+ { return _stricmp(c1.c_str(), c2.c_str()) < 0; }
+ };
+
+ template<typename StringT>
+ struct String_Less {
+ bool operator() (const StringT& c1, const StringT& c2) const
+ { return c1 < c2; }
+ };
+
+ // ---------------------------------------------------------------------------------
+ // sets of strings
+ // ---------------------------------------------------------------------------------
+
+ template <template<class>class Compare = std::less>
+ class string_set: public itl::set<std::string, Compare>
+ {
+ public:
+ typedef itl::set<std::string, Compare> base_type;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+
+ public:
+ std::string as_string(char* sep = " ")const; // JODO URG Sync
+ std::string join(char* sep = " ")const { return as_string(sep); } // JODO URG Sync
+ void selectSet(string_set& selectees, StringSelectorFPD selector)const;
+ } ;
+
+
+ // ---------------------------------------------------------------------------------
+ // sets of strings ordered ignoring case
+ // ---------------------------------------------------------------------------------
+
+ typedef string_set<String_ICLess> ICstring_set; //CL depreciated
+ typedef string_set<String_ICLess> ICstring_setD;
+
+
+ template <template<class>class Compare>
+ std::string string_set<Compare>::as_string(char* sep)const
+ {
+ const_iterator it = this->begin();
+ if(it == this->end()) return std::string("");
+ else
+ {
+ std::string y(*it++);
+ while(it != this->end()) { y += sep; y += (*it++); }
+ return y;
+ }
+ }
+
+
+ template <template<class>class Compare>
+ void string_set<Compare>::selectSet(string_set& selectees, StringSelectorFPD selector)const
+ {
+ selectees.clear();
+ const_FORALL_THIS(it)
+ selectees.insert(((*it).*selector)());
+ }
+}} // namespace boost itl
+
+
+#endif
+
+
Added: sandbox/itl/boost/itl_xt/string_sheet.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/string_sheet.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,124 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#include <stdafx.h>
+#include "string_sheet.h"
+#include <boost/itl/type_traits/to_string.hpp>
+
+using namespace boost::itl;
+
+
+string diff_desc::afxReport(const string& file)const
+{
+ string msg = "Difference in:\n";
+ msg += file + "\n";
+ msg += "d_size=" + value<int>::to_string(m_SizeDiff);
+ msg += " col=" + value<int>::to_string(m_RowSizeDiff) + "\n";
+ msg += "First Difference 1:ref 2:cur:\n";
+ msg += "First Difference 1:ref 2:cur:\n";
+ msg += m_Lhs + "\n";
+ msg += m_Rhs + "\n";
+
+ return msg;
+}
+
+
+void string_sheet::fprint(FILE* file, const char* sep)const
+{
+ const_FORALL_THIS(row_)
+ {
+ const string_list& row = (*row_);
+ fprintf(file, "%s\n", row.join(sep).c_str());
+ }
+}
+
+void string_sheet::fscan(ifstream& infile, const char* sep)
+{
+ char rawLine[MAX_INPUT_ROW_SIZE]; //JODO flex
+
+ while(!infile.eof())
+ {
+ infile.getline(rawLine, MAX_INPUT_ROW_SIZE);
+ string_list row;
+ row.split(rawLine, sep);
+ push_back(row);
+ }
+ pop_back(); // Schliessende Leerzeile wegnehmen
+}
+
+
+diff_desc string_sheet::diff(const string_sheet& rhs)const
+{
+ int thisSize = size();
+ int rhsSize = rhs.size();
+
+ diff_desc diff;
+ diff.setSizeDiff(thisSize - rhsSize);
+
+ int rowSize = std::min(thisSize, rhsSize);
+
+ string_sheet::const_iterator thisRow_ = begin();
+ string_sheet::const_iterator rhsRow_ = rhs.begin();
+
+ for(int rowIdx = 1; rowIdx <= rowSize; rowIdx++)
+ {
+ const string_list& thisRow = (*thisRow_);
+ const string_list& rhsRow = (*rhsRow_);
+
+ int lhsRowSize = thisRow.size();
+ int rhsRowSize = rhsRow.size();
+ if(lhsRowSize != rhsRowSize)
+ {
+ diff.setRow(rowIdx);
+ diff.setCol(std::min(lhsRowSize, rhsRowSize)+1);
+ diff.setRowSizeDiff(lhsRowSize - rhsRowSize);
+ return diff;
+ }
+
+ string_list::const_iterator lhsCol_ = thisRow.begin();
+ string_list::const_iterator rhsCol_ = rhsRow.begin();
+
+ for(int colIdx=1; colIdx <= lhsRowSize; colIdx++)
+ {
+ if((*lhsCol_) != (*rhsCol_))
+ {
+ diff.setRow(rowIdx);
+ diff.setCol(colIdx);
+ diff.setLhs(*lhsCol_);
+ diff.setRhs(*rhsCol_);
+ return diff;
+ }
+ lhsCol_++;
+ rhsCol_++;
+ }
+
+ thisRow_++;
+ rhsRow_++;
+ }
+
+ return diff;
+}
Added: sandbox/itl/boost/itl_xt/string_sheet.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/string_sheet.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,88 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_string_sheet_JOFA_050209_H__
+#define __itl_string_sheet_JOFA_050209_H__
+
+#include <iostream>
+#include <fstream>
+#include <boost/itl/string_list.hpp>
+#include <boost/itl/notate.hpp>
+
+namespace boost{namespace itl
+{
+
+ const int MAX_INPUT_ROW_SIZE = 10000;
+
+ class diff_desc
+ {
+ public:
+ diff_desc(): m_SizeDiff(0), m_RowSizeDiff(0), m_Row(0), m_Col(0), m_Lhs(), m_Rhs() {}
+
+ bool empty()const {
+ return m_SizeDiff==0 && m_RowSizeDiff==0 && m_Row==0;
+ }
+
+ int getSizeDiff()const {return m_SizeDiff;}
+ int getRowSizeDiff()const{return m_RowSizeDiff;}
+ int getRow()const {return m_Row;}
+ int getcol()const {return m_Col;}
+ std::string getLhs()const {return m_Lhs;}
+ std::string getRhs()const {return m_Rhs;}
+
+ void setSizeDiff (int SizeDiff){m_SizeDiff=SizeDiff;}
+ void setRowSizeDiff (int RowSizeDiff){m_RowSizeDiff=RowSizeDiff;}
+ void setRow (int Row){m_Row=Row;}
+ void setCol (int Col){m_Col=Col;}
+ void setLhs (std::string Lhs){m_Lhs=Lhs;}
+ void setRhs (std::string Rhs){m_Rhs=Rhs;}
+
+ std::string afxReport(const std::string& file)const;
+
+ private:
+ int m_SizeDiff;
+ int m_RowSizeDiff;
+ int m_Row;
+ int m_Col;
+ std::string m_Lhs;
+ std::string m_Rhs;
+ };
+
+ class string_sheet : public list<string_list>
+ {
+ public:
+ typedef list<string_list> string_sheetD;
+ public:
+ diff_desc diff(const string_sheet& rhs)const;
+
+ void fprint(FILE* file, const char* sep = "\t")const;
+ void fscan(std::ifstream& ifstr, const char* sep = "\t");
+ };
+}} // namespace itl boost
+
+#endif // __itl_string_sheet_JOFA_050209_H__
+
Added: sandbox/itl/boost/itl_xt/stringpattern_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/stringpattern_set.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,72 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_stringpattern_set_JOFA_040902_H__
+#define __itl_stringpattern_set_JOFA_040902_H__
+
+#include "prefix_set.h"
+namespace boost{namespace itl
+{
+ /// Specifies a set of strings via prefix_set s include and exclude
+ /** stringpattern_set repraesentiert eine Menge von Strings durch
+ zwei PrefixSetTs, der zugehoerigen und der nicht zugehoerigen
+ Strings.
+
+ Mit 'include' fuegt man Praefixe fuer zugehoerige Strings ein.
+ Mit 'exclude' fuegt man Praefixe fuer nicht zugehoerige Strings ein.
+
+ stringpattern_set s;
+ s.include("Han");
+ s.include("Har");
+ s.exclude("Hara");
+ s.contains("Hans")==true;
+ s.contains("Harald")==false;
+ */
+ class stringpattern_set
+ {
+ public:
+ void include(const string& val)
+ { m_Includes.insert(val); }
+
+ void exclude(const string& val)
+ { m_Excludes.insert(val); }
+
+ bool contains(const string& val)const
+ { return m_Includes.contains(val) && !m_Excludes.contains(val); }
+
+ private:
+ prefix_set m_Includes;
+ prefix_set m_Excludes;
+ };
+
+}} // namespace itl boost
+
+#endif // __itl_stringpattern_set_JOFA_040902_H__
+
+
Added: sandbox/itl/boost/itl_xt/tuple_computer.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/tuple_computer.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,505 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __tuple_computer_JOFA_040614_H__
+#define __tuple_computer_JOFA_040614_H__
+
+#include <boost/itl/map.hpp>
+#include <boost/itl_xt/var_tuple_order.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
+namespace boost{namespace itl
+{
+
+ template <int VarCount>
+ class tuple_computer_interface
+ {
+ public:
+ typedef var_tuple<VarCount> var_tuple_type;
+ typedef var_tuple_order<var_tuple_type> tuple_order_type;
+ typedef itl::set<var_tuple_type, var_tuple_order> tuple_set_type;
+
+ public:
+ virtual ~tuple_computer_interface(){};
+
+ //JODO Ergänzung + Comments + Zerlegung
+ virtual void domain(tuple_set_type&)const=0;
+
+ /// Add keyset of *this computer to tupelset 'accu'
+ virtual void addDomain(tuple_set_type& accu)const=0;
+
+ /** Load Computer from src. If *this has a different TupelOrder
+ *this is not a copy of 'src' but a recomputation according
+ to the different TupelOrder */
+ virtual void load(const tuple_computer_interface& src)=0;
+
+ /** Align *this TupelsComputers for domain such that this->domain()==domain.
+ Insert 0 or empty values for all tupels which are not in *this. */
+ virtual void alignFor(const tuple_set_type& domain)=0;
+
+ virtual std::string as_string()const=0;
+ };
+
+
+
+ // Alternative Names
+ // TupelCubeT
+ // TupicCubeT
+ // TupyCubeT
+ // HyperCubeT
+ // TupAss TupelAssociativeComputer
+ // A Tupel based Value Accumulator TuBaVator
+ // A Value associating Tupel Accumulator AVaTAr
+
+ /// Base class template for tuple computers aggregating values associated to tuples
+ /** On insertion of a (t1, ..., tn)->v tuple value pair, a value within
+ the tuple computer is summed by v, if the tuple t is already contained in
+ the tuple_computer_base.
+
+ Template parameter VarCount defines the size of the tuples.
+
+ Template parameter CounterT is the value type of the tuple_computer_base.
+ Those are the values to aggregated.
+ */
+ template <int VarCount, class CounterT>
+ class tuple_computer_base : public tuple_computer_interface<VarCount>
+ {
+ public:
+ typedef tuple_computer_interface<VarCount> base_type;
+ typedef typename base_type::tuple_set_type tuple_set_type;
+
+ public:
+
+ /** @name A: Type definitions for the template class
+ */
+ //@{
+ typedef var_tuple<VarCount> var_tuple_type;
+ typedef var_tuple_order<var_tuple_type> tuple_order_type;
+ /// Container type for the implementation
+ typedef itl::map<var_tuple_type, CounterT, neutron_absorber, var_tuple_order> ImplMapTD;
+ /// iterator
+ typedef typename ImplMapTD::iterator iterator;
+ /// const_iterator
+ typedef typename ImplMapTD::const_iterator const_iterator;
+
+ /// value type of the implementing container
+ typedef typename ImplMapTD::value_type value_type;
+ /// key type of the implementing container
+ typedef typename ImplMapTD::key_type key_type;
+ /// data type of the implementing container
+ typedef typename ImplMapTD::data_type data_type;
+
+ /// Type of strict weak ordering
+ typedef typename ImplMapTD::key_compare key_compare;
+
+ typedef CounterT counter_type;
+ //@}
+
+ // B: Constructors, destructors, assignment
+ /// Default constructor for the empty map
+ tuple_computer_base(): m_map() {}
+ /// Copy constructor
+ tuple_computer_base(const tuple_computer_base& src): m_map(src.m_map) {}
+
+ /// Construct from order
+ tuple_computer_base(const key_compare& ord): m_map(ord) {}
+
+ // Virtual constructor
+ //JODO? virtual tuple_computer_base* cons()const=0;
+ /// Virtual destructor
+ virtual ~tuple_computer_base(){};
+
+
+ /// Assignment operator
+ tuple_computer_base& operator = (const tuple_computer_base& src)
+ {
+ m_map.ImplMapTD::operator=(src.m_map);
+ return *this;
+ }
+
+ // ------------------------------------------------------------------------
+ // Interface MapIT
+ // C:
+
+ /// Remove all elements from the map
+ void clear() { m_map.clear(); }
+ /// Is the map empty?
+ bool empty()const { return m_map.empty(); }
+ /// Does the map contain an element for key x
+ bool contains(const var_tuple_type& x)const { return m_map.contains(x); }
+ /// Does the map contain a valuepair (tupel, counter)
+ bool contains(const value_type& x)const;
+
+ /// Get the set of keys
+ void domain(tuple_set_type& domain)const;
+ ///
+ void addDomain(tuple_set_type& domain)const;
+
+
+ /** @name F: Tester
+ */
+ //@{
+ /// <tt>*this</tt> is subset of <tt>super</tt>
+ bool isSubsetOf(const tuple_computer_base& super)const;
+ /// <tt>*this</tt> is subset of <tt>super</tt>
+ bool operator <= (const tuple_computer_base& super)const;
+
+ /// Equality
+ bool isEqual(const tuple_computer_base& x2)const
+ { return isSubsetOf(x2) && x2.isSubsetOf(*this); }
+ /// Equality operator
+ bool operator == (const tuple_computer_base& x2)const { return isEqual(x2); }
+ /// Inequality operator
+ bool operator != (const tuple_computer_base& x2)const { return !isEqual(x2); }
+
+ //@}
+
+
+ /** @name G: Modificators
+ */
+ //@{
+ /** Insertion of a (tupel, content) pair <tt>(t,x)</tt> */
+ void insert(const var_tuple_type& t, CounterT x)
+ { insert( value_type(t, x) ); }
+
+ /** Insertion of a (tupel, content) pair as <tt>value_pair</tt> */
+ void insert(const value_type& vt);
+ //@}
+
+ /** @name H: value search
+ */
+ //@{
+ /** */
+ iterator find(const var_tuple_type& tupel) { return m_map.find(tupel); }
+ const_iterator find(const var_tuple_type& tupel)const { return m_map.find(tupel); }
+ //@}
+
+
+
+ /** @name I: Interval iterators
+ */
+ //@{
+ ///
+ iterator begin() { return m_map.begin(); }
+ ///
+ iterator end() { return m_map.end(); }
+ ///
+ const_iterator begin()const { return m_map.begin(); }
+ ///
+ const_iterator end()const { return m_map.end(); }
+ //@}
+
+ /** @name S: String representation
+ */
+ //@{
+ ///
+ std::string as_string()const { return m_map.as_string(); }
+ //@}
+
+
+ int size()const { return m_map.size(); }
+
+ // NOTE! Die Ordnung, die ein TupelComputer verwendet ist fest, wir können zwar eine
+ // Kopie dieses Ordnungs-Objektes bekommen, aber keine Referenz. Also sind alle
+ // möglichen Transformationen nur dadurch zu machen, dass wir einen neuen
+ // Tupelcomputer mit entsprechendem Ordnungsobjekt (Funktor) kreieren und es
+ // dann befüllen. Der OrdnungsFunktor muss alle Möglichkeiten zur Verfügung
+ // stellen, also Umsortierung (Permutation), Projektion und Gruppierung.
+ // Gruppierung beinhaltet auch bedingte Äquivalenz. Dazu brauchen wir noch
+ // Filter: Ausblenden von Wertemengen und bedingte Filter: Ausblenden von Werten
+ // in Abhängigkeit von den Werten anderer UVs (oder UV-Gruppierungen)
+
+ private:
+ ImplMapTD m_map;
+ };
+
+
+ template <int VarCount, class CounterT>
+ void tuple_computer_base<VarCount, CounterT>::domain(tuple_set_type& domain)const
+ {
+ domain.clear();
+ addDomain(domain);
+ }
+
+
+ template <int VarCount, class CounterT>
+ void tuple_computer_base<VarCount, CounterT>::addDomain(tuple_set_type& domain)const
+ {
+ const_FORALL_THIS(tupel_)
+ domain.insert((*tupel_).KEY_VALUE);
+ }
+
+
+ template <int VarCount, class CounterT>
+ void tuple_computer_base<VarCount, CounterT>::insert(const value_type& val)
+ {
+ std::pair<typename ImplMapTD::iterator,bool> insertion = m_map.insert(val);
+
+ if(!insertion.WAS_SUCCESSFUL)
+ (*insertion.ITERATOR).CONT_VALUE += val.CONT_VALUE;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // JODO THINK: Es ist fraglich, ob wir überhaupt abgeleitete TupelComputer
+ // brauchen. Vielleicht lässt sich ja alles über entsprechende CounterT-
+ // Instanzen regeln.
+ // ------------------------------------------------------------------------
+
+ /// An amount_tuple_computer aggregates values (amounts) associated to tuples.
+ /** amount_tuple_computer is a TupleComputer that aggregates amounts
+ associated to tuples.
+
+ Template parameter VarCount defines the size of the used tuples.
+
+ CounteeT is the amount type, the type that is aggrgated.
+ Usually this shall be a numeric type. Yet it can also be
+ intantiated with any +=summable class type.
+ */
+ template <int VarCount, class CounteeT>
+ class amount_tuple_computer : public tuple_computer_base<VarCount, CounteeT>
+ {
+ public:
+ typedef tuple_computer_base<VarCount, CounteeT> base_type;
+ typedef typename base_type::key_type var_tuple_type;
+ typedef typename base_type::key_type key_type;
+ typedef typename base_type::key_compare key_compare;
+ typedef typename base_type::tuple_set_type tuple_set_type;
+
+ public:
+ // Default Ctor
+ amount_tuple_computer(): base_type() {}
+ // Copy Ctor
+ amount_tuple_computer(const amount_tuple_computer& src): base_type(src) {}
+ // Ctor from strict weak ordering
+ amount_tuple_computer(const key_compare& order): base_type(order) {}
+
+ public:
+ // Special interface that can not be expressed by TupelComputerT
+
+ void load(const tuple_computer_interface<VarCount>& srcI);
+
+ void alignFor(const tuple_set_type& domain)
+ {
+ const_FORALL(typename tuple_set_type, it_, domain)
+ this->insert(*it_, CounteeT());
+ }
+
+ };
+
+ template <int VarCount, class CounterT>
+ void amount_tuple_computer<VarCount, CounterT>::load(const tuple_computer_interface<VarCount>& srcI)
+ {
+ const amount_tuple_computer& src = dynamic_cast<const amount_tuple_computer&>(srcI);
+ const_FORALL(typename amount_tuple_computer, it_, src)
+ this->insert(*it_);
+ }
+
+
+
+ // ------------------------------------------------------------------------
+ /// A date_tuple_computer aggregates points in time (dates) associated to tuples.
+ /** class date_tuple_computer: Merkmalskombinationsrechner (flavor: Zeitpunktrechner)
+
+ Jedem Tupel (Merkmalskombination) wird ein Map assoziiert, das Zeitpunkte
+ (Dates) zählen kann.
+ */
+ template <int VarCount, class TimeT, class CounteeT>
+ class date_tuple_computer :
+ public tuple_computer_base<VarCount, itl::map<TimeT, CounteeT> >
+ {
+ public:
+ typedef typename itl::map<TimeT, CounteeT> counter_type;
+ typedef tuple_computer_base<VarCount, counter_type> base_type;
+ typedef typename base_type::var_tuple_type var_tuple_type;
+ typedef typename base_type::key_compare key_compare;
+ typedef typename itl::set<var_tuple_type, var_tuple_order>
+ tuple_set_type;
+
+ public:
+ // Default Ctor
+ date_tuple_computer(): base_type() {}
+ // Copy Ctor
+ date_tuple_computer(const date_tuple_computer& src): base_type(src) {}
+ // Ctor from strict weak ordering
+ date_tuple_computer(const key_compare& order): base_type(order) {}
+
+ public:
+ // Special interface that can not be expressed by TupelComputerT
+
+ void load(const tuple_computer_interface<VarCount>& srcI);
+
+ void alignFor(const tuple_set_type& domain)
+ {
+ const_FORALL(typename tuple_set_type, it_, domain)
+ insert(*it_, counter_type());
+ }
+
+ };
+
+ template <int VarCount, class TimeT, class CounteeT>
+ void date_tuple_computer<VarCount,TimeT,CounteeT>::load(const tuple_computer_interface<VarCount>& srcI)
+ {
+ const date_tuple_computer& src = dynamic_cast<const date_tuple_computer&>(srcI);
+ const_FORALL(typename date_tuple_computer, it_, src)
+ insert(*it_);
+ }
+
+
+
+ // ------------------------------------------------------------------------
+ /// Aggregates intervals associated to tuples
+ /** class interval_tuple_computer: Merkmalskombinationsrechner (flavor:
+ Zeitraumrechner). Jedem Tupel (Merkmalskombination) wird ein
+ split_interval_map assoziiert, das Zeiträume (Itv=Interval) zählen
+ kann. Genauer gesagt werden Zustände gezählt, die für einen Zeitraum
+ anhalten. Bei Überlappungen der Zeiträume müssen die die Häufigkeiten
+ im split_interval_map entsprechend aufaddiert werden.
+ */
+ template <int VarCount, class TimeT, class CounteeT>
+ class interval_tuple_computer :
+ public tuple_computer_base<VarCount,
+ split_interval_map<TimeT, CounteeT> >
+ {
+ public:
+ typedef split_interval_map<TimeT, CounteeT> counter_type;
+ typedef tuple_computer_base<VarCount, counter_type> base_type;
+ typedef typename base_type::var_tuple_type var_tuple_type;
+ typedef typename base_type::key_compare key_compare;
+ typedef itl::set<var_tuple_type, var_tuple_order> tuple_set_type;
+ typedef typename base_type::counter_type::interval_type interval_type;
+
+ private:
+ typedef itl::map<TimeT, CounteeT> DateMapTD;
+
+ public:
+ // Default Ctor
+ interval_tuple_computer(): base_type() {}
+ // Copy Ctor
+ interval_tuple_computer(const interval_tuple_computer& src): base_type(src) {}
+ // Ctor from strict weak ordering
+ interval_tuple_computer(const key_compare& order): base_type(order) {}
+
+ public:
+ // Special interface that can not be expressed by TupelComputerT
+
+ void load(const tuple_computer_interface<VarCount>& srcI);
+
+ // Eine Menge von ZeitPUNKTEN einfügen. Diese werden in Intervalle gewandelt
+ void insertDateMap(const var_tuple_type tup, const DateMapTD& date);
+
+ void alignFor(const tuple_set_type& domain)
+ {
+ const_FORALL(typename tuple_set_type, it_, domain)
+ insert(*it_, counter_type());
+ }
+ };
+
+
+ template <int VarCount, class TimeT, class CounteeT>
+ void interval_tuple_computer<VarCount,TimeT,CounteeT>::load(const tuple_computer_interface<VarCount>& srcI)
+ {
+ const interval_tuple_computer& src = dynamic_cast<const interval_tuple_computer&>(srcI);
+ const_FORALL(typename interval_tuple_computer, it_, src)
+ insert(*it_);
+ }
+
+ template <int VarCount, class TimeT, class CounteeT>
+ void interval_tuple_computer<VarCount,TimeT,CounteeT>::insertDateMap(const var_tuple_type tup, const DateMapTD& date)
+ {
+ counter_type itvCounter;
+ const_FORALL(typename DateMapTD, date_, date)
+ {
+ itvCounter.insert(
+ counter_type::value_type(
+ counter_type::interval_type((*date_).KEY_VALUE, (*date_).KEY_VALUE),
+ (*date_).CONT_VALUE
+ )
+ );
+ }
+
+ insert(value_type(tup, itvCounter));
+ }
+
+
+
+ //JODO: Where to put this kind of functionality
+ template <class SubType, class ItvDomTV, class CodomTV>
+ void intervalize(interval_base_map<SubType, ItvDomTV, CodomTV>& itvMap,
+ const itl::map<ItvDomTV, CodomTV>& dateMap)
+ {
+ typedef itl::map<ItvDomTV, CodomTV> DateMapTD;
+ typedef interval_base_map<SubType, ItvDomTV, CodomTV> ItvMapTD;
+
+ itvMap.clear();
+ const_FORALL(typename DateMapTD, date_, dateMap)
+ {
+ itvMap.insert(
+ ItvMapTD::value_type(
+ ItvMapTD::interval_type((*date_).KEY_VALUE, (*date_).KEY_VALUE),
+ (*date_).CONT_VALUE
+ )
+ );
+ }
+ }
+
+ //JODO Move this;
+ //JODO DESIGN: Memfunction of interval_base_set? destructive + constructive. Self-deviding
+
+ //NOTE: ItvMap GridSum
+ template <class SubType, class ItvDomTV, class CodomTV>
+ void sumWithin(interval_base_map<SubType, ItvDomTV, CodomTV>& gridSums,
+ interval_base_map<SubType, ItvDomTV, CodomTV>& interSection,
+ const interval_base_map<SubType, ItvDomTV, CodomTV>& itvMap,
+ const split_interval_set<ItvDomTV>& grid)
+ {
+ typedef interval_base_map<SubType, ItvDomTV, CodomTV> ItvMapTD;
+ typedef split_interval_set<ItvDomTV> DiscItvSetTD;
+
+ gridSums.clear();
+ interSection.clear();
+ if(itvMap.empty()) return;
+
+ ItvMapTD* aux = itvMap.cons();
+ //JODO OPTI: optimize using the ordering: if intervalls are beyond borders we can terminate
+ const_FORALL(typename DiscItvSetTD, itv_, grid)
+ {
+ itvMap.intersect(*aux, *itv_);
+ gridSums.insert(ItvMapTD::value_type(*itv_, (*aux).volume()));
+ interSection += (*aux);
+ }
+
+ }
+
+}} // namespace itl boost
+
+#endif // __tuple_computer_JOFA_040614_H__
+
+
+
Added: sandbox/itl/boost/itl_xt/typed_episode.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/typed_episode.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,79 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __itl_typed_episode_hpp_JOFA_011015_H__
+#define __itl_typed_episode_hpp_JOFA_011015_H__
+
+#include <boost/itl/interval.hpp>
+#include <boost/itl_xt/ordered_type.hpp>
+
+namespace boost{namespace itl
+{
+
+/// Serves as a base class for the decomposition of histories in episodes
+/**
+ <b>Episoden-Intercace</b>
+
+ Eine Episode besitzt ein Intervall.
+
+ @author Joachim Faulhaber
+*/
+template <class TimeT>
+class episode_interface
+{
+public:
+
+ /// virtual dtor: cave leakem
+ virtual ~episode_interface(){}
+
+ /// das Intervall der Episode
+ virtual itl::interval<TimeT> interval()const=0;
+};
+
+/// typed_episode is an episode that can be ordered wrt. it's type
+/**
+ <b>ein Episode mit Typ dazu</b>
+
+ Die Klasse typed_episode ist nach Typ sortierbar, denn sie
+ implementiert \ref ordered_type. Ausserdem ist es eine Episode, denn
+ sie implementiert \ref episode_interface.
+
+ @author Joachim Faulhaber
+*/
+template <class TimeT, class TypeDomain>
+class typed_episode : public ordered_type_base<TypeDomain>, public episode_interface<TimeT>
+{
+};
+
+}} // namespace itl boost
+
+#endif // __itl_typed_episode_hpp_JOFA_011015_H__
+
+
+
Added: sandbox/itl/boost/itl_xt/var_permutation.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/var_permutation.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,268 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __var_permutation_JOFA_040621_H__
+#define __var_permutation_JOFA_040621_H__
+
+#include <string.h>
+#include <boost/itl_xt/fixtupelconst.hpp>
+#include <boost/itl_xt/list.hpp>
+
+namespace boost{namespace itl
+{
+
+ template <int varCountV>
+ class var_permutation
+ {
+ public:
+ typedef itl::list<VarEnumTD> ListTD;
+ public:
+ var_permutation(): m_Size(0) {}
+ var_permutation(const var_permutation&);
+ var_permutation& operator = (const var_permutation&);
+
+ /// Hinten anfuegen
+ var_permutation& add(VarEnumTD var);
+ /// Von hinten 'count' Elemente loeschen
+ var_permutation& del(int count = 1);
+
+ int size()const { return m_Size; }
+ void setIdentity();
+ var_permutation& clear() { m_Size = 0; return *this; }
+
+ /** Liefert zum Index 'permIdx' die unabhängige Variable var=permutation[permIdx].
+ Da es sich um eine schnelle Primitive handelt, wird der Gültigkeitsbereich des
+ Arguments 0 <= permIdx <m_Size nicht geprüft. */
+ VarEnumTD operator[] (VarEnumTD permIdx)const { return m_Permutation[permIdx]; }
+
+ /** Liefert zum Index 'permIdx' die unabhängige Variable var=permutation[permIdx].
+ Liefert -1, wenn permIdx kein gültiger Index ist. */
+ VarEnumTD getVar(VarEnumTD permIdx)
+ { return (0 <= permIdx && permIdx < m_Size) ? m_Permutation[permIdx] : UNDEFINED_INDEX; }
+
+ var_permutation operator() (VarEnumTD fst, VarEnumTD lst)const;
+
+ /** Index zur Variable 'var' finden. Liefert -1, wenn 'var' nicht gefunden.
+ index=find(var) ist hierbei der Index 0 <= index < m_Size der Permutation die den
+ Wert der unabhängigen Variable 'var' enthält. */
+ int find(VarEnumTD var)const;
+
+ /// Ist 'var' enthalten?
+ bool contains(VarEnumTD var)const { return 0 <= find(var); }
+
+ /// Fuege 'var' an der Stelle 'pos' ein. Liefert false, wenn insert scheitert.
+ bool insert(VarEnumTD var, int pos);
+
+ /// Das Element mit dem Wert 'val' loeschen
+ var_permutation& remove(VarEnumTD val);
+
+ /** 'perm' ist eine Permutation von 'seq', so dass perm eine Untersequenz
+ von *this ist, in der keine Vertauschungen der Reihenfolge von *this vorkommen.
+ 'perm' ist vertauschungsfreie Untersequenz von *this.
+ Voraussetzung ist, dass die Elemente von 'seq' in *this enthalten sind. */
+ void consequent_permutation(var_permutation& perm, const var_permutation& seq)const;
+
+ /** Liefert den reduzierten Aggregationsgrad einer Untersequenz 'subSeq'.
+ 'subSeq' hat natuerlich weniger Aggregationsgrade, als *this. Wir tun so,
+ als waeren alle Elemente von *this ausgeblendet. Jedes Element, das in
+ *this ausgebelendet ist, wird von grade abgezogen.
+ */
+ int gradeReduct(int grade, const var_permutation& subSeq)const;
+
+
+ ListTD asList()const;
+ std::string as_string()const;
+
+ private:
+ VarEnumTD m_Permutation[varCountV];
+ int m_Size;
+ };
+
+ template <int varCountV>
+ var_permutation<varCountV>::var_permutation (const var_permutation<varCountV>& src)
+ {
+ m_Size = src.m_Size;
+ FOREACH_VAR_TO(idx, m_Size)
+ m_Permutation[idx] = src.m_Permutation[idx];
+ }
+
+ template <int varCountV>
+ var_permutation<varCountV>& var_permutation<varCountV>::operator = (const var_permutation<varCountV>& src)
+ {
+ if(&src != this)
+ {
+ m_Size = src.m_Size;
+ FOREACH_VAR_TO(idx, m_Size)
+ m_Permutation[idx] = src.m_Permutation[idx];
+ }
+ return *this;
+ }
+
+
+ template <int varCountV>
+ void var_permutation<varCountV>::setIdentity()
+ {
+ FOREACH_VAR(idx)
+ m_Permutation[idx] = idx;
+ m_Size = varCountV;
+ }
+
+ template <int varCountV>
+ var_permutation<varCountV>& var_permutation<varCountV>::add(VarEnumTD var)
+ {
+ if(m_Size < varCountV)
+ {
+ m_Permutation[m_Size] = var;
+ m_Size++;
+ }
+ return *this;
+ }
+
+ template <int varCountV>
+ var_permutation<varCountV>& var_permutation<varCountV>::del(int count) // = 1 default
+ {
+ int back = std::min(count, m_Size);
+ m_Size -= back;
+ return *this;
+ }
+
+ template <int varCountV>
+ var_permutation<varCountV> var_permutation<varCountV>::operator() (VarEnumTD fst, VarEnumTD lst)const
+ {
+ var_permutation perm;
+ for(VarEnumTD idx = fst; idx < lst; idx++)
+ perm.add((*this)[idx]);
+
+ return perm;
+ }
+
+ template <int varCountV>
+ var_permutation<varCountV>& var_permutation<varCountV>::remove(VarEnumTD val)
+ {
+ int doomedIdx = find(val);
+ if(doomedIdx == UNDEFINED_INDEX)
+ return *this;
+
+ for(int idx=doomedIdx; idx < (m_Size-1); idx++)
+ m_Permutation[idx] = m_Permutation[idx+1];
+
+ m_Size--;
+
+ return *this;
+ }
+
+ template <int varCountV>
+ int var_permutation<varCountV>::find(VarEnumTD val)const
+ {
+ int hit = UNDEFINED_INDEX;
+ for(int idx=0; idx<m_Size; idx++)
+ if(m_Permutation[idx]==val)
+ return idx;
+
+ return hit;
+ }
+
+
+ template <int varCountV>
+ bool var_permutation<varCountV>::insert(VarEnumTD var, int pos)
+ {
+ //JODO URG untested
+ BOOST_ASSERT(!contains(var)) //var_permutation has to be unique;
+ if(varCountV <= var || varCountV == m_Size)
+ return false;
+
+ // Alle nach rechts schaufeln
+ for(int idx=pos; idx < m_Size; idx++)
+ m_Permutation[idx+1] = m_Permutation[idx];
+
+ m_Permutation[pos] = var;
+ }
+
+ template <int varCountV>
+ std::string var_permutation<varCountV>::as_string()const
+ {
+ std::string repr = "[";
+ int idx = 0;
+ if(m_Size>0)
+ repr += to_string<VarEnumTD>::apply(m_Permutation[idx++]);
+
+ while(idx<m_Size)
+ repr += to_string<VarEnumTD>::apply(m_Permutation[idx++]);
+
+ repr += "]";
+
+ return repr;
+ }
+
+
+ template <int varCountV>
+ typename itl::var_permutation<varCountV>::ListTD var_permutation<varCountV>::asList()const
+ {
+ ListTD seq;
+ int idx = 0;
+ while(idx < m_Size)
+ seq.push_back(m_Permutation[idx++]);
+ return seq;
+ }
+
+
+ template <int varCountV>
+ void var_permutation<varCountV>::consequent_permutation(var_permutation& perm, const var_permutation& seq)const
+ {
+ ListTD master = asList(),
+ conseq,
+ unseq = seq.asList();
+
+ master.consequent_permutation(conseq, unseq);
+
+ perm.clear();
+ const_FORALL(ListTD, it_, conseq)
+ perm.add(*it_);
+ }
+
+ template <int varCountV>
+ int var_permutation<varCountV>::gradeReduct(int grade, const var_permutation& subSeq)const
+ {
+ // subSeq ist echte Untersequenz von *this.
+ if(grade==0)
+ return 0;
+ int subIdx = 0;
+ for(int varIdx = 0; varIdx < size(); varIdx++)
+ {
+ if(subSeq[subIdx] == (*this)[varIdx])
+ subIdx++;
+ if(varIdx+1 == grade)
+ return subIdx;
+ }
+ }
+
+
+}} // namespace itl boost
+
+#endif // __var_permutation_JOFA_040621_H__
+
+
Added: sandbox/itl/boost/itl_xt/var_tuple.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/var_tuple.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,161 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+#ifndef __var_tuple_JOFA_040614_H__
+#define __var_tuple_JOFA_040614_H__
+
+#include <boost/itl/notate.hpp>
+#include <boost/itl_xt/fixtupelconst.hpp>
+#include <string>
+#include <sstream>
+
+namespace boost{namespace itl
+{
+ /// tuple of independent variables
+ /** class var_tuple: Die Tupel unabhängiger Variablen. Beschreiben
+ die Zellen eines n-dimensionalen Zählwürfels
+
+ Zuständigkeit: Zellen eines n-dimensionalen Zählwürfels beschreiben. Als
+ Index für Merkmalskombinationsrechner dienen. (Um)Ordnen, Projizieren und
+ Gruppieren unterstützen.
+
+ Zusammenarbeit: Order, Projection, Grouping, Merkmalskombinationsrecher
+
+ FastVarTupel ist schnell (Fast), da es als einfaches array[int] implemetiert wird
+ */
+ template <int varCountV>
+ class var_tuple
+ {
+ public:
+ enum { var_count = varCountV };
+ public:
+ /// Default Ctor. Achtung absichtlich keine Initialisierung!
+ var_tuple(){};
+ /// Ctor initialisiere alle Elemente des Tupels auf einen Wert
+ var_tuple(StatVarTD);
+
+ /// Copy Ctor
+ var_tuple(const var_tuple&);
+
+ /// Assignment
+ var_tuple& operator = (const var_tuple&);
+
+ /// Größe des Tupels
+ int size()const { return varCountV; }
+
+ /// Gleichheit
+ bool operator == (const var_tuple&)const;
+
+ /// Standard-Ordnung
+ bool operator < (const var_tuple&)const;
+
+ /// Lesender Zugriff auf Elemente
+ StatVarTD operator [] (int idx)const { return m_tupel[idx]; }
+ /// Modifizierender Zugriff
+ StatVarTD& operator [] (int idx) { return m_tupel[idx]; }
+
+ ///
+ std::string as_string()const;
+
+ private:
+ StatVarTD m_tupel[varCountV];
+
+ };
+
+
+ template <int varCountV>
+ itl::var_tuple<varCountV>::var_tuple (StatVarTD val) // vor VC8: itl::var_tuple<varCountV>::var_tuple<varCountV>(StatVarTD val)
+ {
+ FOREACH_VAR(idx)
+ m_tupel[idx] = val;
+ }
+
+ template <int varCountV>
+ itl::var_tuple<varCountV>::var_tuple (const var_tuple<varCountV>& src)
+ {
+ FOREACH_VAR(idx)
+ m_tupel[idx] = src.m_tupel[idx];
+ }
+
+ template <int varCountV>
+ var_tuple<varCountV>& var_tuple<varCountV>::operator = (const var_tuple<varCountV>& src)
+ {
+ if(&src != this)
+ {
+ FOREACH_VAR(idx)
+ m_tupel[idx] = src.m_tupel[idx];
+ }
+ return *this;
+ }
+
+
+ template <int varCountV>
+ bool var_tuple<varCountV>::operator == (const var_tuple<varCountV>& rhs)const
+ {
+ for(int idx=0; idx < varCountV; idx++)
+ if(m_tupel[idx] != rhs.m_tupel[idx]) return false;
+
+ return true;
+ }
+
+
+ template <int varCountV>
+ bool var_tuple<varCountV>::operator < (const var_tuple<varCountV>& rhs)const
+ {
+ FOREACH_VAR(idx)
+ if(m_tupel[idx] < rhs.m_tupel[idx]) return true;
+ else if (m_tupel[idx] > rhs.m_tupel[idx]) return false;
+
+ // because all are equal
+ return false;
+ }
+
+ template <int varCountV>
+ std::string var_tuple<varCountV>::as_string()const
+ {
+ std::stringstream repr;
+ repr << "(";
+ for(int idx = 0; idx < varCountV-1; idx++)
+ repr << m_tupel[idx] << ",";
+
+ if(varCountV==0) repr << ")";
+ else repr << m_tupel[varCountV-1] << ")";
+
+ return repr.str();
+ }
+
+
+}} // namespace itl boost
+
+
+
+#endif // __var_tuple_JOFA_040614_H__
+
+
Added: sandbox/itl/boost/itl_xt/var_tuple_inscriptor.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/var_tuple_inscriptor.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,91 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __var_tuple_inscriptor_JOFA_041006_H__
+#define __var_tuple_inscriptor_JOFA_041006_H__
+
+#include <boost/itl/string_list.hpp>
+#include <boost/itl/map.hpp>
+#include <boost/itl/var_permutation.hpp>
+#include <boost/itl/var_tuple.hpp>
+
+namespace boost{namespace itl
+{
+
+
+ template <int varCountV>
+ class var_tuple_inscriptor
+ {
+ private:
+ typedef var_tuple<varCountV> var_tupleT;
+ typedef var_permutation<varCountV> var_permutationT;
+ typedef MapT<int,int> OmissionMapTD;
+
+ public:
+ /** Die Permutation sorgt dafür, dass die Auswahl und Reihenfolge der Beschriftung
+ geändert werden kann. */
+ void setPermutation(const var_permutationT& perm) { m_Perm = perm; }
+ var_permutationT getPermutation()const { return m_Perm; }
+
+ /** Konvertiere einen Tupel von Werten unabhängiger Variablen in eine StringListe
+ von Beschriftungen: Diese dient als Zeilenbeschriftung für Statistikblätter
+ der Excelausgabe.
+
+ 'changeVar' ist der Index der Variablen, die sich bei einer Iteration aendert.
+ So haben wir die Moeglichkeit nur VariablenLabels bei Aenderung auszugeben.
+ changeVar=0 fuehrt dazu, dass alle Variablenabels fuer ein Tulel ausgegeben
+ werden.
+ */
+ virtual void getValueLabels(StringListT& valueLabels, const var_tupleT& tup,
+ VarEnumTD changeVar, int grade)const=0;
+
+ /** Die Liste der Variablentitel anfügen */
+ virtual void addVarTitles(StringListT& headers)const=0;
+
+ /** Nach der Variable 'permVar' werden 'count' spalten leer gelassen */
+ void addOmission(int permVar, int count)
+ { m_Omissions[permVar] = count; }
+
+ int omissionCount(int permVar)const
+ {
+ OmissionMapTD::const_iterator count_ = m_Omissions.find(permVar);
+ if(count_ == m_Omissions.end())
+ return 0;
+ else
+ return (*count_).CONT_VALUE;
+ }
+
+ protected:
+ var_permutationT m_Perm;
+ OmissionMapTD m_Omissions;
+ };
+
+}} // namespace itl boost
+
+#endif // __var_tuple_inscriptor_JOFA_041006_H__
+
+
Added: sandbox/itl/boost/itl_xt/var_tuple_order.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl_xt/var_tuple_order.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,161 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+#ifndef __var_tuple_order_JOFA_040620_H__
+#define __var_tuple_order_JOFA_040620_H__
+
+#include <functional>
+#include <boost/itl/notate.hpp>
+#include <boost/itl_xt/fixtupelconst.hpp>
+#include <boost/itl_xt/var_tuple.hpp>
+#include <boost/itl_xt/var_permutation.hpp>
+#include <boost/itl_xt/grouping.hpp>
+
+namespace boost{namespace itl
+{
+
+ // template <typename VarTupleT> class var_permutation {};
+
+ template <typename VarTupleT>
+ class var_tuple_order : public std::binary_function<VarTupleT, VarTupleT, bool>
+ {
+ public:
+ enum { varCountV = VarTupleT::var_count };
+ typedef var_permutation<varCountV> var_permutationT;
+ typedef grouping<varCountV> groupingT;
+ typedef group_order<varCountV> group_orderT;
+
+ var_tuple_order();
+ var_tuple_order(const var_tuple_order&, const var_permutationT&);
+
+ bool operator() (const VarTupleT& x1, const VarTupleT& x2)const;
+
+ /** Index des ersten Unterschieds zweier Tupel (gemäss der permutierten Reihenfolge).
+ Die permutierte Reihenfolge ist ja die jeweils gültige Reihenfolge. */
+ VarEnumTD indexOfFirstDifference(const VarTupleT& x1, const VarTupleT& x2)const;
+
+ void setPermutation(const var_permutationT& perm) { m_Permutation = perm; }
+ var_permutationT getPermutation()const { return m_Permutation; }
+
+ void setGroupOrder(group_orderT* order) { m_Grouping.setGrouper(order, order->getVarIndex()); }
+
+ /** Liefert den reduzierten Aggregationsgrad einer Teilordnung, die in *this enthalten ist. */
+ int gradeReduct(int grade, const var_tuple_order& subOrder)const
+ { return m_Permutation.gradeReduct(grade, subOrder.getPermutation()); }
+
+ private:
+ // Permutation can also express projection. All independent vars not included in
+ // the permutation are switched off
+ var_permutationT m_Permutation;
+
+ // Conditional and unconditional Grouping
+ groupingT m_Grouping;
+ };
+
+ template <typename VarTupleT>
+ itl::var_tuple_order<VarTupleT>::var_tuple_order ()
+ {
+ m_Permutation.setIdentity();
+ }
+
+ template <typename VarTupleT>
+ itl::var_tuple_order<VarTupleT>::var_tuple_order (const var_tuple_order& order, const var_permutationT& perm):
+ m_Grouping(order.m_Grouping), m_Permutation(perm)
+ {}
+
+
+ template <typename VarTupleT>
+ bool itl::var_tuple_order<VarTupleT>::operator() (const VarTupleT& x1, const VarTupleT& x2)const
+ {
+ FORALL_VEC(permIdx, m_Permutation)
+ {
+ int idx = m_Permutation[permIdx];
+
+ // Den Pointer der Gruppierungsordnung besorgen
+ const group_orderT* groupedLess = m_Grouping[idx];
+
+ if(groupedLess == NULL)
+ {
+ if(x1[idx] < x2[idx])
+ return true;
+ if(x1[idx] > x2[idx])
+ return false;
+ // OTHERWISE (x1[idx] == x2[idx]): proceed to next variable
+ }
+ else
+ {
+ if((*groupedLess)(x1,x2))
+ return true;
+ if((*groupedLess)(x2,x1))
+ return false;
+ // OTHERWISE x1 and x2 belong to same group. Proceed to next var
+ }
+
+ }
+ // All components are equal
+ return false;
+ }
+
+ template <typename VarTupleT>
+ VarEnumTD itl::var_tuple_order<VarTupleT>::indexOfFirstDifference(const VarTupleT& x1, const VarTupleT& x2)const
+ {
+ FORALL_VEC(permIdx, m_Permutation)
+ {
+ int idx = m_Permutation[permIdx];
+
+ // Den Pointer der Gruppierungsordnung besorgen
+ const group_orderT* groupedLess = m_Grouping[idx];
+
+ if(groupedLess == NULL)
+ {
+ if(x1[idx] < x2[idx])
+ return permIdx;
+ if(x1[idx] > x2[idx])
+ return permIdx;
+ // OTHERWISE (x1[idx] == x2[idx]): proceed to next variable
+ }
+ else
+ {
+ if((*groupedLess)(x1,x2))
+ return permIdx;
+ if((*groupedLess)(x2,x1))
+ return permIdx;
+ // OTHERWISE x1 and x2 belong to same group. Proceed to next var
+ }
+
+ }
+ // All components are equal
+ return UNDEFINED_INDEX;
+ }
+
+}} // namespace itl boost
+
+#endif // __var_tuple_order_JOFA_040620_H__
+
+
Added: sandbox/itl/boost/validate/gentor/gentorprofile.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/gentor/gentorprofile.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,118 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#pragma once
+
+#include <boost/itl/interval.hpp>
+
+namespace boost{namespace itl
+{
+
+ class GentorProfile
+ {
+ public:
+ GentorProfile();
+
+ void set_range_int(int lwb, int upb)
+ { _range_int = rightopen_interval(lwb, upb); }
+ void set_range_double(double lwb, double upb)
+ { _range_double = rightopen_interval(lwb, upb); }
+ void set_range_ContainerSize(int lwb, int upb)
+ { _range_ContainerSize = rightopen_interval(lwb, upb); }
+ void set_range_interval_int(int lwb, int upb)
+ { _range_interval_int = rightopen_interval(lwb, upb); }
+ void set_range_interval_double(double lwb, double upb)
+ { _range_interval_double = rightopen_interval(lwb, upb); }
+ void set_maxIntervalLength(int val)
+ { _maxIntervalLength = val; }
+ void set_range_element_ContainerSize(int lwb, int upb)
+ { _range_element_ContainerSize = rightopen_interval(lwb, upb); }
+
+ interval<int> range_int() { return _range_int; }
+ interval<double> range_double() { return _range_double; }
+ interval<int> range_ContainerSize() { return _range_ContainerSize; }
+ interval<int> range_interval_int() { return _range_interval_int; }
+ interval<double> range_interval_double() { return _range_interval_double; }
+ int maxIntervalLength() { return _maxIntervalLength; }
+ interval<int> range_element_ContainerSize()
+ { return _range_element_ContainerSize; }
+
+ private:
+ interval<int> _range_int;
+ interval<double> _range_double;
+ interval<int> _range_ContainerSize;
+
+ interval<int> _range_interval_int;
+ interval<double> _range_interval_double;
+ int _maxIntervalLength;
+
+ interval<int> _range_element_ContainerSize;
+ };
+
+ class GentorProfileSgl // SINGLETON PATTERN
+ {
+ // Singleton pattern part -----------------------------------------------------
+ public:
+ static GentorProfileSgl* it(); // function to call the unique instance
+
+ protected:
+ GentorProfileSgl(); // default constructor is not callable from outside
+ // preventing illegal instances
+
+ // specific interface ---------------------------------------------------------
+ public:
+ void set_range_int(int lwb, int upb) { m_profile.set_range_int(lwb, upb); }
+ void set_range_double(double lwb, double upb) { m_profile.set_range_double(lwb, upb); }
+ void set_range_ContainerSize(int lwb, int upb) { m_profile.set_range_ContainerSize(lwb, upb); }
+ void set_range_interval_int(int lwb, int upb) { m_profile.set_range_interval_int(lwb, upb); }
+ void set_range_interval_double(double lwb, double upb){ m_profile.set_range_interval_double(lwb, upb); }
+ void set_maxIntervalLength(int val) { m_profile.set_maxIntervalLength(val); }
+ void set_range_element_ContainerSize(int lwb, int upb)
+ { m_profile.set_range_element_ContainerSize(lwb, upb); }
+
+ interval<int> range_int() { return m_profile.range_int(); }
+ interval<double> range_double() { return m_profile.range_double(); }
+ interval<int> range_ContainerSize() { return m_profile.range_ContainerSize(); }
+ interval<int> range_interval_int() { return m_profile.range_interval_int(); }
+ interval<double> range_interval_double() { return m_profile.range_interval_double();}
+ int maxIntervalLength() { return m_profile.maxIntervalLength(); }
+ interval<int> range_element_ContainerSize(){ return m_profile.range_element_ContainerSize(); }
+
+
+ private:
+ // Singleton pattern part -------------------------------------------------
+ static GentorProfileSgl* s_instance; // pointer to the unique instance
+
+ // specific members -------------------------------------------------------
+
+ // TODO add specifc members as needed
+ GentorProfile m_profile;
+ };
+
+ template<typename NumberT>
+ struct GentorProfileSgl_numeric_range
+ {
+ static interval<NumberT> get();
+ };
+
+ template<>
+ struct GentorProfileSgl_numeric_range<int>
+ {
+ static interval<int> get()
+ { return GentorProfileSgl::it()->range_int(); }
+ };
+
+ template<>
+ struct GentorProfileSgl_numeric_range<double>
+ {
+ static interval<double> get()
+ { return GentorProfileSgl::it()->range_double(); }
+ };
+
+}} // namespace itl boost
Added: sandbox/itl/boost/validate/gentor/randomgentor.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/gentor/randomgentor.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,421 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#pragma once
+
+
+#include <boost/itl_xt/numbergentor.hpp>
+#include <boost/itl_xt/setgentor.hpp>
+#include <boost/itl_xt/mapgentor.hpp>
+#include <boost/itl_xt/itvgentor.hpp>
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl/separate_interval_set.hpp>
+#include <boost/itl/split_interval_set.hpp>
+#include <boost/itl/interval_map.hpp>
+#include <boost/itl/split_interval_map.hpp>
+#include <boost/validate/gentor/gentorprofile.h>
+
+
+namespace boost{namespace itl
+{
+
+ // ----------------------------------------------------------
+ template <class ValueT> class RandomGentor;
+ template <> class RandomGentor<int> : public NumberGentorT<int> {};
+ template <> class RandomGentor<double> : public NumberGentorT<double> {};
+
+ // ----- sets ----------------------------------------------------------------
+ //template <class DomainT, template<class>class Set>
+ //class RandomGentor<Set<DomainT> > :
+ // public SetGentorT<Set<DomainT> > {};
+
+ template <class DomainT>
+ class RandomGentor<itl::set<DomainT> > :
+ public SetGentorT<itl::set<DomainT> > {};
+
+ template <class DomainT>
+ class RandomGentor<itl::interval_set<DomainT> > :
+ public SetGentorT<itl::interval_set<DomainT> > {};
+
+ template <class DomainT>
+ class RandomGentor<itl::separate_interval_set<DomainT> > :
+ public SetGentorT<itl::separate_interval_set<DomainT> > {};
+
+ template <class DomainT>
+ class RandomGentor<itl::split_interval_set<DomainT> > :
+ public SetGentorT<itl::split_interval_set<DomainT> > {};
+
+ // ----- maps -------------------------------------------------------------
+ template <class DomainT, class Neutronizer>
+ class RandomGentor<itl::map<DomainT,itl::set<int>,Neutronizer> > :
+ public MapGentorT<itl::map<DomainT,itl::set<int>,Neutronizer> > {};
+
+ template <class DomainT, class CodomainT, class Neutronizer>
+ class RandomGentor<itl::map<DomainT,CodomainT,Neutronizer> > :
+ public MapGentorT<itl::map<DomainT,CodomainT,Neutronizer> > {};
+
+
+ // ----- interval_map<D,C,N> ----------------------------------------
+ template <class DomainT, class Neutronizer>
+ class RandomGentor<interval_map<DomainT,itl::set<int>,Neutronizer> > :
+ public MapGentorT<interval_map<DomainT,itl::set<int>,Neutronizer> > {};
+
+ template <class DomainT, class CodomainT, class Neutronizer>
+ class RandomGentor<interval_map<DomainT,CodomainT,Neutronizer> > :
+ public MapGentorT<interval_map<DomainT,CodomainT,Neutronizer> > {};
+
+ // ----- split_interval_map<D,C,N> ----------------------------------------
+ template <class DomainT, class Neutronizer>
+ class RandomGentor<split_interval_map<DomainT,itl::set<int>,Neutronizer> > :
+ public MapGentorT<split_interval_map<DomainT,itl::set<int>,Neutronizer> > {};
+
+ template <class DomainT, class CodomainT, class Neutronizer>
+ class RandomGentor<split_interval_map<DomainT,CodomainT,Neutronizer> > :
+ public MapGentorT<split_interval_map<DomainT,CodomainT,Neutronizer> > {};
+
+
+ // ------------------------------------------------------------------------
+ // class template SomeValue:
+ // TargetT is a value tuple that fits to the value generator gentor
+ // of type GentorT<TargetT>. The special kind of generator can be
+ // passed by the user. The only requirement is that the generator
+ // implements a function 'some' which is called to generate a tuple
+ // of type TargetT
+ template <class TargetT, template<class>class GentorT> struct SomeValue
+ {
+ static void apply(TargetT& value, GentorT<TargetT>& gentor);
+ };
+
+ template <class TargetT>
+ struct SomeValue<TargetT, RandomGentor>
+ {
+ static void apply(TargetT& value, RandomGentor<TargetT>& gentor)
+ {
+ gentor.some(value);
+ }
+ };
+ // ------------------------------------------------------------------------
+
+
+ // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ template <class TargetT, template<class>class GentorT> struct Calibrater
+ {
+ static void apply(GentorT<TargetT>& gentor);
+ };
+
+ template <>
+ struct Calibrater<int, RandomGentor>
+ {
+ static void apply(RandomGentor<int>& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ gentor.setRange(GentorProfileSgl::it()->range_int());
+ }
+ };
+
+ template <>
+ struct Calibrater<double, RandomGentor>
+ {
+ static void apply(RandomGentor<double>& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ gentor.setRange(GentorProfileSgl::it()->range_double());
+ }
+ };
+
+
+ template <>
+ struct Calibrater<itl::set<int>, RandomGentor>
+ {
+ static void apply(RandomGentor<itl::set<int> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+ NumberGentorT<int>* intGentor = new NumberGentorT<int>;
+ intGentor->setRange(GentorProfileSgl::it()->range_int());
+ gentor.setDomainGentor(intGentor);
+ }
+ };
+
+ template <>
+ struct Calibrater<itl::set<double>, RandomGentor>
+ {
+ static void apply(RandomGentor<itl::set<double> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+ NumberGentorT<double>* elemGentor = new NumberGentorT<double>;
+ elemGentor->setRange(GentorProfileSgl::it()->range_double());
+ gentor.setDomainGentor(elemGentor);
+ }
+ };
+
+
+ template <>
+ struct Calibrater<interval_set<int>, RandomGentor>
+ {
+ static void apply(RandomGentor<interval_set<int> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+ ItvGentorT<int>* itvGentor = new ItvGentorT<int>;
+ interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ template <>
+ struct Calibrater<interval_set<double>, RandomGentor>
+ {
+ static void apply(RandomGentor<interval_set<double> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+ ItvGentorT<double>* itvGentor = new ItvGentorT<double>;
+ interval<double> valRange = GentorProfileSgl::it()->range_interval_double();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ template <>
+ struct Calibrater<separate_interval_set<int>, RandomGentor>
+ {
+ static void apply(RandomGentor<separate_interval_set<int> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+ ItvGentorT<int>* itvGentor = new ItvGentorT<int>;
+ interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ template <>
+ struct Calibrater<separate_interval_set<double>, RandomGentor>
+ {
+ static void apply(RandomGentor<separate_interval_set<double> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<double>* itvGentor = new ItvGentorT<double>;
+ interval<double> valRange = GentorProfileSgl::it()->range_interval_double();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ template <>
+ struct Calibrater<split_interval_set<int>, RandomGentor>
+ {
+ static void apply(RandomGentor<split_interval_set<int> >& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ // interval<int> range = rightOpenInterval<int>(0,10); //JODO: From SysCalibrater
+ //JODO gentor.calibrate(profile);
+
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<int>* itvGentor = new ItvGentorT<int>;
+ interval<int> valRange = GentorProfileSgl::it()->range_interval_int();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ template <>
+ struct Calibrater<split_interval_set<double>, RandomGentor>
+ {
+ static void apply(RandomGentor<split_interval_set<double> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<double>* itvGentor = new ItvGentorT<double>;
+ interval<double> valRange = GentorProfileSgl::it()->range_interval_double();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+ gentor.setDomainGentor(itvGentor);
+ }
+ };
+
+ //----------------------------------------------------------------------------
+ // itl::map<DomainT,CodomainT,Neutronizer>
+ //----------------------------------------------------------------------------
+ template <typename NumericDomainT, class Neutronizer>
+ struct Calibrater<itl::map<NumericDomainT,itl::set<int>,Neutronizer>, RandomGentor>
+ {
+ static void apply(RandomGentor<itl::map<NumericDomainT,itl::set<int>,Neutronizer> >& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ // interval<int> range = rightOpenInterval<int>(0,10); //JODO: From SysCalibrater
+ //JODO gentor.calibrate(profile);
+
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ NumberGentorT<NumericDomainT>* domainGentor = new NumberGentorT<NumericDomainT>;
+ domainGentor->setRange(GentorProfileSgl_numeric_range<NumericDomainT>::get());
+
+ SetGentorT<itl::set<int> >* codomainGentor = new SetGentorT<itl::set<int> >;
+ NumberGentorT<int>* elementGentor = new NumberGentorT<int>;
+ elementGentor->setRange(GentorProfileSgl_numeric_range<int>::get());
+
+ codomainGentor->setDomainGentor(elementGentor);
+ codomainGentor->setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ gentor.setDomainGentor(domainGentor);
+ gentor.setCodomainGentor(codomainGentor);
+ }
+ };
+
+ template <typename NumericDomainT, typename NumericCodomainT, class Neutronizer>
+ struct Calibrater<itl::map<NumericDomainT,NumericCodomainT,Neutronizer>, RandomGentor>
+ {
+ static void apply(RandomGentor<itl::map<NumericDomainT,NumericCodomainT,Neutronizer> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ NumberGentorT<NumericDomainT>* domainGentor = new NumberGentorT<NumericDomainT>;
+ NumberGentorT<NumericCodomainT>* codomainGentor = new NumberGentorT<NumericCodomainT>;
+ domainGentor->setRange(GentorProfileSgl_numeric_range<NumericDomainT>::get());
+ codomainGentor->setRange(GentorProfileSgl_numeric_range<NumericCodomainT>::get());
+ gentor.setDomainGentor(domainGentor);
+ gentor.setCodomainGentor(codomainGentor);
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ // itl::interval_map<DomainT,CodomainT,Neutronizer>
+ //----------------------------------------------------------------------------
+ template <class NumericDomainT, class Neutronizer>
+ struct Calibrater<interval_map<NumericDomainT,itl::set<int>,Neutronizer>, RandomGentor>
+ {
+ static void apply(RandomGentor<interval_map<NumericDomainT,itl::set<int>,Neutronizer> >& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ // interval<int> range = rightOpenInterval<int>(0,10); //JODO: From SysCalibrater
+ //JODO gentor.calibrate(profile);
+
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<NumericDomainT>* itvGentor = new ItvGentorT<NumericDomainT>;
+ interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+
+ SetGentorT<itl::set<int> >* codomainGentor = new SetGentorT<itl::set<int> >;
+ NumberGentorT<int>* elementGentor = new NumberGentorT<int>;
+ elementGentor->setRange(GentorProfileSgl::it()->range_int());
+
+ codomainGentor->setDomainGentor(elementGentor);
+ codomainGentor->setRangeOfSampleSize(GentorProfileSgl::it()->range_element_ContainerSize());
+
+ gentor.setDomainGentor(itvGentor);
+ gentor.setCodomainGentor(codomainGentor);
+ }
+ };
+
+ template <typename NumericDomainT, typename NumericCodomainT, class Neutronizer>
+ struct Calibrater<interval_map<NumericDomainT,NumericCodomainT,Neutronizer>, RandomGentor>
+ {
+ static void apply(RandomGentor<interval_map<NumericDomainT,NumericCodomainT,Neutronizer> >& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ // interval<int> range = rightOpenInterval<int>(0,10); //JODO: From SysCalibrater
+ //JODO gentor.calibrate(profile);
+
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<NumericDomainT>* itvGentor = new ItvGentorT<NumericDomainT>;
+ interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+
+ NumberGentorT<NumericCodomainT>* codomainGentor = new NumberGentorT<NumericCodomainT>;
+ codomainGentor->setRange(GentorProfileSgl_numeric_range<NumericCodomainT>::get());
+
+ gentor.setDomainGentor(itvGentor);
+ gentor.setCodomainGentor(codomainGentor);
+ }
+ };
+
+ //----------------------------------------------------------------------------
+ // itl::split_interval_map<DomainT,CodomainT,Neutronizer>
+ //----------------------------------------------------------------------------
+ template <class NumericDomainT, class Neutronizer>
+ struct Calibrater<split_interval_map<NumericDomainT,itl::set<int>,Neutronizer>, RandomGentor>
+ {
+ static void apply(RandomGentor<split_interval_map<NumericDomainT,itl::set<int>,Neutronizer> >& gentor)
+ {
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<NumericDomainT>* itvGentor = new ItvGentorT<NumericDomainT>;
+ interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength());
+
+ SetGentorT<itl::set<int> >* codomainGentor = new SetGentorT<itl::set<int> >;
+ NumberGentorT<int>* elementGentor = new NumberGentorT<int>;
+ elementGentor->setRange(GentorProfileSgl::it()->range_int());
+
+ codomainGentor->setDomainGentor(elementGentor);
+ codomainGentor->setRangeOfSampleSize(GentorProfileSgl::it()->range_element_ContainerSize());
+
+ gentor.setDomainGentor(itvGentor);
+ gentor.setCodomainGentor(codomainGentor);
+ }
+ };
+
+ template <typename NumericDomainT, typename NumericCodomainT, class Neutronizer>
+ struct Calibrater<split_interval_map<NumericDomainT,NumericCodomainT,Neutronizer>, RandomGentor>
+ {
+ static void apply(RandomGentor<split_interval_map<NumericDomainT,NumericCodomainT,Neutronizer> >& gentor)
+ {
+ // Set the range within which the sizes of the generated object varies.
+ // interval<int> range = rightOpenInterval<int>(0,10); //JODO: From SysCalibrater
+ //JODO gentor.calibrate(profile);
+
+ gentor.setRangeOfSampleSize(GentorProfileSgl::it()->range_ContainerSize());
+
+ // If it is a container: (Create and) Pass the generator(s) for their contents
+ // NumberGentorT<int> intGentor;
+ ItvGentorT<NumericDomainT>* itvGentor = new ItvGentorT<NumericDomainT>;
+ interval<NumericDomainT> valRange = GentorProfileSgl_numeric_range<NumericDomainT>::get();
+ itvGentor->setValueRange(valRange.lower(), valRange.upper());
+ itvGentor->setMaxIntervalLength(GentorProfileSgl::it()->maxIntervalLength()); //JODO
+
+ NumberGentorT<NumericCodomainT>* codomainGentor = new NumberGentorT<NumericCodomainT>;
+ codomainGentor->setRange(GentorProfileSgl_numeric_range<NumericCodomainT>::get());
+
+ gentor.setDomainGentor(itvGentor);
+ gentor.setCodomainGentor(codomainGentor);
+ }
+ };
+ // ---------------------------------------------------------------------------
+
+}} // namespace itl boost
Added: sandbox/itl/boost/validate/gentor/rangegentor.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/gentor/rangegentor.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,84 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+/* ------------------------------------------------------------------
+class IntevalGentor
+ A random generator for Sets.
+--------------------------------------------------------------------*/
+#pragma once
+
+#include <boost/itl/interval.hpp>
+#include <boost/itl_xt/gentorit.hpp>
+
+namespace boost{namespace itl
+{
+ //JODO: RangeGentor is similat to ItvGentorT. RangeGentor might be replaced by ItvGentorT
+ // with some modifications applied to ItvGentorT.
+
+ template <class Type>
+ class RangeGentor: public RandomGentorAT<interval<Type> >
+ {
+ public:
+ virtual void some(interval<Type>& x);
+ interval<Type> last()const;
+
+ void setLowerBoundRange(int lwb, int upb)
+ { setLowerBoundRange(rightopen_interval(lwb,upb)); }
+ void setLowerBoundRange(const interval<int>& range)
+ { BOOST_ASSERT(range.is_rightopen()||range.is_closed()); _lwbGentor.setRange(range); }
+
+ void setUpperBoundRange(int lwb, int upb)
+ { setUpperBoundRange(rightopen_interval(lwb,upb)); }
+ void setUpperBoundRange(const interval<int>& range)
+ { BOOST_ASSERT(range.is_rightopen()||range.is_closed()); _upbGentor.setRange(range); }
+
+ private:
+ NumberGentorT<Type> _lwbGentor;
+ NumberGentorT<Type> _upbGentor;
+ interval<Type> _last;
+ };
+
+ template <class Type>
+ void RangeGentor<Type>::some(interval<Type>& x)
+ {
+ Type lwb, upb;
+ _lwbGentor.some(lwb);
+ _upbGentor.some(upb);
+ _last = rightopen_interval(lwb, upb);
+ x = _last;
+ }
+
+ template <class Type>
+ interval<Type> RangeGentor<Type>::last()const
+ {
+ return _last;
+ }
+
+}} // namespace itl boost
+
+
+
Added: sandbox/itl/boost/validate/law.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/law.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,102 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_Law_h_JOFA_070411__
+#define __itl_Law_h_JOFA_070411__
+
+#include <string>
+#include <set>
+#include <boost/validate/loki_xt/Tuple.h>
+
+namespace boost{namespace itl
+{
+
+ /** abstract template class Law:
+ A Law can hold for a given set of variables.
+ A Law together with the set of input variables is an instance of the law.
+ The evaluation of the law results in a set of output variables.
+ Output variables hold interim and final results of the evaluation of the law.
+ */
+ template
+ <
+ class SubType,
+ typename InputTypes, typename OutputTypes
+ >
+ class Law
+ {
+ public:
+ typedef SubType sub_type;
+ typedef InputTypes input_types;
+ typedef OutputTypes output_types;
+ typedef typename Loki::tuple<InputTypes> input_tuple;
+ typedef typename Loki::tuple<OutputTypes> output_tuple;
+
+ public:
+ bool holds(){ return that()->holds(); }
+ bool debug_holds(){ return that()->debug_holds(); }
+
+ void setInstance(const input_tuple& inVars)
+ { _inputTuple = inVars; }
+
+ void getInstance(input_tuple& inVars, output_tuple& outVars)const
+ { inVars = _inputTuple; outVars = _outputTuple; }
+
+ void getInputInstance(input_tuple& inVars)const
+ { inVars = _inputTuple; }
+
+ void getOutputInstance(output_tuple& outVars)const
+ { outVars = _outputTuple; }
+
+ size_t size()const{ return that()->size(); }
+
+ bool operator == (const Law& rhs)const
+ { return size() == rhs.size(); }
+
+ bool operator < (const Law& rhs)const
+ { return size() < rhs.size(); }
+
+ std::string name()const { return that()->name(); }
+ std::string formula()const { return that()->formula(); }
+ std::string typeString()const { return that()->typeString(); }
+
+ template<unsigned int index>
+ typename Loki::TL::TypeAt<InputTypes, index>::Result
+ setInputValue(const typename Loki::TL::TypeAt<InputTypes, index>::Result& value)
+ { return Loki::tup::refer<index>(_inputTuple)=value; }
+
+ template<unsigned int index>
+ typename Loki::TL::TypeAt<InputTypes, index>::Result getInputValue()const
+ { return Loki::tup::get<index>(_inputTuple); }
+
+ template<unsigned int index>
+ typename Loki::TL::TypeAt<OutputTypes, index>::Result
+ setOutputValue(const typename Loki::TL::TypeAt<OutputTypes, index>::Result& value)
+ { return Loki::tup::refer<index>(_outputTuple)=value; }
+
+ template<unsigned int index>
+ typename Loki::TL::TypeAt<OutputTypes, index>::Result getOutputValue()const
+ { return Loki::tup::get<index>(_outputTuple); }
+
+ protected:
+ sub_type* that() { return static_cast <sub_type*>(this); }
+ const sub_type* that()const { return static_cast<const sub_type*>(this); }
+
+ private:
+ input_tuple _inputTuple;
+ output_tuple _outputTuple;
+ };
+
+
+ enum InputVarIndex { operand_a, operand_b, operand_c, operand_d, operand_e };
+ enum OutputVarIndex { lhs_result, rhs_result };
+
+}} // namespace itl boost
+
+#endif //__itl_Law_h_JOFA_070411__
+
Added: sandbox/itl/boost/validate/laws/monoid.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/laws/monoid.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,381 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_monoid_h_JOFA_070411__
+#define __itl_monoid_h_JOFA_070411__
+
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/itl/functors.hpp>
+#include <boost/validate/law.h>
+
+namespace boost{namespace itl
+{
+
+ /* Monoid: (M,+,0) with .+.: M x M -> M has these axioms
+ (1) Associativity
+ (2) Neutral element
+ A commutative monoid or abelian monoid has also
+ (3) Commutativity
+ */
+
+ template <typename Type>
+ class AdditionNeutrality
+ : public Law<AdditionNeutrality<Type>, LOKI_TYPELIST_1(Type), LOKI_TYPELIST_1(Type)>
+ {
+ public:
+ std::string name()const { return "Addition Neutrality"; }
+ std::string formula()const { return "a + 0 == 0"; }
+
+ std::string typeString()const
+ {
+ return "Neutrality<"+type_to_string<Type>::apply()+",+,0>";
+ }
+
+ public:
+ bool holds()
+ {
+ Type inVal = this->template getInputValue<0>();
+ Type outVal = inVal + Type();
+ this->template setOutputValue<0>(outVal);
+ return inVal == outVal;
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const;
+
+ void setValue(const Type& inVal) { this->template setInputValue<0>(inVal); }
+ Type getResult()const { return this->template getOutputValue<0>(); }
+ };
+
+ template <> size_t AdditionNeutrality<int>::size()const
+ { return getInputValue<0>(); }
+
+ template <class Type> size_t AdditionNeutrality<Type>::size()const
+ { return this->template getInputValue<0>().size(); };
+
+ template <typename Type>
+ class AdditionCommutativity
+ : public Law<AdditionCommutativity<Type>, LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** a + b == b + a
+ Input = (a := inVal1, b := inVal2)
+ Output = (sum_lhs, sum_rhs)
+ */
+ public:
+ std::string name()const { return "Addition Commutativity"; }
+ std::string formula()const { return "a + b == b + a"; }
+
+ std::string typeString()const
+ {
+ return "Commutativity<"+type_to_string<Type>::apply()+",+>";
+ }
+
+ public:
+ enum InputVarIndex { operand_a, operand_b };
+ enum OutputVarIndex { lhs_sum, rhs_sum };
+
+ void setOperand_a(const Type& inVal) { this->template setInputValue<operand_a>(inVal); }
+ void setOperand_b(const Type& inVal) { this->template setInputValue<operand_b>(inVal); }
+ void setOperands(const Type& inVal_a, const Type& inVal_b)
+ { this->template setInputValue<operand_b>(inVal_a); this->template setInputValue<operand_b>(inVal_b); }
+
+ Type getLhsSum()const { return this->template getOutputValue<lhs_sum>(); }
+ Type getRhsSum()const { return this->template getOutputValue<rhs_sum>(); }
+
+ bool holds()
+ {
+ this->template setOutputValue<lhs_sum>(this->template getInputValue<operand_a>() + this->template getInputValue<operand_b>());
+ this->template setOutputValue<rhs_sum>(this->template getInputValue<operand_b>() + this->template getInputValue<operand_a>());
+ return this->template getOutputValue<lhs_sum>() == this->template getOutputValue<rhs_sum>();
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>());
+ }
+ };
+
+
+ template <typename TypeA, typename TypeB>
+ class MixedAdditionCommutativity
+ : public Law<MixedAdditionCommutativity<TypeA, TypeB>,
+ LOKI_TYPELIST_2(TypeA,TypeB), LOKI_TYPELIST_2(TypeB,TypeB)>
+ {
+ /** a + b == b + a
+ Input = (a := inVal1, b := inVal2)
+ Output = (sum_lhs, sum_rhs)
+ */
+ public:
+ std::string name()const { return "Mixed Addition Commutativity"; }
+ std::string formula()const { return "a + b == b + a for A a; B b; +: A x B -> B"; }
+
+ std::string typeString()const
+ {
+ return "Commutativity<"+type_to_string<TypeA>::apply()+","
+ +type_to_string<TypeB>::apply()+",+>";
+ }
+
+ public:
+ enum InputVarIndex { operand_a, operand_b };
+ enum OutputVarIndex { lhs_sum, rhs_sum };
+
+ void setOperand_a(const TypeA& inVal) { this->template setInputValue<operand_a>(inVal); }
+ void setOperand_b(const TypeB& inVal) { this->template setInputValue<operand_b>(inVal); }
+ void setOperands(const TypeA& inVal_a, const TypeB& inVal_b)
+ { this->template setInputValue<operand_b>(inVal_a); this->template setInputValue<operand_b>(inVal_b); }
+
+ TypeB getLhsSum()const { return this->template getOutputValue<lhs_sum>(); }
+ TypeB getRhsSum()const { return this->template getOutputValue<rhs_sum>(); }
+
+ bool holds()
+ {
+ this->template setOutputValue<lhs_sum>(this->template getInputValue<operand_a>() + this->template getInputValue<operand_b>());
+ this->template setOutputValue<rhs_sum>(this->template getInputValue<operand_b>() + this->template getInputValue<operand_a>());
+ return this->template getOutputValue<lhs_sum>() == this->template getOutputValue<rhs_sum>();
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return value_size<TypeA>::get(this->template getInputValue<operand_a>())+
+ value_size<TypeB>::get(this->template getInputValue<operand_b>());
+ }
+
+ };
+
+
+ // ---------------------------------------------------------------------------
+ // Inplace variant of laws for operator o=
+ // ---------------------------------------------------------------------------
+ //JODO MEMO USENET: Kein Patternmatching auf templateparameter-level! Beispiel
+ // TypeAsString!
+ //template <typename Type, template<class>class Accumulator = inplace_plus, int aux=0>
+ template <typename Type, template<class>class Accumulator = inplace_plus, template<class>class NeutronT = neutron>
+ class InplaceNeutrality
+ : public Law<InplaceNeutrality<Type,Accumulator,NeutronT>,
+ LOKI_TYPELIST_1(Type), LOKI_TYPELIST_1(Type)>
+ {
+ /** a o 0 == a computed as
+ l=a; l o= 0; => l==a
+ Input = (a := inVal1)
+ Output = (lhs_result)
+ */
+ public:
+ std::string name()const { return "Inplace Op Neutrality"; }
+ std::string formula()const { return "a o 0 == a 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "Neutrality<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Accumulator>::apply()+","
+ +unary_template_to_string<NeutronT>::apply()+">";
+ }
+
+ public:
+
+ enum InputVarIndex { operand_a, operand_b };
+ enum OutputVarIndex { lhs_result, rhs_result };
+
+ void setOperand_a(const Type& inVal) { this->template setInputValue<operand_a>(inVal); }
+
+ Type getLhsResult()const { return this->template getOutputValue<lhs_result>(); }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>());
+ }
+
+ bool holds()
+ {
+ Type lhs = this->template getInputValue<operand_a>();
+ Accumulator<Type>()(lhs, neutron<Type>()());
+ this->template setOutputValue<lhs_result>(lhs);
+ return lhs == this->template getInputValue<operand_a>();
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ };
+
+
+ template <typename Type,
+ template<class>class Accumulator = inplace_plus,
+ template<class>class Equality = itl::std_equal>
+ class InplaceAssociativity
+ : public Law<InplaceAssociativity<Type,Accumulator>,
+ LOKI_TYPELIST_3(Type,Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** (a o b) o c == a o (b o c) 'inplace'
+ Input = (a := inVal1, b := inVal2, c := inVal3)
+ Output = (sum_lhs, sum_rhs)
+ */
+ public:
+ std::string name()const { return "Inplace Associativity"; }
+ std::string formula()const { return "(a o b) o c == a o (b o c) 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "Associativity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Accumulator>::apply()+">";
+ }
+
+ public:
+
+ enum InputVarIndex { operand_a, operand_b, operand_c };
+ enum OutputVarIndex { lhs_sum, rhs_sum };
+
+ void setOperand_a(const Type& inVal) { this->template setInputValue<operand_a>(inVal); }
+ void setOperand_b(const Type& inVal) { this->template setInputValue<operand_b>(inVal); }
+ void setOperand_c(const Type& inVal) { this->template setInputValue<operand_c>(inVal); }
+ void setOperands(const Type& inVal_a, const Type& inVal_b, const Type& inVal_c)
+ { this->template setInputValue<operand_b>(inVal_a); this->template setInputValue<operand_b>(inVal_b); this->template setInputValue<operand_b>(inVal_c); }
+
+ Type getLhsSum()const { return this->template getOutputValue<lhs_sum>(); }
+ Type getRhsSum()const { return this->template getOutputValue<rhs_sum>(); }
+
+ size_t size()const
+ {
+ return
+ value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>());
+ }
+
+ bool holds()
+ {
+ Type lsum = this->template getInputValue<operand_a>();
+ Accumulator<Type>()(lsum, this->template getInputValue<operand_b>());
+ Accumulator<Type>()(lsum, this->template getInputValue<operand_c>());
+
+ Type rsum = this->template getInputValue<operand_a>();
+ Type b_plus_c = this->template getInputValue<operand_b>();
+ Accumulator<Type>()(b_plus_c, this->template getInputValue<operand_c>());
+ Accumulator<Type>()(rsum, b_plus_c);
+
+ this->template setOutputValue<lhs_sum>(lsum);
+ this->template setOutputValue<rhs_sum>(rsum);
+
+ return Equality<Type>()(lsum, rsum);
+ }
+
+ bool debug_holds()
+ {
+ std::cout << typeString() << std::endl;
+ std::cout << formula() << std::endl;
+ std::cout << "a: " << this->template getInputValue<operand_a>().as_string() << std::endl;
+ std::cout << "b: " << this->template getInputValue<operand_b>().as_string() << std::endl;
+ std::cout << "c: " << this->template getInputValue<operand_c>().as_string() << std::endl;
+
+ Type lsum = this->template getInputValue<operand_a>();
+ Accumulator<Type>()(lsum, this->template getInputValue<operand_b>());
+ std::cout << "a o b: " << lsum.as_string() << std::endl;
+
+ Accumulator<Type>()(lsum, this->template getInputValue<operand_c>());
+ std::cout << "(a o b) o c: " << lsum.as_string() << std::endl;
+
+ Type rsum = this->template getInputValue<operand_a>();
+ Type b_plus_c = this->template getInputValue<operand_b>();
+ Accumulator<Type>()(b_plus_c, this->template getInputValue<operand_c>());
+ std::cout << "b o c: " << b_plus_c.as_string() << std::endl;
+ Accumulator<Type>()(rsum, b_plus_c);
+ std::cout << "a o (b o c): " << rsum.as_string() << std::endl;
+
+ this->template setOutputValue<lhs_sum>(lsum);
+ this->template setOutputValue<rhs_sum>(rsum);
+
+ return Equality<Type>()(lsum, rsum);
+ }
+
+ };
+
+
+ template <typename Type, template<class>class Accumulator = inplace_plus>
+ class InplaceCommutativity
+ : public Law<InplaceCommutativity<Type,Accumulator>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** a o b == b o a computed as
+ lsum=a; lsum+=b; rsum=b; rsum+=a => lsum==rsum
+ Input = (a := inVal1, b := inVal2)
+ Output = (sum_lhs, sum_rhs)
+ */
+ public:
+ std::string name()const { return "Inplace Commutativity"; }
+ std::string formula()const { return "a o b == b o a 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "Commutativity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Accumulator>::apply()+">";
+ }
+
+ public:
+
+ enum InputVarIndex { operand_a, operand_b };
+ enum OutputVarIndex { lhs_sum, rhs_sum };
+
+ void setOperand_a(const Type& inVal) { this->template setInputValue<operand_a>(inVal); }
+ void setOperand_b(const Type& inVal) { this->template setInputValue<operand_b>(inVal); }
+ void setOperands(const Type& inVal_a, const Type& inVal_b)
+ { this->template setInputValue<operand_b>(inVal_a); this->template setInputValue<operand_b>(inVal_b); }
+
+ Type getLhsSum()const { return this->template getOutputValue<lhs_sum>(); }
+ Type getRhsSum()const { return this->template getOutputValue<rhs_sum>(); }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>());
+ }
+
+ bool holds()
+ {
+ Type lsum = this->template getInputValue<operand_a>();
+ lsum += this->template getInputValue<operand_b>();
+ Type rsum = this->template getInputValue<operand_b>();
+ rsum += this->template getInputValue<operand_a>();
+
+ this->template setOutputValue<lhs_sum>(lsum);
+ this->template setOutputValue<rhs_sum>(rsum);
+
+ return lsum == rsum;
+ }
+
+ bool debug_holds()
+ {
+ std::cout << typeString() << std::endl;
+ std::cout << formula() << std::endl;
+ std::cout << "a: " << this->template getInputValue<operand_a>().as_string() << std::endl;
+ std::cout << "b: " << this->template getInputValue<operand_b>().as_string() << std::endl;
+
+ Type lsum = this->template getInputValue<operand_a>();
+ lsum += this->template getInputValue<operand_b>();
+ std::cout << "a o b: " << lsum.as_string() << std::endl;
+
+ Type rsum = this->template getInputValue<operand_b>();
+ rsum += this->template getInputValue<operand_a>();
+ std::cout << "b o a: " << rsum.as_string() << std::endl;
+
+ this->template setOutputValue<lhs_sum>(lsum);
+ this->template setOutputValue<rhs_sum>(rsum);
+
+ return lsum == rsum;
+ }
+
+ };
+
+}} // namespace itl boost
+
+#endif // __itl_monoid_h_JOFA_070411__
+
Added: sandbox/itl/boost/validate/laws/order.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/laws/order.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,209 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_order_h_JOFA_071129__
+#define __itl_order_h_JOFA_071129__
+
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/validate/law.h>
+
+namespace boost{namespace itl
+{
+
+ /* Orders (Orderings): .<. : M x M -> bool */
+
+
+ template <typename Type, template<class>class Relation>
+ class Reflexivity
+ : public Law<Reflexivity<Type,Relation>,
+ LOKI_TYPELIST_1(Type), Loki::NullType>
+ {
+ public:
+ std::string name()const { return "Reflexivity"; }
+ std::string formula()const { return "a <= a"; }
+
+ std::string typeString()const
+ {
+ return "Reflexivity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Relation>::apply()+">";
+ }
+
+ public:
+ bool holds()
+ {
+ Type a = this->template getInputValue<operand_a>();
+ return Relation<Type>()(a,a);
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
+ };
+
+ template<>
+ std::string unary_template_to_string<std::less_equal>::apply() { return "<="; }
+ template<>
+ std::string unary_template_to_string<std::less>::apply() { return "<"; }
+ template<>
+ std::string unary_template_to_string<itl::contained_in>::apply(){ return "C="; }
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Relation>
+ class Irreflexivity
+ : public Law<Irreflexivity<Type,Relation>,
+ LOKI_TYPELIST_1(Type), Loki::NullType>
+ {
+ public:
+ std::string name()const { return "Irreflexivity"; }
+ std::string formula()const { return "!(a < a)"; }
+
+ std::string typeString()const
+ {
+ return "Irreflexivity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Relation>::apply()+">";
+ }
+
+ public:
+ bool holds()
+ {
+ Type a = this->template getInputValue<operand_a>();
+ return !Relation<Type>()(a,a);
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Relation>
+ class Antisymmetry
+ : public Law<Antisymmetry<Type,Relation>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_1(Type)>
+ {
+ /** a <= b && b <= a => a == b
+ Input = (a := inVal1, b := inVal2)
+ Output = ()
+ */
+ public:
+ std::string name()const { return "Antisymmetry"; }
+ std::string formula()const { return "(a <= b && b <= a) => a == b"; }
+
+ std::string typeString()const
+ {
+ return "Antisymmetry<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Relation>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ Type a = this->template getInputValue<operand_a>();
+ Type b = this->template getInputValue<operand_a>();
+
+ return !(Relation<Type>()(a,b) && Relation<Type>()(b,a)) || a == b;
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>());
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Relation>
+ class Antisymmetry2
+ : public Law<Antisymmetry2<Type,Relation>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_1(Type)>
+ {
+ /** a < b => !(b < a)
+ Input = (a := inVal1, b := inVal2)
+ Output = ()
+ */
+ public:
+ std::string name()const { return "Antisymmetry2"; }
+ std::string formula()const { return " a < b => !(b < a)"; }
+
+ std::string typeString()const
+ {
+ return "Antisymmetry2<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Relation>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ Type a = this->template getInputValue<operand_a>();
+ Type b = this->template getInputValue<operand_a>();
+
+ return !(Relation<Type>()(a,b) && Relation<Type>()(b,a));
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>());
+ }
+ };
+
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Relation>
+ class Transitivity
+ : public Law<Transitivity<Type,Relation>,
+ LOKI_TYPELIST_3(Type,Type,Type), Loki::NullType>
+ {
+ /** a < b && b < c => a < c
+ Input = (a := inVal1, b := inVal2, c := inVal3)
+ Output = ()
+ */
+ public:
+ std::string name()const { return "Transitivity"; }
+ std::string formula()const { return "a < b && b < c => a < c"; }
+
+ std::string typeString()const
+ {
+ return "Transitivity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Relation>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ Type a = this->template getInputValue<operand_a>();
+ Type b = this->template getInputValue<operand_a>();
+ Type c = this->template getInputValue<operand_c>();
+
+ return !(Relation<Type>()(a,b) && Relation<Type>()(b,c)) || Relation<Type>()(a,c);
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>())+
+ value_size<Type>::apply(this->template getInputValue<operand_c>());
+ }
+ };
+
+}} // namespace itl boost
+
+#endif // __itl_order_h_JOFA_071129__
+
Added: sandbox/itl/boost/validate/laws/pushouts.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/laws/pushouts.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,130 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_pushouts_h_JOFA_071124__
+#define __itl_pushouts_h_JOFA_071124__
+
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/validate/law.h>
+
+namespace boost{namespace itl
+{
+
+ // ---------------------------------------------------------------------------
+ // (a,b) ---o---> c
+ // | |
+ // |f |f
+ // V V
+ // (a',b')---o---> c'
+ // ---------------------------------------------------------------------------
+ template <typename SourceT, typename TargetT,
+ template<class,class>class FunctionT, // morphic function f
+ template<typename>class OperatorT> // operator like +=
+ class BinaryPushout :
+ public Law<BinaryPushout<SourceT,TargetT,FunctionT,OperatorT>,
+ LOKI_TYPELIST_2(SourceT, SourceT), LOKI_TYPELIST_2(TargetT,TargetT)>
+ {
+ /** f(a o b) == f(a) o f(b)
+ computed using inplace operators o=
+ Input = (a := inVal1, b := inVal2)
+ Output = (lhs_result, rhs_result)
+ */
+ public:
+ std::string name()const { return "Pushout"; }
+ std::string formula()const { return "cont a, cont b: f(a o b) == f(a) o f(b) 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return
+ "Pushout<"+type_to_string<SourceT>::apply()+","
+ +type_to_string<TargetT>::apply()+","
+ +binary_template_to_string<FunctionT>::apply()+","
+ +unary_template_to_string<OperatorT>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // f(a o b) == f(a) o f(b)
+ // --- left hand side ------------------------
+ // lhs := f(a o b)
+ SourceT a_o_b = this->template getInputValue<operand_a>();
+ // a_o_b *= this->template getInputValue<operand_b>();
+ OperatorT<SourceT>()(a_o_b, this->template getInputValue<operand_b>());
+
+ TargetT lhs;
+ FunctionT<TargetT,SourceT>()(lhs, a_o_b);
+
+ // --- right hand side -----------------------
+ // rhs := atomize(a) * atomize(b)
+ TargetT atomic_a;
+ FunctionT<TargetT,SourceT>()(atomic_a, this->template getInputValue<operand_a>());
+ TargetT atomic_b;
+ FunctionT<TargetT,SourceT>()(atomic_b, this->template getInputValue<operand_b>());
+ TargetT rhs = atomic_a;
+ OperatorT<TargetT>()(rhs, atomic_b);
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return lhs == rhs;
+ }
+
+ size_t size()const
+ {
+ return
+ value_size<SourceT>::apply(this->template getInputValue<operand_a>())+
+ value_size<SourceT>::apply(this->template getInputValue<operand_b>());
+ }
+
+ bool debug_holds()
+ {
+ std::cout << typeString() << std::endl;
+ std::cout << formula() << std::endl;
+ std::cout << "a: " << this->template getInputValue<operand_a>().as_string() << std::endl;
+ std::cout << "b: " << this->template getInputValue<operand_b>().as_string() << std::endl;
+
+ // f(a o b) == f(a) o f(b)
+ // --- left hand side ------------------------
+ // lhs := f(a o b)
+ SourceT a_o_b = this->template getInputValue<operand_a>();
+ // a_o_b o= this->template getInputValue<operand_b>();
+ OperatorT<SourceT>()(a_o_b, this->template getInputValue<operand_b>());
+ std::cout << "a o b:" << a_o_b.as_string() << std::endl;
+
+ TargetT lhs;
+ FunctionT<TargetT,SourceT>()(lhs, a_o_b);
+ std::cout << "f(a o b):" << lhs.as_string() << std::endl;
+
+ // --- right hand side -----------------------
+ // rhs := atomize(a) * atomize(b)
+ TargetT atomic_a;
+ FunctionT<TargetT,SourceT>()(atomic_a, this->template getInputValue<operand_a>());
+ std::cout << "f(a):" << atomic_a.as_string() << std::endl;
+ TargetT atomic_b;
+ FunctionT<TargetT,SourceT>()(atomic_b, this->template getInputValue<operand_b>());
+ std::cout << "f(b):" << atomic_b.as_string() << std::endl;
+ TargetT rhs = atomic_a;
+ OperatorT<TargetT>()(rhs, atomic_b);
+ std::cout << "f(a) o f(b):" << rhs.as_string() << std::endl;
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return lhs == rhs;
+ }
+
+ }; //class BinaryPushout
+
+
+}} // namespace itl boost
+
+#endif // __itl_pushouts_h_JOFA_071124__
+
Added: sandbox/itl/boost/validate/laws/set_laws.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/laws/set_laws.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,475 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_set_laws_h_JOFA_071124__
+#define __itl_set_laws_h_JOFA_071124__
+
+#include <boost/itl/type_traits/value_size.hpp>
+#include <boost/validate/law.h>
+#include <boost/itl/functors.hpp>
+
+namespace boost{namespace itl
+{
+
+ template <typename Type, template<class>class Equality = itl::std_equal>
+ class InplaceUnionInvertability
+ : public Law<InplaceUnionInvertability<Type>,
+ LOKI_TYPELIST_1(Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** a - a == 0
+ computed using inplace operators +=
+ Input = (a := inVal1, b := inVal2)
+ Output = (lhs_result, rhs_result)
+ */
+
+ public:
+ std::string name()const { return "InplaceUnionInvertability"; }
+ std::string formula()const { return "a -= a; a == 0"; }
+
+ std::string typeString()const
+ {
+ return "UnionInvertability<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Equality>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ Type lhs = this->template getInputValue<operand_a>();
+ lhs -= this->template getInputValue<operand_a>();
+
+ Type rhs = Type();
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const { return value_size<Type>::apply(this->template getInputValue<operand_a>()); }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Operator1 = inplace_plus,
+ template<class>class Operator2 = inplace_star,
+ template<class>class Equality = itl::std_equal>
+ class InplaceDistributivity
+ : public Law<InplaceDistributivity<Type,Operator1,Operator2,Equality>,
+ LOKI_TYPELIST_3(Type,Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** a + (b * c) == (a + b) * (a + c)
+ computed using inplace operators +=, += and *=
+ Input = (a := inVal1, b := inVal2, c := inVal3)
+ Output = (lhs_result, rhs_result)
+ */
+ public:
+ std::string name()const { return "InplaceDistributivity"; }
+ std::string formula()const { return "a + (b * c) == (a + b) * (a + c) 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "Distributivity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Operator1>::apply()+","
+ +unary_template_to_string<Operator2>::apply()+","
+ +unary_template_to_string<Equality>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // a + (b * c) == (a + b) * (a + c)
+ // --- left hand side ------------------------
+ Type b_star_c = this->template getInputValue<operand_b>();
+ Operator2<Type>()(b_star_c, this->template getInputValue<operand_c>());
+
+ // lhs := a + (b * c)
+ Type lhs = this->template getInputValue<operand_a>();
+ Operator1<Type>()(lhs, b_star_c);
+
+ // --- right hand side -----------------------
+ Type a_plus_b = this->template getInputValue<operand_a>();
+ Operator1<Type>()(a_plus_b, this->template getInputValue<operand_b>());
+
+ Type a_plus_c = this->template getInputValue<operand_a>();
+ Operator1<Type>()(a_plus_c, this->template getInputValue<operand_c>());
+
+ // rhs := (a + b) * (a + c)
+ Type rhs = a_plus_b;
+ Operator2<Type>()(rhs, a_plus_c);
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+
+ bool debug_holds()
+ {
+ // a + (b * c) == (a + b) * (a + c)
+ std::cout << "a:" << this->template getInputValue<operand_a>().as_string() << std::endl;
+ std::cout << "b:" << this->template getInputValue<operand_b>().as_string() << std::endl;
+ std::cout << "c:" << this->template getInputValue<operand_c>().as_string() << std::endl;
+ // --- left hand side ------------------------
+ Type b_star_c = this->template getInputValue<operand_b>();
+ Operator2<Type>()(b_star_c, this->template getInputValue<operand_c>());
+ std::cout << "b*c:" << b_star_c.as_string() << std::endl;
+
+ // lhs := a + (b * c)
+ Type lhs = this->template getInputValue<operand_a>();
+ Operator1<Type>()(lhs, b_star_c);
+ std::cout << "l=a+(b*c):" << lhs.as_string() << std::endl;
+
+ // --- right hand side -----------------------
+ Type a_plus_b = this->template getInputValue<operand_a>();
+ Operator1<Type>()(a_plus_b, this->template getInputValue<operand_b>());
+ std::cout << "a+b:" << a_plus_b.as_string() << std::endl;
+
+ Type a_plus_c = this->template getInputValue<operand_a>();
+ Operator1<Type>()(a_plus_c, this->template getInputValue<operand_c>());
+ std::cout << "a+c:" << a_plus_c.as_string() << std::endl;
+
+ // rhs := (a + b) * (a + c)
+ Type rhs = a_plus_b;
+ Operator2<Type>()(rhs, a_plus_c);
+ std::cout << "r=(a+b)*(a+c):" << rhs.as_string() << std::endl;
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return lhs == rhs;
+ }
+
+ size_t size()const
+ {
+ return value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>())+
+ value_size<Type>::apply(this->template getInputValue<operand_c>());
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Operator1 = inplace_plus,
+ template<class>class Operator2 = inplace_star,
+ template<class>class Equality = itl::std_equal>
+ class InplaceDeMorgan
+ : public Law<InplaceDeMorgan<Type,Operator1,Operator2,Equality>,
+ LOKI_TYPELIST_3(Type,Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** a - (b + c) == (a - b) * (a - c)
+ computed using inplace operators +=, += and *=
+ Input = (a := inVal1, b := inVal2, c := inVal3)
+ Output = (lhs_result, rhs_result)
+ */
+ public:
+ std::string name()const { return "InplacePlusDeMorgan"; }
+ std::string formula()const { return "a - (b + c) == (a - b) * (a - c) 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "DeMorgan<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Operator1>::apply()+","
+ +unary_template_to_string<Operator2>::apply()+","
+ +unary_template_to_string<Equality>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // a - (b + c) == (a - b) * (a - c)
+ // --- left hand side ------------------------
+ Type b_plus_c = this->template getInputValue<operand_b>();
+ Operator1<Type>()(b_plus_c, this->template getInputValue<operand_c>());
+
+ // lhs := a - (b + c)
+ Type lhs = this->template getInputValue<operand_a>();
+ lhs -= b_plus_c;
+
+ // --- right hand side -----------------------
+ Type a_minus_b = this->template getInputValue<operand_a>();
+ a_minus_b -= this->template getInputValue<operand_b>();
+
+ Type a_minus_c = this->template getInputValue<operand_a>();
+ a_minus_c -= this->template getInputValue<operand_c>();
+
+ // rhs := (a - b) * (a - c)
+ Type rhs = a_minus_b;
+ Operator2<Type>()(rhs, a_minus_c);
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return
+ value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>())+
+ value_size<Type>::apply(this->template getInputValue<operand_c>());
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename Type,
+ template<class>class Operator1 = inplace_plus,
+ template<class>class Operator2 = inplace_minus>
+ class InplaceRightDistributivity
+ : public Law<InplaceRightDistributivity<Type,Operator1,Operator2>,
+ LOKI_TYPELIST_3(Type,Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** (a + b) - c == (a - c) + (b - c)
+ computed using inplace operators +=, += and *=
+ Input = (a := inVal1, b := inVal2, c := inVal3)
+ Output = (lhs_result, rhs_result)
+ */
+ public:
+ std::string name()const { return "InplaceRightDistributivity"; }
+ std::string formula()const { return "(a + b) - c == (a - c) + (b - c) 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "RightDistributivity<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Operator1>::apply()+","
+ +unary_template_to_string<Operator2>::apply()+">";
+ }
+
+ public:
+
+ size_t size()const
+ {
+ return
+ value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>())+
+ value_size<Type>::apply(this->template getInputValue<operand_c>());
+ }
+
+ bool holds()
+ {
+ // (a + b) - c == (a - c) + (b - c)
+ // --- left hand side ------------------------
+ // lhs := (a + b) - c
+ Type lhs = this->template getInputValue<operand_a>();
+ Operator1<Type>()(lhs, this->template getInputValue<operand_b>());
+ Operator2<Type>()(lhs, this->template getInputValue<operand_c>());
+
+ // --- right hand side -----------------------
+ Type a_minus_c = this->template getInputValue<operand_a>();
+ Operator2<Type>()(a_minus_c, this->template getInputValue<operand_c>());
+
+ Type b_minus_c = this->template getInputValue<operand_b>();
+ Operator2<Type>()(b_minus_c, this->template getInputValue<operand_c>());
+
+ // rhs := (a - c) + (b - c)
+ Type rhs = a_minus_c;
+ Operator1<Type>()(rhs, b_minus_c);
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return lhs == rhs;
+ }
+
+ bool debug_holds()
+ {
+ // (a + b) - c == (a - c) + (b - c)
+ std::cout << "a:" << this->template getInputValue<operand_a>().as_string() << std::endl;
+ std::cout << "b:" << this->template getInputValue<operand_b>().as_string() << std::endl;
+ std::cout << "c:" << this->template getInputValue<operand_c>().as_string() << std::endl;
+ // --- left hand side ------------------------
+ // lhs := (a + b) - c
+ Type lhs = this->template getInputValue<operand_a>();
+ Operator1<Type>()(lhs, this->template getInputValue<operand_b>());
+ std::cout << "a+b:" << lhs.as_string() << std::endl;
+ Operator2<Type>()(lhs, this->template getInputValue<operand_c>());
+ std::cout << "l=(a+b)-c:" << lhs.as_string() << std::endl;
+
+ // --- right hand side -----------------------
+ Type a_minus_c = this->template getInputValue<operand_a>();
+ Operator2<Type>()(a_minus_c, this->template getInputValue<operand_c>());
+ std::cout << "a-c:" << a_minus_c.as_string() << std::endl;
+
+ Type b_minus_c = this->template getInputValue<operand_b>();
+ Operator2<Type>()(b_minus_c, this->template getInputValue<operand_c>());
+ std::cout << "b-c:" << b_minus_c.as_string() << std::endl;
+
+ // rhs := (a - c) + (b - c)
+ Type rhs = a_minus_c;
+ Operator1<Type>()(rhs, b_minus_c);
+ std::cout << "r=(a-c)+(b-c):" << b_minus_c.as_string() << std::endl;
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return lhs == rhs;
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename Type, template<class>class Equality = itl::std_equal>
+ class InplaceSymmetricDifference
+ : public Law<InplaceSymmetricDifference<Type>,
+ LOKI_TYPELIST_2(Type,Type), LOKI_TYPELIST_2(Type,Type)>
+ {
+ /** (a + b) - (a * b) == (a - b) + (b - a)
+ computed using inplace operators +=, += and *=
+ Input = (a := inVal1, b := inVal2)
+ Output = (lhs_result, rhs_result)
+ */
+ public:
+ std::string name()const { return "Inplace Symmetric Difference"; }
+ std::string formula()const { return "(a+b) - (a*b) == (a-b) + (b-a) 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "SymmetricDifference<"+type_to_string<Type>::apply()+","
+ +unary_template_to_string<Equality>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // --- left hand side ------------------------
+ Type a_plus_b = this->template getInputValue<operand_a>();
+ a_plus_b += this->template getInputValue<operand_b>();
+
+ Type a_sec_b = this->template getInputValue<operand_a>();
+ a_sec_b *= this->template getInputValue<operand_b>();
+
+ Type lhs = a_plus_b;
+ lhs -= a_sec_b;
+
+ // --- right hand side -----------------------
+ Type a_minus_b = this->template getInputValue<operand_a>();
+ a_minus_b -= this->template getInputValue<operand_b>();
+
+ Type b_minus_a = this->template getInputValue<operand_b>();
+ b_minus_a -= this->template getInputValue<operand_a>();
+
+ Type rhs = a_minus_b;
+ rhs += b_minus_a;
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+
+ bool debug_holds()
+ {
+ // --- left hand side ------------------------
+ Type a_plus_b = this->template getInputValue<operand_a>();
+ a_plus_b += this->template getInputValue<operand_b>();
+
+ std::cout << "a_plus_b=" << a_plus_b.as_string() << std::endl;
+
+ Type a_sec_b = this->template getInputValue<operand_a>();
+ a_sec_b *= this->template getInputValue<operand_b>();
+
+ std::cout << "a_sec_b=" << a_sec_b.as_string() << std::endl;
+
+ Type lhs = a_plus_b;
+ lhs -= a_sec_b;
+
+ std::cout << "lhs=" << lhs.as_string() << std::endl;
+
+ // --- right hand side -----------------------
+ Type a_minus_b = this->template getInputValue<operand_a>();
+ a_minus_b -= this->template getInputValue<operand_b>();
+ std::cout << "a_minus_b=" << a_minus_b.as_string() << std::endl;
+
+ Type b_minus_a = this->template getInputValue<operand_b>();
+ b_minus_a -= this->template getInputValue<operand_a>();
+ std::cout << "b_minus_a=" << b_minus_a.as_string() << std::endl;
+
+ Type rhs = a_minus_b;
+ rhs += b_minus_a;
+ std::cout << "rhs=" << rhs.as_string() << std::endl;
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<Type>()(lhs, rhs);
+ }
+
+ size_t size()const
+ {
+ return
+ value_size<Type>::apply(this->template getInputValue<operand_a>())+
+ value_size<Type>::apply(this->template getInputValue<operand_b>());
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ template <typename MapT, template<class>class Equality = itl::std_equal>
+ class SectionAbsorbtion
+ : public Law<SectionAbsorbtion<MapT>,
+ LOKI_TYPELIST_2(MapT, typename MapT::set_type), LOKI_TYPELIST_2(MapT,MapT)>
+ {
+ /** a - (a * b) == a - b
+ computed using inplace operators -= and *=
+ Input = (a := inVal1, b := inVal2)
+ Output = (lhs_result, rhs_result)
+ */
+ public:
+ std::string name()const { return "SectionAbsorbtion"; }
+ std::string formula()const { return "map a, set b: a - (a * b) == a - b 'inplace'"; }
+
+ std::string typeString()const
+ {
+ return "SectionAbsorbtion<"+type_to_string<MapT>::apply()+","
+ +unary_template_to_string<Equality>::apply()+">";
+ }
+
+ public:
+
+ bool holds()
+ {
+ // a - (a * b) == a - b
+ // --- left hand side ------------------------
+ // lhs := a - (a * b)
+ MapT a_sec_b = this->template getInputValue<operand_a>();
+ a_sec_b *= this->template getInputValue<operand_b>();
+ MapT lhs = this->template getInputValue<operand_a>();
+ lhs -= a_sec_b;
+
+ // --- right hand side -----------------------
+ // rhs := a - b
+ MapT rhs = this->template getInputValue<operand_a>();
+ rhs -= this->template getInputValue<operand_b>();
+
+ this->template setOutputValue<lhs_result>(lhs);
+ this->template setOutputValue<rhs_result>(rhs);
+
+ return Equality<MapT>()(lhs, rhs);
+ }
+
+ bool debug_holds(){ return holds(); }
+
+ size_t size()const
+ {
+ return
+ value_size<MapT>::apply(this->template getInputValue<operand_a>())+
+ value_size<typename MapT::set_type>::apply(this->template getInputValue<operand_b>());
+ }
+ };
+
+}} // namespace itl boost
+
+#endif // __itl_set_laws_h_JOFA_071124__
+
+
Added: sandbox/itl/boost/validate/lawvalidater.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/lawvalidater.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,182 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#pragma once
+
+#include <iostream>
+#include <stdio.h>
+#include <boost/validate/loki_xt/Tuple.h>
+#include <boost/itl/set.hpp>
+#include <boost/itl/map.hpp>
+#include <boost/validate/gentor/randomgentor.h>
+
+#include <boost/validate/laws/monoid.h>
+#include <boost/validate/lawviolations.h>
+
+namespace boost{namespace itl
+{
+ typedef itl::map<std::string, int> ValidationCounterT;
+ typedef itl::map<std::string, int> ViolationCounterT;
+ typedef itl::map<std::string, PolyLawViolations> ViolationMapT;
+
+ class LawValidaterI
+ {
+ public:
+ virtual ~LawValidaterI(){}
+ virtual void init()=0;
+ virtual void run()=0;
+ virtual void addFrequencies(ValidationCounterT&)=0;
+ virtual void addViolations(ViolationCounterT&, ViolationMapT&)=0;
+ };
+
+
+ template <class LawT, template<typename>class GentorT>
+ class LawValidater : public LawValidaterI
+ {
+ public:
+ typedef typename LawT::input_types input_types;
+ typedef typename LawT::output_types output_types;
+ typedef typename LawT::input_tuple input_tuple;
+ typedef typename LawT::output_tuple output_tuple;
+
+ typedef typename Loki::TL::MapType<GentorT, input_types>::Result gentor_types;
+ typedef typename Loki::tuple<gentor_types> input_gentor;
+
+ public:
+ LawValidater(){ setTrialsCount(1000); } //1000(std)//JODO config at only ONE location
+
+ void setTrialsCount(int trials)
+ {
+ _trialsCount = trials;
+ _silentTrialsCount = std::max(1, _trialsCount / 10);
+ }
+
+ void setSilentTrialsCount(int trials) { _trialsCount = trials; }
+
+ void init();
+ void run();
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += ViolationCounterT::value_type(lawType(), static_cast<int>(_lawViolations.size()));
+ if(!_lawViolations.empty())
+ collector += ViolationMapT::value_type(lawType(), PolyLawViolations(new LawViolationsT(_lawViolations)));
+ }
+
+ std::string lawType()const{ return _law.typeString(); }
+
+ void reportLawInfo()const;
+ void reportProgress()const;
+ void reportViolations()const;
+ void reportSuccess()const;
+
+ private:
+ typedef LawViolations<LawT> LawViolationsT;
+
+ private:
+ input_gentor _gentor;
+ LawT _law;
+
+ int _trialsCount;
+ int _silentTrialsCount;
+
+ LawViolationsT _lawViolations;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ }; //class LawValitater
+
+
+ template <class LawT, template<typename>class GentorT>
+ void LawValidater<LawT, GentorT>::init()
+ {
+ _frequencies.clear();
+ _lawViolations.clear();
+ _violations.clear();
+ }
+
+ template <class LawT, template<typename>class GentorT>
+ void LawValidater<LawT, GentorT>::run()
+ {
+ // apply Calibrater.apply to each element of the generator-tuple _gentor
+ // This is just an initialisation of the generators according to system
+ // defaults for convenience purposes.
+ _gentor.template apply<GentorT, Calibrater, input_tuple>();
+
+ // Input values that are to be generated on every iteration
+ input_tuple values;
+
+ for(int idx=0; idx<_trialsCount; idx++)
+ {
+ // Apply the function SomeVale to each component of the input tuple
+ _gentor.template map_template<GentorT, SomeValue>(values);
+ _law.setInstance(values);
+
+ if(!_law.holds())
+ _lawViolations.insert(_law);
+ }
+
+ if(!_lawViolations.empty())
+ {
+ reportViolations();
+ LawT violation = *(_lawViolations.begin());
+
+ input_tuple inVars;
+ output_tuple outVars;
+ violation.getInstance(inVars, outVars);
+ std::cout << "Violation of: " << _law.typeString() << std::endl;
+ std::cout << _law.formula() << std::endl;
+ std::cout << inVars.as_string() << std::endl;
+ std::cout << outVars.as_string() << std::endl;
+
+ violation.debug_holds();
+ }
+ else
+ {
+ //reportSuccess();
+ _frequencies.insert(ValidationCounterT::value_type(lawType(), 1));
+ }
+
+ }
+
+ template <class LawT, template<typename>class GentorT>
+ void LawValidater<LawT, GentorT>::reportLawInfo()const
+ {
+ std::cout << "----------------------------------------------------------" << std::endl;
+ std::cout << "Validation of law: " << std::endl;
+ std::cout << _law.name() << std::endl;
+ std::cout << _law.formula() << std::endl;
+ }
+
+ template <class LawT, template<typename>class GentorT>
+ void LawValidater<LawT, GentorT>::reportProgress()const
+ {
+ typename LawT::input_tuple input_values;
+ _law.getInputInstance(input_values);
+ //JODO think about more general mechanics of progress reporting here
+ std::cout << "SomeValues " << input_values.as_string() << std::endl;
+ }
+
+ template <class LawT, template<typename>class GentorT>
+ void LawValidater<LawT, GentorT>::reportViolations()const
+ {
+ std::cout << static_cast<int>(_lawViolations.getViolationsCount()) << " violations" << std::endl;
+ }
+
+ template <class LawT, template<typename>class GentorT>
+ void LawValidater<LawT, GentorT>::reportSuccess()const
+ {
+ std::cout << "Law successfully validated for " << _trialsCount << " cases" << std::endl;
+ }
+
+}} // namespace itl boost
+
+// ----------------------------------------------------------------------------
+
Added: sandbox/itl/boost/validate/lawviolations.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/lawviolations.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,176 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_LawViolations_h_JOFA_070411__
+#define __itl_LawViolations_h_JOFA_070411__
+
+#include <string>
+#include <boost/itl/set.hpp>
+#include <boost/validate/loki_xt/Tuple.h>
+
+namespace boost{namespace itl
+{
+
+ class LawViolationsI
+ {
+ public:
+ virtual ~LawViolationsI(){}
+
+ virtual size_t size()const=0;
+ virtual size_t getViolationsCount()const=0;
+ virtual LawViolationsI& operator += (const LawViolationsI& rhs)=0;
+
+ virtual const LawViolationsI* getLawViolations()const=0;
+
+ virtual bool operator == (const LawViolationsI& rhs)const=0;
+ virtual bool operator < (const LawViolationsI& rhs)const=0;
+
+ virtual void reportFirst()const=0;
+
+ };
+
+ class PolyLawViolations
+ {
+ public:
+ PolyLawViolations(): p_violations(NULL){}
+ PolyLawViolations(LawViolationsI* vios): p_violations(vios) {}
+ ~PolyLawViolations() {} //JODO delete p_violations; }
+
+ void destroy() { delete p_violations; p_violations = NULL; }
+
+ size_t size()const { return p_violations ? p_violations->size() : 0; }
+ size_t getViolationsCount()const { return p_violations ? p_violations->getViolationsCount() : 0; }
+
+ PolyLawViolations& operator += (const PolyLawViolations& rhs)
+ {
+ if(p_violations == NULL)
+ p_violations = rhs.p_violations;
+ else if(rhs.p_violations != NULL)
+ (*p_violations) += *(rhs.p_violations);
+
+ return *this;
+ }
+
+ bool operator == (const PolyLawViolations& rhs)const
+ {
+ return (p_violations == NULL && rhs.p_violations == NULL)
+ || (
+ ( p_violations != NULL && rhs.p_violations != NULL)
+ &&( p_violations == rhs.p_violations
+ || *p_violations == (*rhs.p_violations))
+ );
+ }
+
+ bool operator < (const PolyLawViolations& rhs)const
+ {
+ return (p_violations != NULL && rhs.p_violations != NULL)
+ && (*p_violations < (*rhs.p_violations));
+ }
+
+ void reportFirst()const
+ {
+ if(p_violations == NULL)
+ std::cout << "Empty law violation." << std::endl;
+ else
+ p_violations->reportFirst();
+ }
+
+ private:
+ LawViolationsI* p_violations;
+ };
+
+
+ /** class LawViolations.
+ LawViolations is a set of instances of a law that are violated sorted by operator <.
+ Operator < will usually be implemented via the size of the laws instance.
+ We are always only interested in small instances of law violations for efficient
+ debugging. */
+ template <class LawT>
+ class LawViolations : public LawViolationsI
+ {
+ public:
+ typedef LawT LawType;
+ typedef typename itl::set<LawType> ViolationSet;
+ typedef typename ViolationSet::size_type size_type;
+
+ typedef typename ViolationSet::iterator iterator;
+ typedef typename ViolationSet::const_iterator const_iterator;
+
+ enum { MaxSize = 20 };
+
+ LawViolations():_maxSize(MaxSize), _violationsCount(0){}
+
+ const LawViolationsI* getLawViolations()const { return this; }
+
+ size_t getViolationsCount()const { return _violationsCount; }
+
+ LawViolationsI& operator += (const LawViolationsI& rhs)
+ {
+ const_FORALL(typename ViolationSet, vio_,
+ dynamic_cast<const LawViolations<LawT>*>(rhs.getLawViolations())->_violations)
+ insert(*vio_);
+
+ return *this;
+ }
+
+ bool operator == (const LawViolationsI& rhs)const
+ {
+ return _violations == dynamic_cast<const LawViolations<LawT>*>(rhs.getLawViolations())->_violations;
+ }
+
+ bool operator < (const LawViolationsI& rhs)const
+ {
+ return _violations < dynamic_cast<const LawViolations<LawT>*>(rhs.getLawViolations())->_violations;
+ }
+
+ void insert(const LawType& lawInstance)
+ {
+ _violations.insert(lawInstance);
+ _violationsCount++;
+ if(0 < _violations.size() && _maxSize < static_cast<int>(_violations.size()))
+ {
+ typename ViolationSet::iterator doomed_ = _violations.end();
+ doomed_--;
+ _violations.erase(doomed_);
+ }
+ }
+
+ iterator begin() { return _violations.begin(); }
+ const_iterator begin()const { return _violations.begin(); }
+ iterator end() { return _violations.end(); }
+ const_iterator end()const { return _violations.begin(); }
+
+ void clear() { _violations.clear(); }
+ bool empty()const { return _violations.empty(); }
+ size_type size()const { return _violations.size(); }
+
+ void reportFirst()const
+ {
+ typename ViolationSet::const_iterator fst = _violations.begin();
+ LawT violation = *(_violations.begin());
+
+ typename LawT::input_tuple inVars;
+ typename LawT::output_tuple outVars;
+ violation.getInstance(inVars, outVars);
+ std::cout << "Violation of: " << violation.typeString() << std::endl;
+ std::cout << inVars.as_string() << std::endl;
+ std::cout << outVars.as_string() << std::endl;
+ }
+
+
+ private:
+ ViolationSet _violations;
+ int _maxSize;
+ size_t _violationsCount;
+ };
+
+}} // namespace itl boost
+
+#endif //__itl_LawViolations_h_JOFA_070411__
+
Added: sandbox/itl/boost/validate/loki/EmptyType.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/EmptyType.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2001 by Andrei Alexandrescu
+// This code accompanies the book:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_EMPTYTYPE_INC_
+#define LOKI_EMPTYTYPE_INC_
+
+// $Id$
+
+
+namespace Loki
+{
+////////////////////////////////////////////////////////////////////////////////
+// class EmptyType
+// Used as a class type that doesn't hold anything
+// Useful as a strawman class
+////////////////////////////////////////////////////////////////////////////////
+
+ class EmptyType {};
+
+
+ inline bool operator==(const EmptyType&, const EmptyType&)
+ {
+ return true;
+ }
+
+ inline bool operator<(const EmptyType&, const EmptyType&)
+ {
+ return false;
+ }
+
+ inline bool operator>(const EmptyType&, const EmptyType&)
+ {
+ return false;
+ }
+}
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki/NullType.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/NullType.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2001 by Andrei Alexandrescu
+// This code accompanies the book:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_NULLTYPE_INC_
+#define LOKI_NULLTYPE_INC_
+
+// $Id$
+
+
+namespace Loki
+{
+////////////////////////////////////////////////////////////////////////////////
+// class NullType
+// Used as a placeholder for "no type here"
+// Useful as an end marker in typelists
+////////////////////////////////////////////////////////////////////////////////
+
+ class NullType {};
+
+} // namespace Loki
+
+
+#endif // end file guardian
Added: sandbox/itl/boost/validate/loki/Sequence.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/Sequence.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2005 by Peter Kümmel
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_SEQUENCE_INC_
+#define LOKI_SEQUENCE_INC_
+
+// $Id$
+
+
+#include "Typelist.h"
+
+namespace Loki
+{
+
+ template
+ <
+ class T01=NullType,class T02=NullType,class T03=NullType,class T04=NullType,class T05=NullType,
+ class T06=NullType,class T07=NullType,class T08=NullType,class T09=NullType,class T10=NullType,
+ class T11=NullType,class T12=NullType,class T13=NullType,class T14=NullType,class T15=NullType,
+ class T16=NullType,class T17=NullType,class T18=NullType,class T19=NullType,class T20=NullType
+ >
+ struct Seq
+ {
+ private:
+ typedef typename Seq< T02, T03, T04, T05, T06, T07, T08, T09, T10,
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>::Type
+ TailResult;
+ public:
+ typedef Typelist<T01, TailResult> Type;
+ };
+
+ template<>
+ struct Seq<>
+ {
+ typedef NullType Type;
+ };
+
+} // namespace Loki
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki/TypeManip.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/TypeManip.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,284 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2001 by Andrei Alexandrescu
+// This code accompanies the book:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author or Addison-Welsey Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_TYPEMANIP_INC_
+#define LOKI_TYPEMANIP_INC_
+
+// $Id$
+
+
+namespace Loki
+{
+////////////////////////////////////////////////////////////////////////////////
+// class template Int2Type
+// Converts each integral constant into a unique type
+// Invocation: Int2Type<v> where v is a compile-time constant integral
+// Defines 'value', an enum that evaluates to v
+////////////////////////////////////////////////////////////////////////////////
+
+ template <int v>
+ struct Int2Type
+ {
+ enum { value = v };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Type2Type
+// Converts each type into a unique, insipid type
+// Invocation Type2Type<T> where T is a type
+// Defines the type OriginalType which maps back to T
+////////////////////////////////////////////////////////////////////////////////
+
+ template <typename T>
+ struct Type2Type
+ {
+ typedef T OriginalType;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Select
+// Selects one of two types based upon a boolean constant
+// Invocation: Select<flag, T, U>::Result
+// where:
+// flag is a compile-time boolean constant
+// T and U are types
+// Result evaluates to T if flag is true, and to U otherwise.
+////////////////////////////////////////////////////////////////////////////////
+
+ template <bool flag, typename T, typename U>
+ struct Select
+ {
+ typedef T Result;
+ };
+ template <typename T, typename U>
+ struct Select<false, T, U>
+ {
+ typedef U Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template IsSameType
+// Return true iff two given types are the same
+// Invocation: SameType<T, U>::value
+// where:
+// T and U are types
+// Result evaluates to true iff U == T (types equal)
+////////////////////////////////////////////////////////////////////////////////
+
+ template <typename T, typename U>
+ struct IsSameType
+ {
+ enum { value = false };
+ };
+
+ template <typename T>
+ struct IsSameType<T,T>
+ {
+ enum { value = true };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big)
+////////////////////////////////////////////////////////////////////////////////
+
+ namespace Private
+ {
+ template <class T, class U>
+ struct ConversionHelper
+ {
+ typedef char Small;
+ struct Big { char dummy[2]; };
+ static Big Test(...);
+ static Small Test(U);
+ static T MakeT();
+ };
+ }
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Conversion
+// Figures out the conversion relationships between two types
+// Invocations (T and U are types):
+// a) Conversion<T, U>::exists
+// returns (at compile time) true if there is an implicit conversion from T
+// to U (example: Derived to Base)
+// b) Conversion<T, U>::exists2Way
+// returns (at compile time) true if there are both conversions from T
+// to U and from U to T (example: int to char and back)
+// c) Conversion<T, U>::sameType
+// returns (at compile time) true if T and U represent the same type
+//
+// Caveat: might not work if T and U are in a private inheritance hierarchy.
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class T, class U>
+ struct Conversion
+ {
+ typedef Private::ConversionHelper<T, U> H;
+#ifndef __MWERKS__
+ enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };
+#else
+ enum { exists = false };
+#endif
+ enum { exists2Way = exists && Conversion<U, T>::exists };
+ enum { sameType = false };
+ };
+
+ template <class T>
+ struct Conversion<T, T>
+ {
+ enum { exists = 1, exists2Way = 1, sameType = 1 };
+ };
+
+ template <class T>
+ struct Conversion<void, T>
+ {
+ enum { exists = 0, exists2Way = 0, sameType = 0 };
+ };
+
+ template <class T>
+ struct Conversion<T, void>
+ {
+ enum { exists = 0, exists2Way = 0, sameType = 0 };
+ };
+
+ template <>
+ struct Conversion<void, void>
+ {
+ public:
+ enum { exists = 1, exists2Way = 1, sameType = 1 };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template SuperSubclass
+// Invocation: SuperSubclass<B, D>::value where B and D are types.
+// Returns true if B is a public base of D, or if B and D are aliases of the
+// same type.
+//
+// Caveat: might not work if T and U are in a private inheritance hierarchy.
+////////////////////////////////////////////////////////////////////////////////
+
+template <class T, class U>
+struct SuperSubclass
+{
+ enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
+
+ // Dummy enum to make sure that both classes are fully defined.
+ enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
+};
+
+template <>
+struct SuperSubclass<void, void>
+{
+ enum { value = false };
+};
+
+template <class U>
+struct SuperSubclass<void, U>
+{
+ enum { value = (::Loki::Conversion<const volatile U*, const volatile void*>::exists &&
+ !::Loki::Conversion<const volatile void*, const volatile void*>::sameType) };
+
+ // Dummy enum to make sure that both classes are fully defined.
+ enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
+};
+
+template <class T>
+struct SuperSubclass<T, void>
+{
+ enum { value = (::Loki::Conversion<const volatile void*, const volatile T*>::exists &&
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
+
+ // Dummy enum to make sure that both classes are fully defined.
+ enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// class template SuperSubclassStrict
+// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
+// Returns true if B is a public base of D.
+//
+// Caveat: might not work if T and U are in a private inheritance hierarchy.
+////////////////////////////////////////////////////////////////////////////////
+
+template<class T,class U>
+struct SuperSubclassStrict
+{
+ enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
+ !::Loki::Conversion<const volatile T*, const volatile U*>::sameType) };
+
+ // Dummy enum to make sure that both classes are fully defined.
+ enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
+};
+
+template<>
+struct SuperSubclassStrict<void, void>
+{
+ enum { value = false };
+};
+
+template<class U>
+struct SuperSubclassStrict<void, U>
+{
+ enum { value = (::Loki::Conversion<const volatile U*, const volatile void*>::exists &&
+ !::Loki::Conversion<const volatile void*, const volatile void*>::sameType &&
+ !::Loki::Conversion<const volatile void*, const volatile U*>::sameType) };
+
+ // Dummy enum to make sure that both classes are fully defined.
+ enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
+};
+
+template<class T>
+struct SuperSubclassStrict<T, void>
+{
+ enum { value = (::Loki::Conversion<const volatile void*, const volatile T*>::exists &&
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
+
+ // Dummy enum to make sure that both classes are fully defined.
+ enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
+};
+
+
+} // namespace Loki
+
+////////////////////////////////////////////////////////////////////////////////
+// macro SUPERSUBCLASS
+// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
+// Returns true if B is a public base of D, or if B and D are aliases of the
+// same type.
+//
+// Caveat: might not work if T and U are in a private inheritance hierarchy.
+// Deprecated: Use SuperSubclass class template instead.
+////////////////////////////////////////////////////////////////////////////////
+
+#define LOKI_SUPERSUBCLASS(T, U) \
+ ::Loki::SuperSubclass<T,U>::value
+
+////////////////////////////////////////////////////////////////////////////////
+// macro SUPERSUBCLASS_STRICT
+// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
+// Returns true if B is a public base of D.
+//
+// Caveat: might not work if T and U are in a private inheritance hierarchy.
+// Deprecated: Use SuperSubclassStrict class template instead.
+////////////////////////////////////////////////////////////////////////////////
+
+#define LOKI_SUPERSUBCLASS_STRICT(T, U) \
+ ::Loki::SuperSubclassStrict<T,U>::value
+
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki/TypeTraits.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/TypeTraits.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,2228 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2001 by Andrei Alexandrescu
+// This code accompanies the book:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_TYPETRAITS_INC_
+#define LOKI_TYPETRAITS_INC_
+
+// $Id$
+
+
+#include "Typelist.h"
+#include "Sequence.h"
+
+#if (defined _MSC_VER) && (_MSC_VER < 1400)
+#include <string>
+#endif
+
+
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 4180 ) //qualifier applied to function type has no meaning; ignored
+#endif
+
+namespace Loki
+{
+////////////////////////////////////////////////////////////////////////////////
+// class template IsCustomUnsignedInt
+// Offers a means to integrate nonstandard built-in unsigned integral types
+// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
+// class template defined below.
+// Invocation: IsCustomUnsignedInt<T> where T is any type
+// Defines 'value', an enum that is 1 iff T is a custom built-in unsigned
+// integral type
+// Specialize this class template for nonstandard unsigned integral types
+// and define value = 1 in those specializations
+////////////////////////////////////////////////////////////////////////////////
+
+ template <typename T>
+ struct IsCustomUnsignedInt
+ {
+ enum { value = 0 };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template IsCustomSignedInt
+// Offers a means to integrate nonstandard built-in unsigned integral types
+// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
+// class template defined below.
+// Invocation: IsCustomSignedInt<T> where T is any type
+// Defines 'value', an enum that is 1 iff T is a custom built-in signed
+// integral type
+// Specialize this class template for nonstandard unsigned integral types
+// and define value = 1 in those specializations
+////////////////////////////////////////////////////////////////////////////////
+
+ template <typename T>
+ struct IsCustomSignedInt
+ {
+ enum { value = 0 };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template IsCustomFloat
+// Offers a means to integrate nonstandard floating point types with the
+// TypeTraits class template defined below.
+// Invocation: IsCustomFloat<T> where T is any type
+// Defines 'value', an enum that is 1 iff T is a custom built-in
+// floating point type
+// Specialize this class template for nonstandard unsigned integral types
+// and define value = 1 in those specializations
+////////////////////////////////////////////////////////////////////////////////
+
+ template <typename T>
+ struct IsCustomFloat
+ {
+ enum { value = 0 };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// Helper types for class template TypeTraits defined below
+////////////////////////////////////////////////////////////////////////////////
+
+ namespace Private
+ {
+#ifndef LOKI_DISABLE_TYPELIST_MACROS
+ typedef LOKI_TYPELIST_4(unsigned char, unsigned short int,unsigned int, unsigned long int)
+ StdUnsignedInts;
+ typedef LOKI_TYPELIST_4(signed char, short int,int, long int)
+ StdSignedInts;
+ typedef LOKI_TYPELIST_3(bool, char, wchar_t)
+ StdOtherInts;
+ typedef LOKI_TYPELIST_3(float, double, long double)
+ StdFloats;
+#else
+ typedef Loki::Seq<unsigned char, unsigned short int,unsigned int, unsigned long int>::Type
+ StdUnsignedInts;
+ typedef Loki::Seq<signed char, short int,int, long int>::Type
+ StdSignedInts;
+ typedef Loki::Seq<bool, char, wchar_t>::Type
+ StdOtherInts;
+ typedef Loki::Seq<float, double, long double>::Type
+ StdFloats;
+
+#endif
+ template <typename U> struct AddPointer
+ {
+ typedef U* Result;
+ };
+
+ template <typename U> struct AddPointer<U&>
+ {
+ typedef U* Result;
+ };
+
+ template <class U> struct AddReference
+ {
+ typedef U & Result;
+ };
+
+ template <class U> struct AddReference<U &>
+ {
+ typedef U & Result;
+ };
+
+ template <> struct AddReference<void>
+ {
+ typedef NullType Result;
+ };
+
+ template <class U> struct AddParameterType
+ {
+ typedef const U & Result;
+ };
+
+ template <class U> struct AddParameterType<U &>
+ {
+ typedef U & Result;
+ };
+
+ template <> struct AddParameterType<void>
+ {
+ typedef NullType Result;
+ };
+
+ template <typename T>
+ struct IsFunctionPointerRaw
+ {enum{result = 0};};
+
+ template <typename T>
+ struct IsFunctionPointerRaw<T(*)()>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01>
+ struct IsFunctionPointerRaw<T(*)(P01)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20)>
+ {enum {result = 1};};
+
+ template <typename T>
+ struct IsFunctionPointerRaw<T(*)(
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...)>
+ {enum {result = 1};};
+
+ template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...)>
+ {enum {result = 1};};
+
+
+ template <typename T>
+ struct IsMemberFunctionPointerRaw
+ {enum{result = 0};};
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)()>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(P01)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20)>
+ {enum {result = 1};};
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...)>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...)>
+ {enum {result = 1};};
+
+ // Const versions
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)() const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(P01) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...) const>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...) const>
+ {enum {result = 1};};
+
+ // Volatile versions
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)() volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(P01) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...) volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...) volatile>
+ {enum {result = 1};};
+
+ // Const volatile versions
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)() const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(P01) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...) const volatile>
+ {enum {result = 1};};
+
+ template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+ struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...) const volatile>
+ {enum {result = 1};};
+
+ }// namespace Private
+
+////////////////////////////////////////////////////////////////////////////////
+// class template TypeTraits
+//
+// Figures out at compile time various properties of any given type
+// Invocations (T is a type, TypeTraits<T>::Propertie):
+//
+// - isPointer : returns true if T is a pointer type
+// - PointeeType : returns the type to which T points if T is a pointer
+// type, NullType otherwise
+// - isReference : returns true if T is a reference type
+// - ReferredType : returns the type to which T refers if T is a reference
+// type, NullType otherwise
+// - isMemberPointer : returns true if T is a pointer to member type
+// - isStdUnsignedInt: returns true if T is a standard unsigned integral type
+// - isStdSignedInt : returns true if T is a standard signed integral type
+// - isStdIntegral : returns true if T is a standard integral type
+// - isStdFloat : returns true if T is a standard floating-point type
+// - isStdArith : returns true if T is a standard arithmetic type
+// - isStdFundamental: returns true if T is a standard fundamental type
+// - isUnsignedInt : returns true if T is a unsigned integral type
+// - isSignedInt : returns true if T is a signed integral type
+// - isIntegral : returns true if T is a integral type
+// - isFloat : returns true if T is a floating-point type
+// - isArith : returns true if T is a arithmetic type
+// - isFundamental : returns true if T is a fundamental type
+// - ParameterType : returns the optimal type to be used as a parameter for
+// functions that take Ts
+// - isConst : returns true if T is a const-qualified type
+// - NonConstType : Type with removed 'const' qualifier from T, if any
+// - isVolatile : returns true if T is a volatile-qualified type
+// - NonVolatileType : Type with removed 'volatile' qualifier from T, if any
+// - UnqualifiedType : Type with removed 'const' and 'volatile' qualifiers from
+// T, if any
+// - ConstParameterType: returns the optimal type to be used as a parameter
+// for functions that take 'const T's
+//
+////////////////////////////////////////////////////////////////////////////////
+
+ template <typename T>
+ class TypeTraits
+ {
+ private:
+
+ template <class U> struct ReferenceTraits
+ {
+ enum { result = false };
+ typedef U ReferredType;
+ };
+
+ template <class U> struct ReferenceTraits<U&>
+ {
+ enum { result = true };
+ typedef U ReferredType;
+ };
+
+ template <class U> struct PointerTraits
+ {
+ enum { result = false };
+ typedef NullType PointeeType;
+ };
+
+ template <class U> struct PointerTraits<U*>
+ {
+ enum { result = true };
+ typedef U PointeeType;
+ };
+
+ template <class U> struct PointerTraits<U*&>
+ {
+ enum { result = true };
+ typedef U PointeeType;
+ };
+
+ template <class U> struct PToMTraits
+ {
+ enum { result = false };
+ };
+
+ template <class U, class V> struct PToMTraits<U V::*>
+ {
+ enum { result = true };
+ };
+
+ template <class U, class V> struct PToMTraits<U V::*&>
+ {
+ enum { result = true };
+ };
+
+ template <class U> struct FunctionPointerTraits
+ {
+ enum{ result = Private::IsFunctionPointerRaw<U>::result };
+ };
+
+ template <typename U> struct PToMFunctionTraits
+ {
+ enum{ result = Private::IsMemberFunctionPointerRaw<U>::result };
+ };
+
+ template <class U> struct UnConst
+ {
+ typedef U Result;
+ enum { isConst = 0 };
+ };
+
+ template <class U> struct UnConst<const U>
+ {
+ typedef U Result;
+ enum { isConst = 1 };
+ };
+
+ template <class U> struct UnConst<const U&>
+ {
+ typedef U& Result;
+ enum { isConst = 1 };
+ };
+
+ template <class U> struct UnVolatile
+ {
+ typedef U Result;
+ enum { isVolatile = 0 };
+ };
+
+ template <class U> struct UnVolatile<volatile U>
+ {
+ typedef U Result;
+ enum { isVolatile = 1 };
+ };
+
+ template <class U> struct UnVolatile<volatile U&>
+ {
+ typedef U& Result;
+ enum { isVolatile = 1 };
+ };
+
+ public:
+ typedef typename UnConst<T>::Result
+ NonConstType;
+ typedef typename UnVolatile<T>::Result
+ NonVolatileType;
+ typedef typename UnVolatile<typename UnConst<T>::Result>::Result
+ UnqualifiedType;
+ typedef typename PointerTraits<UnqualifiedType>::PointeeType
+ PointeeType;
+ typedef typename ReferenceTraits<T>::ReferredType
+ ReferredType;
+
+ enum { isConst = UnConst<T>::isConst };
+ enum { isVolatile = UnVolatile<T>::isVolatile };
+ enum { isReference = ReferenceTraits<UnqualifiedType>::result };
+ enum { isFunction = FunctionPointerTraits<typename Private::AddPointer<T>::Result >::result };
+ enum { isFunctionPointer= FunctionPointerTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result };
+ enum { isMemberFunctionPointer= PToMFunctionTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result };
+ enum { isMemberPointer = PToMTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result ||
+ isMemberFunctionPointer };
+ enum { isPointer = PointerTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result ||
+ isFunctionPointer };
+
+ enum { isStdUnsignedInt = TL::IndexOf<Private::StdUnsignedInts, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdUnsignedInts,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
+ enum { isStdSignedInt = TL::IndexOf<Private::StdSignedInts, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdSignedInts,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
+ enum { isStdIntegral = isStdUnsignedInt || isStdSignedInt ||
+ TL::IndexOf<Private::StdOtherInts, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdOtherInts,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
+ enum { isStdFloat = TL::IndexOf<Private::StdFloats, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdFloats,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
+ enum { isStdArith = isStdIntegral || isStdFloat };
+ enum { isStdFundamental = isStdArith || isStdFloat || Conversion<T, void>::sameType };
+
+ enum { isUnsignedInt = isStdUnsignedInt || IsCustomUnsignedInt<UnqualifiedType>::value };
+ enum { isSignedInt = isStdSignedInt || IsCustomSignedInt<UnqualifiedType>::value };
+ enum { isIntegral = isStdIntegral || isUnsignedInt || isSignedInt };
+ enum { isFloat = isStdFloat || IsCustomFloat<UnqualifiedType>::value };
+ enum { isArith = isIntegral || isFloat };
+ enum { isFundamental = isStdFundamental || isArith };
+
+ typedef typename Select<isStdArith || isPointer || isMemberPointer, T,
+ typename Private::AddParameterType<T>::Result>::Result
+ ParameterType;
+ };
+}
+
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif // _MSC_VER
+
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki/Typelist.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/Typelist.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,459 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2001 by Andrei Alexandrescu
+// This code accompanies the book:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author or Addison-Welsey Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_TYPELIST_INC_
+#define LOKI_TYPELIST_INC_
+
+// $Id$
+
+
+#include "NullType.h"
+#include "TypeManip.h"
+#include "TypelistMacros.h"
+
+
+namespace Loki
+{
+////////////////////////////////////////////////////////////////////////////////
+// class template Typelist
+// The building block of typelists of any length
+// Use it through the LOKI_TYPELIST_NN macros
+// Defines nested types:
+// Head (first element, a non-typelist type by convention)
+// Tail (second element, can be another typelist)
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class T, class U>
+ struct Typelist
+ {
+ typedef T Head;
+ typedef U Tail;
+ };
+
+// Typelist utility algorithms
+
+ namespace TL
+ {
+
+////////////////////////////////////////////////////////////////////////////////
+// class template MakeTypelist
+// Takes a number of arguments equal to its numeric suffix
+// The arguments are type names.
+// MakeTypelist<T1, T2, ...>::Result
+// returns a typelist that is of T1, T2, ...
+////////////////////////////////////////////////////////////////////////////////
+
+ template
+ <
+ typename T1 = NullType, typename T2 = NullType, typename T3 = NullType,
+ typename T4 = NullType, typename T5 = NullType, typename T6 = NullType,
+ typename T7 = NullType, typename T8 = NullType, typename T9 = NullType,
+ typename T10 = NullType, typename T11 = NullType, typename T12 = NullType,
+ typename T13 = NullType, typename T14 = NullType, typename T15 = NullType,
+ typename T16 = NullType, typename T17 = NullType, typename T18 = NullType
+ >
+ struct MakeTypelist
+ {
+ private:
+ typedef typename MakeTypelist
+ <
+ T2 , T3 , T4 ,
+ T5 , T6 , T7 ,
+ T8 , T9 , T10,
+ T11, T12, T13,
+ T14, T15, T16,
+ T17, T18
+ >
+ ::Result TailResult;
+
+ public:
+ typedef Typelist<T1, TailResult> Result;
+ };
+
+ template<>
+ struct MakeTypelist<>
+ {
+ typedef NullType Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Length
+// Computes the length of a typelist
+// Invocation (TList is a typelist):
+// Length<TList>::value
+// returns a compile-time constant containing the length of TList, not counting
+// the end terminator (which by convention is NullType)
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList> struct Length;
+ template <> struct Length<NullType>
+ {
+ enum { value = 0 };
+ };
+
+ template <class T, class U>
+ struct Length< Typelist<T, U> >
+ {
+ enum { value = 1 + Length<U>::value };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template TypeAt
+// Finds the type at a given index in a typelist
+// Invocation (TList is a typelist and index is a compile-time integral
+// constant):
+// TypeAt<TList, index>::Result
+// returns the type in position 'index' in TList
+// If you pass an out-of-bounds index, the result is a compile-time error
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, unsigned int index> struct TypeAt;
+
+ template <class Head, class Tail>
+ struct TypeAt<Typelist<Head, Tail>, 0>
+ {
+ typedef Head Result;
+ };
+
+ template <class Head, class Tail, unsigned int i>
+ struct TypeAt<Typelist<Head, Tail>, i>
+ {
+ typedef typename TypeAt<Tail, i - 1>::Result Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template TypeAtNonStrict
+// Finds the type at a given index in a typelist
+// Invocations (TList is a typelist and index is a compile-time integral
+// constant):
+// a) TypeAt<TList, index>::Result
+// returns the type in position 'index' in TList, or NullType if index is
+// out-of-bounds
+// b) TypeAt<TList, index, D>::Result
+// returns the type in position 'index' in TList, or D if index is out-of-bounds
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, unsigned int index,
+ typename DefaultType = NullType>
+ struct TypeAtNonStrict
+ {
+ typedef DefaultType Result;
+ };
+
+ template <class Head, class Tail, typename DefaultType>
+ struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType>
+ {
+ typedef Head Result;
+ };
+
+ template <class Head, class Tail, unsigned int i, typename DefaultType>
+ struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType>
+ {
+ typedef typename
+ TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template IndexOf
+// Finds the index of a type in a typelist
+// Invocation (TList is a typelist and T is a type):
+// IndexOf<TList, T>::value
+// returns the position of T in TList, or NullType if T is not found in TList
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T> struct IndexOf;
+
+ template <class T>
+ struct IndexOf<NullType, T>
+ {
+ enum { value = -1 };
+ };
+
+ template <class T, class Tail>
+ struct IndexOf<Typelist<T, Tail>, T>
+ {
+ enum { value = 0 };
+ };
+
+ template <class Head, class Tail, class T>
+ struct IndexOf<Typelist<Head, Tail>, T>
+ {
+ private:
+ enum { temp = IndexOf<Tail, T>::value };
+ public:
+ enum { value = (temp == -1 ? -1 : 1 + temp) };
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Append
+// Appends a type or a typelist to another
+// Invocation (TList is a typelist and T is either a type or a typelist):
+// Append<TList, T>::Result
+// returns a typelist that is TList followed by T and NullType-terminated
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T> struct Append;
+
+ template <> struct Append<NullType, NullType>
+ {
+ typedef NullType Result;
+ };
+
+ template <class T> struct Append<NullType, T>
+ {
+ typedef Typelist<T,NullType> Result;
+ };
+
+ template <class Head, class Tail>
+ struct Append<NullType, Typelist<Head, Tail> >
+ {
+ typedef Typelist<Head, Tail> Result;
+ };
+
+ template <class Head, class Tail, class T>
+ struct Append<Typelist<Head, Tail>, T>
+ {
+ typedef Typelist<Head,
+ typename Append<Tail, T>::Result>
+ Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Erase
+// Erases the first occurence, if any, of a type in a typelist
+// Invocation (TList is a typelist and T is a type):
+// Erase<TList, T>::Result
+// returns a typelist that is TList without the first occurence of T
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T> struct Erase;
+
+ template <class T> // Specialization 1
+ struct Erase<NullType, T>
+ {
+ typedef NullType Result;
+ };
+
+ template <class T, class Tail> // Specialization 2
+ struct Erase<Typelist<T, Tail>, T>
+ {
+ typedef Tail Result;
+ };
+
+ template <class Head, class Tail, class T> // Specialization 3
+ struct Erase<Typelist<Head, Tail>, T>
+ {
+ typedef Typelist<Head,
+ typename Erase<Tail, T>::Result>
+ Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template EraseAll
+// Erases all first occurences, if any, of a type in a typelist
+// Invocation (TList is a typelist and T is a type):
+// EraseAll<TList, T>::Result
+// returns a typelist that is TList without any occurence of T
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T> struct EraseAll;
+ template <class T>
+ struct EraseAll<NullType, T>
+ {
+ typedef NullType Result;
+ };
+ template <class T, class Tail>
+ struct EraseAll<Typelist<T, Tail>, T>
+ {
+ // Go all the way down the list removing the type
+ typedef typename EraseAll<Tail, T>::Result Result;
+ };
+ template <class Head, class Tail, class T>
+ struct EraseAll<Typelist<Head, Tail>, T>
+ {
+ // Go all the way down the list removing the type
+ typedef Typelist<Head,
+ typename EraseAll<Tail, T>::Result>
+ Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template NoDuplicates
+// Removes all duplicate types in a typelist
+// Invocation (TList is a typelist):
+// NoDuplicates<TList, T>::Result
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList> struct NoDuplicates;
+
+ template <> struct NoDuplicates<NullType>
+ {
+ typedef NullType Result;
+ };
+
+ template <class Head, class Tail>
+ struct NoDuplicates< Typelist<Head, Tail> >
+ {
+ private:
+ typedef typename NoDuplicates<Tail>::Result L1;
+ typedef typename Erase<L1, Head>::Result L2;
+ public:
+ typedef Typelist<Head, L2> Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Replace
+// Replaces the first occurence of a type in a typelist, with another type
+// Invocation (TList is a typelist, T, U are types):
+// Replace<TList, T, U>::Result
+// returns a typelist in which the first occurence of T is replaced with U
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T, class U> struct Replace;
+
+ template <class T, class U>
+ struct Replace<NullType, T, U>
+ {
+ typedef NullType Result;
+ };
+
+ template <class T, class Tail, class U>
+ struct Replace<Typelist<T, Tail>, T, U>
+ {
+ typedef Typelist<U, Tail> Result;
+ };
+
+ template <class Head, class Tail, class T, class U>
+ struct Replace<Typelist<Head, Tail>, T, U>
+ {
+ typedef Typelist<Head,
+ typename Replace<Tail, T, U>::Result>
+ Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template ReplaceAll
+// Replaces all occurences of a type in a typelist, with another type
+// Invocation (TList is a typelist, T, U are types):
+// Replace<TList, T, U>::Result
+// returns a typelist in which all occurences of T is replaced with U
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T, class U> struct ReplaceAll;
+
+ template <class T, class U>
+ struct ReplaceAll<NullType, T, U>
+ {
+ typedef NullType Result;
+ };
+
+ template <class T, class Tail, class U>
+ struct ReplaceAll<Typelist<T, Tail>, T, U>
+ {
+ typedef Typelist<U, typename ReplaceAll<Tail, T, U>::Result> Result;
+ };
+
+ template <class Head, class Tail, class T, class U>
+ struct ReplaceAll<Typelist<Head, Tail>, T, U>
+ {
+ typedef Typelist<Head,
+ typename ReplaceAll<Tail, T, U>::Result>
+ Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template Reverse
+// Reverses a typelist
+// Invocation (TList is a typelist):
+// Reverse<TList>::Result
+// returns a typelist that is TList reversed
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList> struct Reverse;
+
+ template <>
+ struct Reverse<NullType>
+ {
+ typedef NullType Result;
+ };
+
+ template <class Head, class Tail>
+ struct Reverse< Typelist<Head, Tail> >
+ {
+ typedef typename Append<
+ typename Reverse<Tail>::Result, Head>::Result Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template MostDerived
+// Finds the type in a typelist that is the most derived from a given type
+// Invocation (TList is a typelist, T is a type):
+// MostDerived<TList, T>::Result
+// returns the type in TList that's the most derived from T
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList, class T> struct MostDerived;
+
+ template <class T>
+ struct MostDerived<NullType, T>
+ {
+ typedef T Result;
+ };
+
+ template <class Head, class Tail, class T>
+ struct MostDerived<Typelist<Head, Tail>, T>
+ {
+ private:
+ typedef typename MostDerived<Tail, T>::Result Candidate;
+ public:
+ typedef typename Select<
+ SuperSubclass<Candidate,Head>::value,
+ Head, Candidate>::Result Result;
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+// class template DerivedToFront
+// Arranges the types in a typelist so that the most derived types appear first
+// Invocation (TList is a typelist):
+// DerivedToFront<TList>::Result
+// returns the reordered TList
+////////////////////////////////////////////////////////////////////////////////
+
+ template <class TList> struct DerivedToFront;
+
+ template <>
+ struct DerivedToFront<NullType>
+ {
+ typedef NullType Result;
+ };
+
+ template <class Head, class Tail>
+ struct DerivedToFront< Typelist<Head, Tail> >
+ {
+ private:
+ typedef typename MostDerived<Tail, Head>::Result
+ TheMostDerived;
+ typedef typename Replace<Tail,
+ TheMostDerived, Head>::Result Temp;
+ typedef typename DerivedToFront<Temp>::Result L;
+ public:
+ typedef Typelist<TheMostDerived, L> Result;
+ };
+
+ } // namespace TL
+} // namespace Loki
+
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki/TypelistMacros.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki/TypelistMacros.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,353 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2001 by Andrei Alexandrescu
+// This code accompanies the book:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author or Addison-Welsey Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_TYPELISTMACROS_INC_
+#define LOKI_TYPELISTMACROS_INC_
+
+// $Id$
+
+
+//#define LOKI_DISABLE_TYPELIST_MACROS
+#ifndef LOKI_DISABLE_TYPELIST_MACROS
+
+////////////////////////////////////////////////////////////////////////////////
+// macros LOKI_TYPELIST_1, LOKI_TYPELIST_2, ... LOKI_TYPELIST_50
+// Each takes a number of arguments equal to its numeric suffix
+// The arguments are type names. LOKI_TYPELIST_NN generates a typelist containing
+// all types passed as arguments, in that order.
+// Example: LOKI_TYPELIST_2(char, int) generates a type containing char and int.
+////////////////////////////////////////////////////////////////////////////////
+
+#define LOKI_TYPELIST_1(T1) ::Loki::Typelist<T1, ::Loki::NullType>
+
+#define LOKI_TYPELIST_2(T1, T2) ::Loki::Typelist<T1, LOKI_TYPELIST_1(T2) >
+
+#define LOKI_TYPELIST_3(T1, T2, T3) ::Loki::Typelist<T1, LOKI_TYPELIST_2(T2, T3) >
+
+#define LOKI_TYPELIST_4(T1, T2, T3, T4) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_3(T2, T3, T4) >
+
+#define LOKI_TYPELIST_5(T1, T2, T3, T4, T5) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_4(T2, T3, T4, T5) >
+
+#define LOKI_TYPELIST_6(T1, T2, T3, T4, T5, T6) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_5(T2, T3, T4, T5, T6) >
+
+#define LOKI_TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_6(T2, T3, T4, T5, T6, T7) >
+
+#define LOKI_TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_7(T2, T3, T4, T5, T6, T7, T8) >
+
+#define LOKI_TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_8(T2, T3, T4, T5, T6, T7, T8, T9) >
+
+#define LOKI_TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_9(T2, T3, T4, T5, T6, T7, T8, T9, T10) >
+
+#define LOKI_TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_10(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) >
+
+#define LOKI_TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_11(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12) >
+
+#define LOKI_TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_12(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13) >
+
+#define LOKI_TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14) >
+
+#define LOKI_TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15) >
+
+#define LOKI_TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_15(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16) >
+
+#define LOKI_TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_16(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17) >
+
+#define LOKI_TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_17(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18) >
+
+#define LOKI_TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_18(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19) >
+
+#define LOKI_TYPELIST_20(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_19(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) >
+
+#define LOKI_TYPELIST_21(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_20(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) >
+
+#define LOKI_TYPELIST_22(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_21(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) >
+
+#define LOKI_TYPELIST_23(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_22(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) >
+
+#define LOKI_TYPELIST_24(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_23(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) >
+
+#define LOKI_TYPELIST_25(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_24(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25) >
+
+#define LOKI_TYPELIST_26(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_25(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26) >
+
+#define LOKI_TYPELIST_27(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_26(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27) >
+
+#define LOKI_TYPELIST_28(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_27(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28) >
+
+#define LOKI_TYPELIST_29(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_28(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29) >
+
+#define LOKI_TYPELIST_30(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_29(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) >
+
+#define LOKI_TYPELIST_31(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_30(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) >
+
+#define LOKI_TYPELIST_32(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_31(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) >
+
+#define LOKI_TYPELIST_33(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_32(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) >
+
+#define LOKI_TYPELIST_34(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_33(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) >
+
+#define LOKI_TYPELIST_35(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_34(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35) >
+
+#define LOKI_TYPELIST_36(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_35(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36) >
+
+#define LOKI_TYPELIST_37(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_36(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37) >
+
+#define LOKI_TYPELIST_38(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_37(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38) >
+
+#define LOKI_TYPELIST_39(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_38(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39) >
+
+#define LOKI_TYPELIST_40(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_39(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) >
+
+#define LOKI_TYPELIST_41(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_40(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) >
+
+#define LOKI_TYPELIST_42(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_41(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) >
+
+#define LOKI_TYPELIST_43(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) >
+
+#define LOKI_TYPELIST_44(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) >
+
+#define LOKI_TYPELIST_45(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45) >
+
+#define LOKI_TYPELIST_46(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46) >
+
+#define LOKI_TYPELIST_47(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47) >
+
+#define LOKI_TYPELIST_48(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47, T48) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47, T48) >
+
+#define LOKI_TYPELIST_49(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47, T48, T49) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47, T48, T49) >
+
+#define LOKI_TYPELIST_50(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) \
+ ::Loki::Typelist<T1, LOKI_TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \
+ T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \
+ T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \
+ T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) >
+
+#endif //LOKI_DISABLE_TYPELIST_MACROS
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki_xt/Tuple.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki_xt/Tuple.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,851 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+// This code is based on and inspired by designs of:
+// The Loki Library by Andrei Alexandrescu et al.
+// See:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// and:
+// www.sourceforge.net/projects/loki
+//
+// Parts of the Loki Library have been used for the Itl Library.
+// Those parts from the path <itl/loki> can also be included from the
+// original Loki Library sources.
+
+#ifndef __Loki_tuple_h_JOFA_070604__
+#define __Loki_tuple_h_JOFA_070604__
+
+#include <boost/validate/loki/Typelist.h>
+#include <boost/validate/loki/TypeTraits.h>
+#include <boost/validate/loki/EmptyType.h>
+#include <boost/validate/loki_xt/TypelistGentor.h>
+
+
+namespace Loki
+{
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#pragma warning( push )
+ // 'class1' : base-class 'class2' is already a base-class of 'class3'
+#pragma warning( disable : 4584 )
+#endif // _MSC_VER
+
+ // forward
+ template <class TargetT, class SrcT> struct Sizer;
+
+ namespace tup
+ {
+ template <typename FstT, typename SndT> struct TypePair
+ {
+ typedef FstT FirstT;
+ typedef SndT SecondT;
+ };
+
+ // --------------------------------------------------------------------------
+ // template class TupleElement
+ // --------------------------------------------------------------------------
+ template <typename Type, unsigned int index>
+ struct TupleElement
+ {
+ typedef Type ValueType;
+ enum { position = index };
+ Type _value;
+ operator Type&() { return _value; }
+ operator const Type&() const { return _value; }
+ void set(Type& value){ _value = value; }
+ };
+
+ // --------------------------------------------------------------------------
+ // template class TupleGentor
+ // --------------------------------------------------------------------------
+ template <class TList, unsigned int index>
+ struct TupleGentor;
+
+ template <class HeadT, class TailT, unsigned int index>
+ struct TupleGentor<Typelist<HeadT, TailT>, index>
+ : public TupleElement<HeadT, index>
+ , public TupleGentor<TailT, index+1>
+ {
+ typedef Typelist<HeadT, TailT> TList;
+ typedef TupleElement<HeadT, index> HeadClass;
+ typedef TupleGentor<TailT, index+1> TailClass;
+ };
+
+ template <unsigned int size>
+ struct TupleGentor<NullType, size>
+ {
+ typedef NullType TList;
+ };
+ // --------------------------------------------------------------------------
+
+ // ---------------------------------------------------------------------------
+ // template class RefGetter
+ // ---------------------------------------------------------------------------
+ template <class TupleT, unsigned int idx> struct RefGetter;
+
+ template <class TupleT>
+ struct RefGetter<TupleT, 0>
+ {
+ typedef typename TupleT::HeadClass HeadClass;
+ typedef typename HeadClass::ValueType ValueType;
+
+ static ValueType& Do(TupleT& obj)
+ {
+ HeadClass& elem = obj;
+ return elem;
+ }
+ };
+
+ template <class TupleT, unsigned int idx>
+ struct RefGetter
+ {
+ typedef typename TupleT::HeadClass HeadClass;
+ typedef typename TupleT::TailClass TailClass;
+ typedef typename TL::TypeAt<typename TupleT::TList, idx>::Result ValueType;
+
+ static ValueType& Do(TupleT& obj)
+ {
+ TailClass& rightBase = obj;
+ return RefGetter<TailClass, idx-1>::Do(rightBase);
+ }
+ };
+
+ template <int i, class TupleT>
+ typename RefGetter<TupleT, i>::ValueType& refer(TupleT& obj)
+ {
+ return RefGetter<TupleT, i>::Do(obj);
+ }
+ // ---------------------------------------------------------------------------
+
+ // ---------------------------------------------------------------------------
+ // template class ValueGetter
+ // ---------------------------------------------------------------------------
+ template <class TupleT, unsigned int idx> struct ValueGetter;
+
+ template <class TupleT>
+ struct ValueGetter<TupleT, 0>
+ {
+ typedef typename TupleT::HeadClass HeadClass;
+ typedef typename HeadClass::ValueType ValueType;
+
+ static ValueType Do(const TupleT& obj)
+ {
+ const HeadClass& elem = obj;
+ return elem;
+ }
+ };
+
+ template <class TupleT, unsigned int idx>
+ struct ValueGetter
+ {
+ typedef typename TupleT::HeadClass HeadClass;
+ typedef typename TupleT::TailClass TailClass;
+ typedef typename TL::TypeAt<typename TupleT::TList, idx>::Result ValueType;
+
+ static ValueType Do(const TupleT& obj)
+ {
+ const TailClass& rightBase = obj;
+ return ValueGetter<TailClass, idx-1>::Do(rightBase);
+ }
+ };
+
+ template <int idx, class TupleT>
+ typename ValueGetter<TupleT, idx>::ValueType get(const TupleT& obj)
+ {
+ return ValueGetter<TupleT, idx>::Do(obj);
+ }
+ // ---------------------------------------------------------------------------
+
+
+
+ // ---------------------------------------------------------------------------
+ // template class Mapper
+ // ---------------------------------------------------------------------------
+ template <template<typename,typename>class Function, class TrgTupleT, class SrcTupleT>
+ struct Mapper;
+
+ template <template<typename,typename>class Function, typename TrgType, typename SrcType, unsigned int index>
+ struct Mapper<Function,
+ TupleGentor<Typelist<TrgType, NullType>, index>,
+ TupleGentor<Typelist<SrcType, NullType>, index> >
+ {
+ typedef TupleGentor<Typelist<TrgType, NullType>, index> TrgTupleT;
+ typedef TupleGentor<Typelist<SrcType, NullType>, index> SrcTupleT;
+
+ static void Do(TrgTupleT& trg, const SrcTupleT& src)
+ {
+ TrgType trgVal = Function<TrgType, SrcType>::apply(src);
+ trg.set(trgVal);
+ }
+ };
+
+
+ template <template<typename,typename>class Function, class TrgTupleT, class SrcTupleT>
+ struct Mapper
+ {
+ typedef typename TrgTupleT::HeadClass TrgHeadClass;
+ typedef typename SrcTupleT::HeadClass SrcHeadClass;
+ typedef typename TrgTupleT::TailClass TrgTailClass;
+ typedef typename SrcTupleT::TailClass SrcTailClass;
+ typedef typename TrgHeadClass::ValueType TrgType;
+ typedef typename SrcHeadClass::ValueType SrcType;
+
+ static void Do(TrgTupleT& trg, const SrcTupleT& src)
+ {
+ TrgHeadClass& trgHead = trg;
+ const SrcHeadClass& srcHead = src;
+ TrgTailClass& trgTail = trg;
+ const SrcTailClass& srcTail = src;
+ TrgType trgVal = Function<TrgType, SrcType>::apply(srcHead);
+ trgHead.set(trgVal);
+
+ Mapper<Function, TrgTailClass, SrcTailClass>::Do(trgTail, srcTail);
+ }
+ };
+
+ template <template<typename,typename>class Fun, class TrgTupleT, class SrcTupelT>
+ TrgTupleT Transform(const SrcTupelT& src)
+ {
+ TrgTupleT target;
+ Mapper<Fun, TrgTupleT, SrcTupelT>::Do(target, src);
+ return target;
+ }
+
+ // ---------------------------------------------------------------------------
+ // template class RefMapper
+ // ---------------------------------------------------------------------------
+ template <template<typename,typename>class Function, class TrgTupleT, class SrcTupleT>
+ struct RefMapper;
+
+ template <template<typename,typename>class Function, typename TrgType, typename SrcType, unsigned int index>
+ struct RefMapper<Function,
+ TupleGentor<Typelist<TrgType, NullType>, index>,
+ TupleGentor<Typelist<SrcType, NullType>, index> >
+ {
+ typedef TupleGentor<Typelist<TrgType, NullType>, index> TrgTupleT;
+ typedef TupleGentor<Typelist<SrcType, NullType>, index> SrcTupleT;
+
+ static void Do(TrgTupleT& trg, const SrcTupleT& src)
+ {
+ TrgType trgVal;
+ Function<TrgType, SrcType>::apply(trgVal, src);
+ trg.set(trgVal);
+ }
+ };
+
+ template <template<typename,typename>class Function, class TrgTupleT, class SrcTupleT>
+ struct RefMapper
+ {
+ typedef typename TrgTupleT::HeadClass TrgHeadClass;
+ typedef typename SrcTupleT::HeadClass SrcHeadClass;
+ typedef typename TrgTupleT::TailClass TrgTailClass;
+ typedef typename SrcTupleT::TailClass SrcTailClass;
+ typedef typename TrgHeadClass::ValueType TrgType;
+ typedef typename SrcHeadClass::ValueType SrcType;
+
+ static void Do(TrgTupleT& trg, const SrcTupleT& src)
+ {
+ TrgHeadClass& trgHead = trg;
+ const SrcHeadClass& srcHead = src;
+ TrgTailClass& trgTail = trg;
+ const SrcTailClass& srcTail = src;
+ TrgType trgVal;
+ Function<TrgType, SrcType>::apply(trgVal, srcHead);
+ trgHead.set(trgVal);
+
+ RefMapper<Function, TrgTailClass, SrcTailClass>::Do(trgTail, srcTail);
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ // template class TemplateMapper
+ // ---------------------------------------------------------------------------
+ template <template<class>class UnaryTpl,
+ template<typename,template<class>class> class Function,
+ class TrgTupleT, class SrcTupleT>
+ struct TemplateMapper;
+
+
+ template <template<class>class UnaryTpl, template<typename,template<class>class> class Function,
+ unsigned int index>
+ struct TemplateMapper<UnaryTpl, Function,
+ TupleGentor<NullType, index>,
+ TupleGentor<NullType, index> >
+ {
+ typedef TupleGentor<NullType, index> TrgTupleT;
+ typedef TupleGentor<NullType, index> SrcTupleT;
+ static void Do(TrgTupleT& trg, SrcTupleT& src){}
+ };
+
+
+ //JODO does not work for empty tuples!
+ template <template<class>class UnaryTpl, template<typename,template<class>class> class Function,
+ typename TrgType, unsigned int index>
+ struct TemplateMapper<UnaryTpl, Function,
+ TupleGentor<Typelist<TrgType, NullType>, index>,
+ TupleGentor<Typelist<UnaryTpl<TrgType>, NullType>, index> >
+ {
+ typedef TupleGentor<Typelist<TrgType, NullType>, index> TrgTupleT;
+ typedef TupleGentor<Typelist<UnaryTpl<TrgType>, NullType>, index> SrcTupleT;
+
+ static void Do(TrgTupleT& trg, SrcTupleT& src)
+ {
+ TrgType trgVal;
+ Function<TrgType, UnaryTpl>::apply(trgVal, src);
+ trg.set(trgVal);
+ }
+ };
+
+ template <template<class>class UnaryTpl,
+ template<typename,template<class>class>class Function,
+ class TrgTupleT, class SrcTupleT>
+ struct TemplateMapper
+ {
+ typedef typename TrgTupleT::HeadClass TrgHeadClass;
+ typedef typename SrcTupleT::HeadClass SrcHeadClass;
+ typedef typename TrgTupleT::TailClass TrgTailClass;
+ typedef typename SrcTupleT::TailClass SrcTailClass;
+ typedef typename TrgHeadClass::ValueType TrgType;
+ typedef typename SrcHeadClass::ValueType SrcType;
+
+ static void Do(TrgTupleT& trg, SrcTupleT& src)
+ {
+ TrgHeadClass& trgHead = trg;
+ SrcHeadClass& srcHead = src;
+ TrgTailClass& trgTail = trg;
+ SrcTailClass& srcTail = src;
+ TrgType trgVal;
+ Function<TrgType, UnaryTpl>::apply(trgVal, srcHead);
+ trgHead.set(trgVal);
+
+ TemplateMapper<UnaryTpl, Function, TrgTailClass, SrcTailClass>::Do(trgTail, srcTail);
+ }
+ };
+ // ---------------------------------------------------------------------------
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // helper class template Reductor
+ // See reduce below
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <class TupleT, unsigned int i> struct Reductor;
+
+ template <class TupleT>
+ struct Reductor<TupleT, 0>
+ {
+ typedef typename TupleT::TList::Head HeadType;
+
+ static HeadType Do(const TupleT& obj)
+ {
+ return get<0>(obj);
+ }
+ };
+
+ template <class TupleT, unsigned int i>
+ struct Reductor
+ {
+ typedef typename TupleT::TList::Head HeadType;
+ typedef typename TupleT::TailClass TailClass;
+
+ static HeadType Do(const TupleT& obj)
+ {
+ // Which is: first(obj) + reduce(tail(obj))
+ return get<0>(obj) + Reductor<TailClass, i-1>::Do(obj);
+ }
+ };
+
+ template <class TupleT>
+ typename Reductor<TupleT, 0>::HeadType reduce(const TupleT& obj)
+ {
+ return Reductor<typename TupleT::BaseClass,
+ TL::Length<typename TupleT::TList>::value-1>::Do(obj);
+ }
+
+ // --------------------------------------------------------------------------
+
+ template <typename TrgT, class TupleT>
+ TrgT perduce(const TupleT& obj);
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, class TupleT>
+ TrgT perduce2(const TupleT&);
+
+
+
+ // ---------------------------------------------------------------------------
+ // template class Apply
+ // ---------------------------------------------------------------------------
+ template <template<class>class UnaryTpl,
+ template<typename,template<class>class> class Function,
+ class TrgTupleT, class SrcTupleT>
+ struct Apply;
+
+
+
+ template <template<class>class UnaryTpl, template<typename,template<class>class> class Function,
+ unsigned int index>
+ struct Apply<UnaryTpl, Function,
+ TupleGentor<NullType, index>,
+ TupleGentor<NullType, index> >
+ {
+ typedef TupleGentor<NullType, index> SrcTupleT;
+
+ static void Do(SrcTupleT& src)
+ {
+ //CL? Function<TrgType, UnaryTpl>::apply(src);
+ }
+ };
+
+
+ //JODO does not work for empty tuples!
+ template <template<class>class UnaryTpl, template<typename,template<class>class> class Function,
+ typename TrgType, unsigned int index>
+ struct Apply<UnaryTpl, Function,
+ TupleGentor<Typelist<TrgType, NullType>, index>,
+ TupleGentor<Typelist<UnaryTpl<TrgType>, NullType>, index> >
+ {
+ typedef TupleGentor<Typelist<TrgType, NullType>, index> TrgTupleT;
+ typedef TupleGentor<Typelist<UnaryTpl<TrgType>, NullType>, index> SrcTupleT;
+
+ static void Do(SrcTupleT& src)
+ {
+ Function<TrgType, UnaryTpl>::apply(src);
+ }
+ };
+
+
+ template <template<class>class UnaryTpl,
+ template<typename,template<class>class>class Function,
+ class TrgTupleT, class SrcTupleT>
+ struct Apply
+ {
+ typedef typename TrgTupleT::HeadClass TrgHeadClass;
+ typedef typename SrcTupleT::HeadClass SrcHeadClass;
+ typedef typename TrgTupleT::TailClass TrgTailClass;
+ typedef typename SrcTupleT::TailClass SrcTailClass;
+ typedef typename TrgHeadClass::ValueType TrgType;
+ typedef typename SrcHeadClass::ValueType SrcType;
+
+ static void Do(SrcTupleT& src)
+ {
+ SrcHeadClass& srcHead = src;
+ SrcTailClass& srcTail = src;
+
+ Function<TrgType, UnaryTpl>::apply(srcHead);
+
+ Apply<UnaryTpl, Function, TrgTailClass, SrcTailClass>::Do(srcTail);
+ }
+ };
+
+ template <class TupleT, unsigned int i> struct Stringer;
+
+ template <class TupleT>
+ std::string Stringify(const TupleT& obj);
+
+ } // namespace tup
+
+
+ // ---------------------------------------------------------------------------
+ // template class tuple
+ // ---------------------------------------------------------------------------
+ template <typename Types> class tuple
+ : public tup::TupleGentor<Types, 0>
+ {
+ public:
+ typedef tuple<Types> SelfType;
+ typedef typename tup::TupleGentor<Types, 0> BaseClass;
+ typedef NullType HeadType;
+
+ enum { Size = TL::Length<Types>::value };
+
+ int size()const { return Size; }
+
+ template <unsigned int index>
+ typename TL::TypeAt<Types, index>::Result get()const
+ { return Loki::tup::get<index>(*this); }
+
+ std::string as_string()const { return Stringify(*this); }
+
+ //JODO Does not work for empty tuples
+ HeadType reduce()const { return tup::reduce(*this); }
+
+ template <typename TrgT>
+ TrgT perduce()const { return tup::perduce<TrgT>(*this); }
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer, typename TrgT>
+ TrgT perduce2()const { return tup::perduce2<Combi, Embracer, TrgT>(*this); }
+
+ template <template<typename,typename>class Fun, class TrgTupleT>
+ TrgTupleT map()const
+ {
+ TrgTupleT target;
+ tup::Mapper<Fun, TrgTupleT, SelfType>::Do(target, *this);
+ return target;
+ }
+
+ template <template<typename,typename>class Fun, class TrgTupleT>
+ void map(TrgTupleT& target)const
+ {
+ tup::RefMapper<Fun, TrgTupleT, SelfType>::Do(target, *this);
+ }
+
+ // Need example here to reduce abstraction pain
+ // A value generator template A generator-function-type: value generating function value-tuple-type
+ // GentorT e.g. SomeValue to be generated
+ template <template<class>class UnaryTpl, template<class TrgTupleT,template<class>class>class Fun, class TrgTupleT>
+ void map_template(TrgTupleT& target)
+ {
+ tup::TemplateMapper<UnaryTpl, Fun, TrgTupleT, SelfType>::Do(target, *this);
+ }
+
+ // --------------------------------------------------------------------
+ /*
+ template
+ <
+ template<class>class ConsumerTpl, // GentorT<TypeT>
+ template<class>class ArgumentTpl, // GentorProfileT<TypeT>
+ template<template<class>class, // to consumer GentorT<TypeT>
+ template<class>class> // apply GentorProfileT<TypeT>
+ class Consume, // using function Calibrate
+ class ArgumentTupleT, // tuple type for profile tuple value
+ class BaseTupleT // Basis value tuple type
+ >
+ void map_consumer_template(const ArgumentTupleT& arguments)
+ {
+ tup::ConsumerTemplateMapper
+ <
+ ConsumerTpl,
+ ArgumentTpl,
+ Consume,
+ ArgumentTupleT,
+ BaseTupleT,
+ SelfType
+ >
+ ::Do
+ (
+ *this, // SelfType e.g. Tuple<GentorT <T>>
+ arguments // ArgumentTupleT e.g. Tuple<GentorProfileT<T>>
+ );
+ }
+ */
+ // --------------------------------------------------------------------
+
+ template <template<class>class UnaryTpl, template<class TrgTupleT,template<class>class>class Fun, class TrgTupleT>
+ void apply()
+ {
+ tup::Apply<UnaryTpl, Fun, TrgTupleT, SelfType>::Do(*this);
+ }
+
+ /*
+ template <typename TargetType
+ template<typename,typename>class Translator,
+ template<typename>class Combinator,
+ template<typename>class Embracer>
+ TargetType transform
+ */
+
+ // This leads to a compiler breakdown with ms vc8 !!!
+ // template <unsigned int index>
+ // void set(const TL::TypeAt<Types, index>::Result& value)const
+ // { return Loki::tup::refer<index>(const_cast<tuple<Types>&> (*this)) = value; }
+ };
+
+ namespace tup
+ {
+ template<typename T0, typename T1>
+ tuple<LOKI_TYPELIST_2(T0, T1)> le(const T0& val0, const T1& val1)
+ {
+ tuple<LOKI_TYPELIST_2(T0, T1)> tup;
+ refer<0>(tup)=val0;
+ refer<1>(tup)=val1;
+ return tup;
+ }
+
+ //---------------------------------------------------------------------------
+ // template class Perductor
+ //---------------------------------------------------------------------------
+ template <typename TrgT, typename SrcT> struct Perducer;
+
+ template <typename TrgT, class TupleT, unsigned int i> struct Perductor;
+
+ template <typename TrgT, class TupleT>
+ struct Perductor<TrgT, TupleT, 0>
+ {
+ typedef typename TupleT::TList::Head HeadType;
+
+ static TrgT Do(const TupleT& obj)
+ {
+ return Perducer<TrgT, HeadType>::Do(get<0>(obj));
+ }
+ };
+
+ template <typename TrgT, class TupleT, unsigned int i>
+ struct Perductor
+ {
+ typedef typename TupleT::TList::Head HeadType;
+ typedef typename TupleT::TailClass TailClass;
+
+ static TrgT Do(const TupleT& obj)
+ {
+ // Which is: first(obj) + reduce(tail(obj))
+ return Perducer<TrgT, HeadType>::Do(get<0>(obj)) + Perductor<TrgT, TailClass, i-1>::Do(obj);
+ }
+ };
+
+
+ template <typename TrgT, class Types>
+ struct Perducer<TrgT, tuple<Types> >
+ {
+ static TrgT Do(const tuple<Types>& obj)
+ {
+ return perduce<TrgT>(obj);
+ }
+ };
+
+ template <typename TrgT, typename SrcT>
+ struct Perducer
+ {
+ static TrgT Do(const SrcT& value) { return value; }
+ };
+
+ template <typename TrgT, class TupleT>
+ TrgT perduce(const TupleT& obj)
+ {
+ return Perductor<TrgT, typename TupleT::BaseClass,
+ TL::Length<typename TupleT::TList>::value-1>::Do(obj);
+ }
+
+ //---------------------------------------------------------------------------
+ // template class Perductor2
+ // allows to specify a Combinator Combi istead of just operator+ to
+ // binary combine values for reduction
+ //---------------------------------------------------------------------------
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, typename SrcT> struct Perducer2;
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, class TupleT, unsigned int i>
+ struct Perductor2;
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, class TupleT>
+ struct Perductor2<Combi, Embracer, TrgT, TupleT, 0>
+ {
+ typedef typename TupleT::TList::Head HeadType;
+
+ static TrgT Do(const TupleT& obj)
+ {
+ return Perducer2<Combi, Embracer, TrgT, HeadType>::Do(get<0>(obj));
+ }
+ };
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, class TupleT, unsigned int i>
+ struct Perductor2
+ {
+ typedef typename TupleT::TList::Head HeadType;
+ typedef typename TupleT::TailClass TailClass;
+
+ static TrgT Do(const TupleT& obj)
+ {
+ // Which is: first(obj) + reduce(tail(obj))
+ return
+ Combi<TrgT>::Do(
+ Perducer2<Combi, Embracer, TrgT, HeadType>::Do(get<0>(obj)),
+ Perductor2<Combi, Embracer, TrgT, TailClass, i-1>::Do(obj)
+ );
+ }
+ };
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, class Types>
+ struct Perducer2<Combi, Embracer, TrgT, tuple<Types> >
+ {
+ static TrgT Do(const tuple<Types>& obj)
+ {
+ //return perduce2<Combi, Embracer, TrgT>(obj);
+ return Embracer<TrgT>::Do(perduce2<Combi, Embracer, TrgT>(obj));
+ }
+ };
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, typename SrcT>
+ struct Perducer2
+ {
+ static TrgT Do(const SrcT& value) { return value; }
+ };
+
+ template <template<typename>class Combi,
+ template<typename>class Embracer,
+ typename TrgT, class TupleT>
+ TrgT perduce2(const TupleT& obj)
+ {
+ return Perductor2<Combi, Embracer, TrgT, typename TupleT::BaseClass,
+ TL::Length<typename TupleT::TList>::value-1>::Do(obj);
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // helper class template Stringer
+ // See Stringify below
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <unsigned int i>
+ struct Stringer<tuple<NullType>, i>
+ {
+ static std::string Do(const tuple<NullType>& obj)
+ {
+ return std::string();
+ }
+ };
+
+ template <class TupleT>
+ struct Stringer<TupleT, 0>
+ {
+ typedef typename TupleT::TList::Head HeadType;
+
+ static std::string Do(const TupleT& obj)
+ {
+ return to_string<HeadType>::apply(get<0>(obj));
+ }
+ };
+
+ template <class TupleT, unsigned int i>
+ struct Stringer
+ {
+ typedef typename TupleT::TList::Head HeadType;
+ typedef typename TupleT::TailClass TailClass;
+
+ static std::string Do(const TupleT& obj)
+ {
+ return to_string<HeadType>::apply(get<0>(obj))
+ + ", " + Stringer<TailClass, i-1>::Do(obj);
+ }
+ };
+
+ template <class TupleT>
+ std::string Stringify(const TupleT& obj)
+ {
+ return
+ "("+
+ Stringer<TupleT, TL::Length<typename TupleT::TList>::value-1>::Do(obj)
+ +")";
+ }
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // helper class template Mapper
+ // See Map below
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <typename TargetT, typename SourceT> struct UnaryFunction
+ {
+ typedef TargetT (*Type)(SourceT);
+ };
+
+ template <typename TargetT, typename SourceT> struct TwiceFun
+ {
+ static TargetT apply(const SourceT& src);
+ };
+ template <>
+ struct TwiceFun<int,int>
+ {
+ static int apply(const int& src)
+ {
+ return 2*src;
+ }
+ };
+ template <>
+ struct TwiceFun<int,double>
+ {
+ static int apply(const double& src)
+ {
+ return static_cast<int>(2.0*src);
+ }
+ };
+ template <>
+ struct TwiceFun<double,double>
+ {
+ static double apply(const double& src)
+ {
+ return (2.0*src);
+ }
+ };
+
+ // --- Referential version -------------------------------------
+ template <typename TargetT, typename SourceT> struct RefTwiceFun
+ {
+ static void apply(TargetT& trg, const SourceT& src);
+ };
+ template <>
+ struct RefTwiceFun<int,int>
+ {
+ static void apply(int& trg, const int& src)
+ {
+ trg = 2*src;
+ }
+ };
+
+
+ // ---------------------------------------------------------------------------
+ // template class ToString
+ // ---------------------------------------------------------------------------
+ template <typename TargetT, typename SourceT> struct ToString
+ { static TargetT apply(const SourceT& src); };
+
+ template <typename SourceT> struct ToString<std::string, SourceT>
+ {
+ static std::string apply(const SourceT& src)
+ {
+ return itl::to_string<SourceT>::apply(src);
+ }
+ };
+ // ---------------------------------------------------------------------------
+
+
+
+ } //namespace tup
+
+
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#pragma warning( pop )
+#endif
+} // namespace Loki
+
+#endif // __Loki_tuple_h_JOFA_070604__
+
Added: sandbox/itl/boost/validate/loki_xt/TupleGentor.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki_xt/TupleGentor.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,355 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+// This code is based on and inspired by designs of:
+// The Loki Library by Andrei Alexandrescu et al.
+// See:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// and:
+// www.sourceforge.net/projects/loki
+//
+// Parts of the Loki Library have been used for the Itl Library.
+// Those parts from the path <itl/loki> can also be included from the
+// original Loki Library sources.
+
+#ifndef LOKI_TupleGentor_INC_
+#define LOKI_TupleGentor_INC_
+
+// $Id$
+
+
+#include "Typelist.h"
+#include "TypeTraits.h"
+#include "EmptyType.h"
+#include "TypelistGentor.h"
+
+#include "base/ctxreprbase.h"
+
+
+#define LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
+#include <Functor.h>
+
+
+namespace Loki
+{
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#pragma warning( push )
+ // 'class1' : base-class 'class2' is already a base-class of 'class3'
+#pragma warning( disable : 4584 )
+#endif // _MSC_VER
+
+
+
+ template <typename FstT, typename SndT> struct TypePair
+ {
+ typedef FstT FirstT;
+ typedef SndT SecondT;
+ };
+
+ template <typename Type, unsigned int index>
+ struct TupleElement
+ {
+ typedef Type ValueType;
+ enum { position = index };
+ Type _value;
+ operator Type&() { return _value; }
+ operator const Type&() const { return _value; }
+ void set(Type& value){ _value = value; }
+ };
+
+ template <class TList, unsigned int index>
+ class TupleGentor;
+
+ template <class HeadT, class TailT, unsigned int index>
+ class TupleGentor<Typelist<HeadT, TailT>, index>
+ : public TupleElement<HeadT, index>
+ , public TupleGentor<TailT, index+1>
+ {
+ public:
+ enum { Index = index };
+ typedef Typelist<HeadT, TailT> TList;
+ typedef TupleElement<HeadT, index> HeadClass;
+ typedef TupleGentor<TailT, index+1> TailClass;
+ };
+
+ template <unsigned int size>
+ class TupleGentor<NullType, size>
+ {};
+
+ // ---------------------------------------------------------------------------
+ template <typename Types> class Tupl
+ : public TupleGentor<Types, 0>
+ {
+ public:
+ typedef TupleGentor<Types, 0> BaseClass;
+ std::string as_string()const;
+ };
+
+ // ---------------------------------------------------------------------------
+ // ---------------------------------------------------------------------------
+ template <class TupleT, unsigned int idx> struct ValueGetter;
+
+ template <class TupleT>
+ struct ValueGetter<TupleT, 0>
+ {
+ typedef typename TupleT::HeadClass HeadClass;
+ typedef typename HeadClass::ValueType ValueType;
+
+ static ValueType& Do(TupleT& obj)
+ {
+ HeadClass& elem = obj;
+ return elem;
+ }
+ };
+
+ template <class TupleT, unsigned int idx>
+ struct ValueGetter
+ {
+ typedef typename TupleT::HeadClass HeadClass;
+ typedef typename TupleT::TailClass TailClass;
+ typedef typename TL::TypeAt<typename TupleT::TList, idx>::Result ValueType;
+
+ static ValueType& Do(TupleT& obj)
+ {
+ TailClass& rightBase = obj;
+ return ValueGetter<TailClass, idx-1>::Do(rightBase);
+ }
+ };
+
+ template <int i, class H>
+ typename ValueGetter<H, i>::ValueType& get(H& obj)
+ {
+ return ValueGetter<H, i>::Do(obj);
+ }
+ // ---------------------------------------------------------------------------
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // helper class template Reductor
+ // See Reduce below
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <class H, unsigned int i> struct Reductor;
+
+ template <class H>
+ struct Reductor<H, 0>
+ {
+ typedef typename H::TList::Head HeadType;
+
+ static HeadType Do(H& obj)
+ {
+ return get<0>(obj);
+ }
+ };
+
+ template <class H, unsigned int i>
+ struct Reductor
+ {
+ typedef typename H::TList::Head HeadType;
+ typedef typename H::TailClass TailClass;
+
+ static HeadType Do(H& obj)
+ {
+ // Which is: first(obj) + reduce(tail(obj))
+ return get<0>(obj) + Reductor<TailClass, i-1>::Do(obj);
+ }
+ };
+
+ template <class H>
+ typename Reductor<H, 0>::HeadType Reduce(H& obj)
+ {
+ return Reductor<H, Length<H::TList>::value-1>::Do(obj);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // helper class template Stringer
+ // See Reduce below
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <class H, unsigned int i> struct Stringer;
+
+
+ template <class H>
+ struct Stringer<H, 0>
+ {
+ typedef typename H::TList::Head HeadType;
+
+ static std::string Do(H& obj)
+ {
+ return itl::value<HeadType>::to_string(get<0>(obj));
+ }
+ };
+
+ template <class H, unsigned int i>
+ struct Stringer
+ {
+ typedef typename H::TList::Head HeadType;
+ typedef typename H::TailClass TailClass;
+
+ static std::string Do(H& obj)
+ {
+ return itl::value<HeadType>::to_string(get<0>(obj))
+ + ", " + Stringer<TailClass, i-1>::Do(obj);
+ }
+ };
+
+ template <class H>
+ typename std::string Stringify(H& obj)
+ {
+ return "("+Stringer<H, Length<H::TList>::value-1>::Do(obj)+")";
+ }
+
+ template <typename Types>
+ std::string Tupl<Types>::as_string()const
+ {
+ //JODO In order to work with const selector functions I need to
+ // implement a const ValueGetter version
+ return Stringify(const_cast<Tupl<Types>&>(*this));
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // helper class template Mapper
+ // See Map below
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <typename TargetT, typename SourceT> struct UnaryFunction
+ {
+ typedef typename TargetT (*Type)(SourceT);
+ };
+
+ template <typename TargetT, typename SourceT> struct TwiceFun
+ {
+ static TargetT apply(const SourceT& src);
+ };
+ template <>
+ struct TwiceFun<int,int>
+ {
+ static int apply(const int& src)
+ {
+ return 2*src;
+ }
+ };
+ template <>
+ struct TwiceFun<int,double>
+ {
+ static int apply(const double& src)
+ {
+ return static_cast<int>(2.0*src);
+ }
+ };
+ template <>
+ struct TwiceFun<double,double>
+ {
+ static double apply(const double& src)
+ {
+ return (2.0*src);
+ }
+ };
+
+ // ---------------------------------------------------------------------------
+ // template class ToString
+ // ---------------------------------------------------------------------------
+ template <typename TargetT, typename SourceT> struct ToString
+ { static TargetT apply(const SourceT& src); };
+
+ template <typename SourceT> struct ToString<std::string, SourceT>
+ {
+ static std::string apply(const SourceT& src)
+ {
+ return itl::value<SourceT>::to_string(src);
+ }
+ };
+
+
+ // ---------------------------------------------------------------------------
+ // template class Mapper
+ // ---------------------------------------------------------------------------
+ template <template<typename,typename>class Function, class TrgTupleT, class SrcTupleT>
+ struct Mapper;
+
+ template <template<typename,typename>class Function, typename TrgType, typename SrcType, unsigned int index>
+ struct Mapper<Function,
+ TupleGentor<Typelist<TrgType, NullType>, index>,
+ TupleGentor<Typelist<SrcType, NullType>, index> >
+ {
+ typedef typename TupleGentor<Typelist<TrgType, NullType>, index> TrgTupleT;
+ typedef typename TupleGentor<Typelist<SrcType, NullType>, index> SrcTupleT;
+
+ static void Do(TrgTupleT& trg, const SrcTupleT& src)
+ {
+ TrgType trgVal = Function<TrgType, SrcType>::apply(src);
+ trg.set(trgVal);
+ }
+ };
+
+
+ template <template<typename,typename>class Function, class TrgTupleT, class SrcTupleT>
+ struct Mapper
+ {
+ typedef typename TrgTupleT::HeadClass TrgHeadClass;
+ typedef typename SrcTupleT::HeadClass SrcHeadClass;
+ typedef typename TrgTupleT::TailClass TrgTailClass;
+ typedef typename SrcTupleT::TailClass SrcTailClass;
+ typedef typename TrgHeadClass::ValueType TrgType;
+ typedef typename SrcHeadClass::ValueType SrcType;
+
+ static void Do(TrgTupleT& trg, const SrcTupleT& src)
+ {
+ TrgHeadClass& trgHead = trg;
+ const SrcHeadClass& srcHead = src;
+ TrgTailClass& trgTail = trg;
+ const SrcTailClass& srcTail = src;
+ TrgType trgVal = Function<TrgType, SrcType>::apply(srcHead);
+ trgHead.set(trgVal);
+
+ Mapper<Function, TrgTailClass, SrcTailClass>::Do(trgTail, srcTail);
+ }
+ };
+
+ template <template<typename,typename>class Fun, class TrgTupelT, class SrcTupelT>
+ TrgTupelT Transform(const SrcTupelT& src)
+ {
+ TrgTupelT target;
+ Mapper<Fun, TrgTupelT, SrcTupelT>::Do(target, src);
+ return target;
+ }
+
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ // ---------------------------------------------------------------------------
+ // ---------------------------------------------------------------------------
+
+
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#pragma warning( pop )
+#endif
+} // namespace Loki
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/loki_xt/TypelistGentor.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/loki_xt/TypelistGentor.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,140 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+// This code is based on and inspired by designs of:
+// The Loki Library by Andrei Alexandrescu et al.
+// See:
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
+// and:
+// www.sourceforge.net/projects/loki
+//
+// Parts of the Loki Library have been used for the Itl Library.
+// Those parts from the path <itl/loki> can also be included from the
+// original Loki Library sources.
+
+#ifndef LOKI_TypelistGentor_INC_
+#define LOKI_TypelistGentor_INC_
+
+// $Id$
+
+
+#include <boost/validate/loki/Typelist.h>
+#include <boost/validate/loki/TypeTraits.h>
+#include <boost/validate/loki/EmptyType.h>
+
+
+namespace Loki
+{
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#pragma warning( push )
+ // 'class1' : base-class 'class2' is already a base-class of 'class3'
+#pragma warning( disable : 4584 )
+#endif // _MSC_VER
+
+ //JODO This should be integrated into Typelist.h
+ namespace TL
+ {
+ template <class TList1, class TList2> struct StrictEquality;
+
+ template<>
+ struct StrictEquality<NullType, NullType>
+ {
+ enum { Result = true };
+ };
+
+ template<typename Head1>
+ struct StrictEquality<Typelist<Head1, NullType>, NullType>
+ {
+ enum { Result = false };
+ };
+
+ template<typename Head2>
+ struct StrictEquality<NullType, Typelist<Head2, NullType> >
+ {
+ enum { Result = false };
+ };
+
+ template<typename Head, class Tail1, class Tail2>
+ struct StrictEquality<Typelist<Head, Tail1>, Typelist<Head, Tail2> >
+ {
+ enum { Result = StrictEquality<Tail1, Tail2>::Result };
+ };
+
+ template<typename Head1, class Tail1, typename Head2, class Tail2>
+ struct StrictEquality<Typelist<Head1, Tail1>, Typelist<Head2, Tail2> >
+ {
+ // Does only match if Head1 is unequal to Head2
+ enum { Result = false };
+ };
+
+ // --------------------------------------------------------------------
+ // JODO Extension for Typelist:
+ // class template MapType
+ // MapType(F, Typelist<T1,...,Tn>) = Typelist<F<T1>,...,F<Tn> >
+ // --------------------------------------------------------------------
+ template<template<typename TypeT>class UnaryTemplate, typename Typelist>
+ struct MapType;
+
+ template<template<typename TypeT>class UnaryTemplate>
+ struct MapType<UnaryTemplate, NullType>
+ {
+ typedef NullType Result;
+ };
+
+ template<template<typename TypeT>class UnaryTemplate, class Head, class Tail>
+ struct MapType<UnaryTemplate, Typelist<Head, Tail> >
+ {
+ typedef Typelist<UnaryTemplate<Head>, typename MapType<UnaryTemplate, Tail>::Result> Result;
+ };
+
+ }
+
+ /* class template GenTypeList. It serves to generate homogenious
+ Typelists of a given size. */
+ template <class T, unsigned int size> struct GenTypeList;
+
+ template <class T>
+ struct GenTypeList<T, 0>
+ {
+ typedef NullType Result;
+ };
+
+ template <class T, unsigned int size>
+ struct GenTypeList
+ {
+ typedef Typelist<T, typename GenTypeList<T, size-1>::Result > Result;
+ };
+
+
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+#pragma warning( pop )
+#endif
+} // namespace Loki
+
+#endif // end file guardian
+
Added: sandbox/itl/boost/validate/realmvalidater.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/realmvalidater.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,342 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#pragma once
+
+#include <iostream>
+#include <stdio.h>
+#include <time.h>
+#include <boost/validate/typevalidater.h>
+
+#define ITL_LOCATION(message) location(__FILE__,__LINE__,message)
+
+namespace boost{namespace itl
+{
+ std::string location(const std::string& file, int line, const std::string& message)
+ {
+ std::string result = file;
+ result += "(" + to_string<int>::apply(line) + "): ";
+ result += message;
+ return result;
+ }
+
+ namespace RootType
+ {
+ enum RootTypes
+ {
+ itl_set, interval_set, separate_interval_set, split_interval_set,
+ itl_map, interval_map, split_interval_map,
+ Types_size
+ };
+ }
+
+ namespace DomainType
+ {
+ enum DomainTypes { Int, Double, DomainTypes_size };
+ }
+
+ namespace CodomainType
+ {
+ enum CodomainTypes { Int, Double, set_int, CodomainTypes_size };
+ }
+
+
+ class RealmValidater
+ {
+ public:
+ RealmValidater() { setProfile(); }
+
+ private:
+ void setRootTypeNames()
+ {
+ std::vector<std::string> type_names(RootType::Types_size);
+ type_names[RootType::itl_set] = "itl_set";
+ type_names[RootType::interval_set] = "interval_set";
+ type_names[RootType::separate_interval_set] = "separate_interval_set";
+ type_names[RootType::split_interval_set] = "split_interval_set";
+ type_names[RootType::itl_map] = "itl_map";
+ type_names[RootType::interval_map] = "interval_map";
+ type_names[RootType::split_interval_map] = "split_interval_map";
+ _rootChoice.setTypeNames(type_names);
+ }
+ void setDomainTypeNames()
+ {
+ std::vector<std::string> type_names(CodomainType::CodomainTypes_size);
+ type_names[CodomainType::Int] = "Int";
+ type_names[CodomainType::Double] = "Double";
+ _domainChoice.setTypeNames(type_names);
+ }
+ void setCodomainTypeNames()
+ {
+ std::vector<std::string> type_names(CodomainType::CodomainTypes_size);
+ type_names[CodomainType::Int] = "Int";
+ type_names[CodomainType::Double] = "Double";
+ type_names[CodomainType::set_int] = "set_int";
+ _codomainChoice.setTypeNames(type_names);
+ }
+
+ void setInvalid() { _isValid = false; }
+
+ AlgebraValidater* choiceError(const std::string& location, int value, const ChoiceT& choice)
+ {
+ reportTypeChoiceError(location, value, choice);
+ setInvalid();
+ return NULL;
+ }
+
+ public:
+ bool hasValidProfile()const { return _isValid; }
+
+ void setProfile()
+ {
+ _isValid = true;
+ _rootChoice.setSize(RootType::Types_size);
+ _rootChoice.setMaxWeights(100);
+ _rootChoice[RootType::itl_set] = 14;
+ _rootChoice[RootType::interval_set] = 14;
+ _rootChoice[RootType::separate_interval_set] = 14;
+ _rootChoice[RootType::split_interval_set] = 14;
+ _rootChoice[RootType::itl_map] = 14;
+ _rootChoice[RootType::interval_map] = 15;
+ _rootChoice[RootType::split_interval_map] = 15;
+ setRootTypeNames();
+ _rootChoice.init();
+
+ _domainChoice.setSize(DomainType::DomainTypes_size);
+ _domainChoice.setMaxWeights(100);
+ _domainChoice[DomainType::Int] = 50;
+ _domainChoice[DomainType::Double] = 50;
+ setDomainTypeNames();
+ _domainChoice.init();
+
+ _codomainChoice.setSize(CodomainType::CodomainTypes_size);
+ _codomainChoice.setMaxWeights(100);
+ _codomainChoice[CodomainType::Int] = 50;
+ _codomainChoice[CodomainType::Double] = 0;
+ _codomainChoice[CodomainType::set_int] = 50;
+ setCodomainTypeNames();
+ _codomainChoice.init();
+
+ if(!_rootChoice.is_consistent())
+ {
+ setInvalid();
+ std::cout << _rootChoice.inconsitencyMessage("RealmValidater::setProfile()") << std::endl;
+ }
+
+ if(!_domainChoice.is_consistent())
+ {
+ setInvalid();
+ std::cout << _domainChoice.inconsitencyMessage("RealmValidater::setProfile()") << std::endl;
+ }
+
+ if(!_codomainChoice.is_consistent())
+ {
+ setInvalid();
+ std::cout << _codomainChoice.inconsitencyMessage("RealmValidater::setProfile()") << std::endl;
+ }
+
+ }
+
+ void validate()
+ {
+ srand(static_cast<unsigned>(time(NULL))); //Different numbers each run
+ //srand(static_cast<unsigned>(1)); //Same numbers each run (std)
+ //srand(static_cast<unsigned>(4711)); //Same numbers each run (varying)
+
+ for(int idx=0; hasValidProfile(); idx++)
+ {
+ if(idx>0 && idx % 100 == 0)
+ reportFrequencies();
+ validateType();
+ }
+ }
+
+ AlgebraValidater* chooseValidater()
+ {
+ int rootChoice = _rootChoice.some();
+ int domainChoice = _domainChoice.some();
+ int codomainChoice = _codomainChoice.some();
+
+ switch(rootChoice)
+ {
+ case RootType::itl_set: {
+ switch(domainChoice) {
+ case DomainType::Int: return new InplaceSetValidater<itl::set<int> >;
+ case DomainType::Double: return new InplaceSetValidater<itl::set<double> >;
+ default: return choiceError(ITL_LOCATION("\nRootType::itl_set: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }
+ }
+ case RootType::interval_set: {
+ switch(domainChoice) {
+ case DomainType::Int: return new IntervalSetValidater<interval_set<int> >;
+ case DomainType::Double: return new InplaceSetValidater<interval_set<double> >;
+ default: return choiceError(ITL_LOCATION("\nRootType::interval_set: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }
+ }
+ case RootType::separate_interval_set: {
+ switch(domainChoice) {
+ case DomainType::Int: return new IntervalSetValidater<split_interval_set<int> >;
+ case DomainType::Double: return new IntervalSetValidater<split_interval_set<double> >;
+ default: return choiceError(ITL_LOCATION("\nRootType::separate_interval_set: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }
+ }
+ case RootType::split_interval_set: {
+ switch(domainChoice) {
+ case DomainType::Int: return new IntervalSetValidater<split_interval_set<int> >;
+ case DomainType::Double: return new IntervalSetValidater<split_interval_set<double> >;
+ default: return choiceError(ITL_LOCATION("\nRootType::split_interval_set: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }
+ }
+ //-----------------------------------------------------------------
+ case RootType::itl_map: {
+ switch(domainChoice) {
+ case DomainType::Int:
+ switch(codomainChoice) {
+ // than enricher maps have.
+ case CodomainType::Int: return new InplaceMapValidater<itl::map<int,int,neutron_enricher> >;
+ //case CodomainType::Double: return new InplaceMapValidater<itl::map<int,double,neutron_enricher> >;
+ case CodomainType::set_int: return new InplaceMapValidater<itl::map<int,itl::set<int> > >;
+ default: return choiceError(ITL_LOCATION("\nRootType::itl_map: codomainChoice:\n"),
+ codomainChoice, _codomainChoice);
+ }//switch codomain
+
+ case DomainType::Double:
+ switch(codomainChoice) {
+ case CodomainType::Int: return new InplaceMapValidater<itl::map<double,int,neutron_enricher> >;
+ //case CodomainType::Double: return new InplaceMapValidater<itl::map<double,double,neutron_enricher> >;
+ case CodomainType::set_int: return new InplaceMapValidater<itl::map<double,itl::set<int> > >;
+ default: return choiceError(ITL_LOCATION("\nRootType::itl_map: codomainChoice:\n"),
+ codomainChoice, _codomainChoice);
+ }//switch codomain
+
+ default: return choiceError(ITL_LOCATION("\nRootType::itl_map: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }//switch domain
+ }//case itl_map
+ //-----------------------------------------------------------------
+ case RootType::interval_map: {
+ switch(domainChoice) {
+ case DomainType::Int:
+ switch(codomainChoice) {
+ //JODO SectionAbsorbtion has to be tested for all absorber maps
+ case CodomainType::Int: return new IntervalMapValidater<interval_map<int,int,neutron_enricher> >;
+ //case CodomainType::Double: return new IntervalMapValidater<interval_map<int,double,neutron_enricher> >;
+ case CodomainType::set_int: return new IntervalMapValidater<interval_map<int,itl::set<int> > >;
+ default: return choiceError(ITL_LOCATION("\nRootType::interval_map: codomainChoice:\n"),
+ codomainChoice, _codomainChoice);
+ }// switch codomain
+ case DomainType::Double:
+ switch(codomainChoice) {
+ case CodomainType::Int: return new IntervalMapValidater<interval_map<double,int,neutron_enricher> >;
+ //case CodomainType::Double: return new IntervalMapValidater<interval_map<double,double,neutron_enricher> >;
+ case CodomainType::set_int: return new IntervalMapValidater<interval_map<double,itl::set<int> > >;
+ default: return choiceError(ITL_LOCATION("\nRootType::interval_map: codomainChoice:\n"),
+ codomainChoice, _codomainChoice);
+ }// switch codomain
+ default: return choiceError(ITL_LOCATION("\nRootType::interval_map: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }//switch domain
+ }//case interval_map
+ //-----------------------------------------------------------------
+ case RootType::split_interval_map: {
+ switch(domainChoice) {
+ case DomainType::Int:
+ switch(codomainChoice) {
+ case CodomainType::Int: return new IntervalMapValidater<split_interval_map<int,int,neutron_enricher> >;
+ //case CodomainType::Double: return new IntervalMapValidater<split_interval_map<int,double,neutron_enricher> >;
+ case CodomainType::set_int: return new IntervalMapValidater<split_interval_map<int,itl::set<int> > >;
+ default: return choiceError(ITL_LOCATION("\nRootType::split_interval_map: codomainChoice:\n"),
+ codomainChoice, _codomainChoice);
+ }
+ case DomainType::Double:
+ switch(codomainChoice) {
+ case CodomainType::Int: return new IntervalMapValidater<split_interval_map<double,int,neutron_enricher> >;
+ //case CodomainType::Double: return new IntervalMapValidater<split_interval_map<double,double,neutron_enricher> >;
+ case CodomainType::set_int: return new IntervalMapValidater<split_interval_map<double,itl::set<int> > >;
+ default: return choiceError(ITL_LOCATION("\nRootType::split_interval_map: codomainChoice:\n"),
+ codomainChoice, _codomainChoice);
+ }
+ default: return choiceError(ITL_LOCATION("\nRootType::split_interval_map: domainChoice:\n"),
+ domainChoice, _domainChoice);
+ }//switch domain
+ }//case split_interval_map
+ //-----------------------------------------------------------------
+
+ default: return choiceError(ITL_LOCATION("rootChoice:\n"), rootChoice, _rootChoice);
+ } //switch()
+
+ return NULL; //just to please the compiler ;)
+ }
+
+
+ void validateType()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->validate();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void reportFrequencies()
+ {
+ std::cout << "------------------------------------------------------------------------------" << std::endl;
+ int valid_count = 1;
+ FORALL(ValidationCounterT, it, _frequencies)
+ {
+ printf("%3d %-66s%8d\n", valid_count, it->KEY_VALUE.c_str(), it->CONT_VALUE);
+ valid_count++;
+ }
+ std::cout << "------------------------------------------------------------------------------" << std::endl;
+ int violation_count = 1;
+ FORALL(ViolationMapT, it, _violations)
+ {
+ printf("%3d %-66s%8d\n", violation_count, it->KEY_VALUE.c_str(), it->CONT_VALUE.getViolationsCount());
+ violation_count++;
+ }
+ if(!_violations.empty())
+ std::cout << "------------------------------------------------------------------------------" << std::endl;
+ FORALL(ViolationMapT, it, _violations)
+ {
+ PolyLawViolations violas = it->CONT_VALUE;
+ violas.reportFirst();
+ }
+ if(!_violations.empty())
+ std::cout << "------------------------------------------------------------------------------" << std::endl;
+ }
+
+ void reportTypeChoiceError(const std::string& location, int rootChoice, const ChoiceT& chooser)const
+ {
+ std::cout << location
+ << "Type choice: " << rootChoice << " is out of range or unselectable in switch clause.\n"
+ << "Expected types and their weights are:\n"
+ << chooser.asString();
+ }
+
+ private:
+ ChoiceT _rootChoice;
+ ChoiceT _domainChoice;
+ ChoiceT _codomainChoice;
+ AlgebraValidater* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ bool _isValid;
+ };
+
+
+}} // namespace itl boost
+
Added: sandbox/itl/boost/validate/typevalidater.h
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/validate/typevalidater.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,746 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#pragma once
+
+#include <boost/itl/type_traits/is_continuous.hpp>
+#include <boost/itl/functors.hpp>
+#include <boost/itl/interval_morphism.hpp>
+#include <boost/validate/laws/set_laws.h>
+#include <boost/validate/laws/order.h>
+#include <boost/validate/laws/pushouts.h>
+#include <boost/validate/lawvalidater.h>
+
+namespace boost{namespace itl
+{
+ typedef WeightedNumberGentor<int> ChoiceT;
+
+ class AlgebraValidater
+ {
+ public:
+ virtual ~AlgebraValidater(){}
+ // 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.
+ virtual void setProfile()=0;
+ virtual void validate()=0;
+ virtual void addFrequencies(ValidationCounterT&)=0;
+ virtual void addViolations(ViolationCounterT&, ViolationMapT&)=0;
+
+ virtual bool hasValidProfile()const{ return true; }
+ };
+
+
+ // ------------------------------------------------------------------------
+ // Orderings
+ // ------------------------------------------------------------------------
+
+ template <typename Type, template<class>class Relation>
+ class StrictWeakOrderValidater : public AlgebraValidater
+ {
+ public:
+ enum Laws
+ {
+ transitivity,
+ antisymmetry2,
+ irreflexivity,
+ Laws_size
+ };
+
+ StrictWeakOrderValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[transitivity] = 33;
+ _lawChoice[antisymmetry2] = 33;
+ _lawChoice[irreflexivity] = 34;
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case transitivity: return new LawValidater<Transitivity <Type, Relation >, RandomGentor >;
+ case antisymmetry2: return new LawValidater<Antisymmetry2<Type, Relation >, RandomGentor >;
+ case irreflexivity: return new LawValidater<Irreflexivity<Type, Relation >, RandomGentor >;
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ }; //class AlgebraValidater
+
+
+ // ------------------------------------------------------------------------
+
+ template <typename Type, template<class>class Relation>
+ class PartialOrderValidater : public AlgebraValidater
+ {
+ public:
+ enum Laws
+ {
+ transitivity,
+ antisymmetry,
+ reflexivity,
+ Laws_size
+ };
+
+ PartialOrderValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[transitivity] = 33;
+ _lawChoice[antisymmetry] = 33;
+ _lawChoice[reflexivity] = 34;
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case transitivity: return new LawValidater<Transitivity<Type, Relation>, RandomGentor>;
+ case antisymmetry: return new LawValidater<Antisymmetry<Type, Relation>, RandomGentor>;
+ case reflexivity: return new LawValidater<Reflexivity <Type, Relation>, RandomGentor>;
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ };
+
+
+ // ------------------------------------------------------------------------
+ // Monoids
+ // ------------------------------------------------------------------------
+ /*JODO currently not used, incomplete.
+ template <typename Type>
+ class InplaceCommutativeMonoidValidater : public AlgebraValidater
+ {
+ public:
+ enum Laws
+ {
+ inplacePlusAssociativity, // EA semigroup
+ inplacePlusNeutrality, // EAN monoid
+ inplacePlusCommutativity, // EANC commutative monoid
+ Laws_size
+ };
+
+ InplaceCommutativeMonoidValidater(){setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[inplacePlusAssociativity] = 33;
+ _lawChoice[inplacePlusNeutrality] = 33;
+ _lawChoice[inplacePlusCommutativity] = 34;
+ _lawChoice.init();
+ }
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case inplacePlusNeutrality: return new LawValidater<InplaceNeutrality<Type>, RandomGentor>;
+ case inplacePlusCommutativity: return new LawValidater<InplaceCommutativity<Type>, RandomGentor>;
+ case inplacePlusAssociativity: return new LawValidater<InplaceAssociativity<Type>, RandomGentor>;
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ };
+ */
+
+
+ template <typename Type>
+ class InplaceSetBaseValidater : public AlgebraValidater
+ {
+ public:
+ typedef StrictWeakOrderValidater<Type, std::less> LessValidaterT;
+ typedef PartialOrderValidater<Type, std::less_equal> LessEqualValidaterT;
+ typedef PartialOrderValidater<Type, itl::contained_in> ContainedInValidaterT;
+
+ enum Laws
+ {
+ strictWeakStdOrder,
+ partialStdOrder,
+ containedInOrder,
+ inplacePlusAssociativity,
+ inplacePlusNeutrality,
+ inplacePlusCommutativity,
+ inplaceStarAssociativity,
+ inplaceStarCommutativity,
+ Laws_size
+ };
+
+ InplaceSetBaseValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[strictWeakStdOrder] = 19;
+ _lawChoice[partialStdOrder] = 18;
+ _lawChoice[containedInOrder] = 18;
+ _lawChoice[inplacePlusAssociativity] = 9;
+ _lawChoice[inplacePlusNeutrality] = 9;
+ _lawChoice[inplacePlusCommutativity] = 9;
+ _lawChoice[inplaceStarAssociativity] = 9;
+ _lawChoice[inplaceStarCommutativity] = 9;
+ //JODO _lawChoice[inplaceSymmetricDifference] = 10; // only (map|cop)<set> NOT (map|cop)<group>
+ //JODO _lawChoice[inplacePlusDistributivity] = 100; // only (map|cop)<set> NOT (map|cop)<group>
+ //JODO _lawChoice[inplaceStarDistributivity] = 100; // only (map|cop)<set> NOT (map|cop)<group>
+ //JODO _lawChoice[inplacePlusDeMorgan] = 100; // only (map|cop)<set> NOT (map|cop)<group>
+ //JODO _lawChoice[inplaceStarDeMorgan] = 100; // only (map|cop)<set> NOT (map|cop)<group>
+ //JODO _lawChoice[inplaceUnionInvertability] = 25; // only cop NOT map
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case strictWeakStdOrder: return _lessValidater.chooseValidater();
+ case partialStdOrder: return _lessEqualValidater.chooseValidater();
+ case containedInOrder: return _containedInValidater.chooseValidater();
+ case inplacePlusAssociativity:
+ if( itl::is_interval_container<Type>::value && itl::is_interval_splitter<Type>::value
+ && is_neutron_absorber<Type>::value && is_neutron_emitter<Type>::value)
+ return new LawValidater<InplaceAssociativity<Type, inplace_plus, element_equal>, RandomGentor>;
+ else
+ return new LawValidater<InplaceAssociativity<Type>, RandomGentor>;
+ case inplacePlusNeutrality: return new LawValidater<InplaceNeutrality<Type>, RandomGentor>;
+ case inplacePlusCommutativity: return new LawValidater<InplaceCommutativity<Type>, RandomGentor>;
+ case inplaceStarAssociativity:
+ if( is_interval_container<Type>::value && is_interval_splitter<Type>::value
+ && is_neutron_absorber<Type>::value && is_neutron_emitter<Type>::value)
+ return new LawValidater<InplaceAssociativity<Type, inplace_star, element_equal>, RandomGentor>;
+ else
+ return new LawValidater<InplaceAssociativity<Type, inplace_star>, RandomGentor>;
+ case inplaceStarCommutativity: return new LawValidater<InplaceCommutativity<Type, inplace_star>, RandomGentor>;
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+
+ LessValidaterT _lessValidater;
+ LessEqualValidaterT _lessEqualValidater;
+ ContainedInValidaterT _containedInValidater;
+ };
+
+
+
+ template <typename Type>
+ class InplaceMapValidater : public InplaceSetBaseValidater<Type>
+ {
+ public:
+ enum Laws
+ {
+ inplaceSetBaseLaws,
+ inplaceSymmetricDifference,
+ inplaceUnionInvertability,
+ sectionAbsorbtion,
+ Laws_size
+ };
+
+ InplaceMapValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[inplaceSetBaseLaws] = 85;
+ if(Type::has_symmetric_difference())
+ {
+ _lawChoice[inplaceSymmetricDifference] = 5;
+ _lawChoice[inplaceUnionInvertability] = 5;
+ _lawChoice[sectionAbsorbtion] = 5;
+ }
+ else
+ {
+ _lawChoice[inplaceSymmetricDifference] = 0;
+ _lawChoice[inplaceUnionInvertability] = 7;
+ _lawChoice[sectionAbsorbtion] = 8;
+ }
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case inplaceSetBaseLaws:
+ return InplaceSetBaseValidater<Type>::chooseValidater();
+ case inplaceSymmetricDifference:
+ return new LawValidater<InplaceSymmetricDifference<Type>, RandomGentor>;
+ case inplaceUnionInvertability:
+ return new LawValidater<InplaceUnionInvertability<Type,itl::protonic_equal>, RandomGentor >;
+ case sectionAbsorbtion:
+ return new LawValidater<SectionAbsorbtion<Type,itl::protonic_equal>, RandomGentor>;
+ default:
+ return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ };
+
+
+ template <typename Type>
+ class InplaceSetValidater : public InplaceSetBaseValidater<Type>
+ {
+ public:
+ enum Laws
+ {
+ inplaceSetBaseLaws,
+ inplaceSymmetricDifference,
+ inplaceUnionInvertability,
+ inplacePlusDistributivity,
+ inplaceStarDistributivity,
+ inplacePlusDashRightDistrib,
+ inplaceStarDashRightDistrib,
+ inplacePlusDeMorgan,
+ inplaceStarDeMorgan,
+ Laws_size
+ };
+
+ InplaceSetValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[inplaceSetBaseLaws] = 44;
+ _lawChoice[inplaceSymmetricDifference] = 7;
+ _lawChoice[inplaceUnionInvertability] = 7;
+ _lawChoice[inplacePlusDistributivity] = 7;
+ _lawChoice[inplaceStarDistributivity] = 7;
+ _lawChoice[inplacePlusDashRightDistrib] = 7;
+ _lawChoice[inplaceStarDashRightDistrib] = 7;
+ _lawChoice[inplacePlusDeMorgan] = 7;
+ _lawChoice[inplaceStarDeMorgan] = 7;
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case inplaceSetBaseLaws: return InplaceSetBaseValidater<Type>::chooseValidater();
+ case inplaceSymmetricDifference: return new LawValidater<InplaceSymmetricDifference<Type>, RandomGentor>;
+ case inplaceUnionInvertability: return new LawValidater<InplaceUnionInvertability<Type>, RandomGentor>;
+ case inplacePlusDistributivity: return new LawValidater<InplaceDistributivity<Type, inplace_plus, inplace_star, itl::element_equal>, RandomGentor>;
+ case inplaceStarDistributivity: return new LawValidater<InplaceDistributivity<Type, inplace_star, inplace_plus>, RandomGentor>;
+ case inplacePlusDashRightDistrib:return new LawValidater<InplaceRightDistributivity<Type, inplace_plus, inplace_minus>, RandomGentor>;
+ case inplaceStarDashRightDistrib:return new LawValidater<InplaceRightDistributivity<Type, inplace_star, inplace_minus>, RandomGentor>;
+ case inplacePlusDeMorgan: return new LawValidater<InplaceDeMorgan<Type, inplace_plus, inplace_star, itl::element_equal>, RandomGentor>;
+ case inplaceStarDeMorgan: return new LawValidater<InplaceDeMorgan<Type, inplace_star, inplace_plus, itl::element_equal>, RandomGentor>;
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ };
+
+
+ template <typename Type>
+ class IntervalMorphicValidater : public AlgebraValidater
+ {
+ public:
+ enum Laws
+ {
+ atomize_plus,
+ atomize_minus,
+ atomize_star,
+ cluster_plus,
+ cluster_minus,
+ cluster_star,
+ atomize_insert,
+ atomize_erase,
+ cluster_insert,
+ cluster_erase,
+ join_plus,
+ absorb_plus,
+ Laws_size
+ };
+
+ IntervalMorphicValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ _lawChoice[atomize_plus] = 10;
+ _lawChoice[atomize_minus] = 5;
+ _lawChoice[atomize_star] = 5;
+ _lawChoice[cluster_plus] = 10;
+ _lawChoice[cluster_minus] = 5;
+ _lawChoice[cluster_star] = 5;
+ _lawChoice[atomize_insert] = 10;
+ _lawChoice[atomize_erase] = 10;
+ _lawChoice[cluster_insert] = 10;
+ _lawChoice[cluster_erase] = 20;
+ _lawChoice[join_plus] = 10;
+ _lawChoice[absorb_plus] = 0;
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case atomize_plus:
+ return new LawValidater
+ <
+ BinaryPushout
+ <
+ Type,
+ typename Type::atomized_type,
+ Interval::Atomize,
+ inplace_plus
+ >,
+ RandomGentor
+ >();
+ case atomize_minus: return new LawValidater<BinaryPushout<Type, typename Type::atomized_type, Interval::Atomize, inplace_minus>, RandomGentor>();
+ case atomize_star: return new LawValidater<BinaryPushout<Type, typename Type::atomized_type, Interval::Atomize, inplace_star>, RandomGentor>();
+ case cluster_plus: return new LawValidater<BinaryPushout<typename Type::atomized_type, Type, Interval::Cluster, inplace_plus>, RandomGentor>();
+ case cluster_minus: return new LawValidater<BinaryPushout<typename Type::atomized_type, Type, Interval::Cluster, inplace_minus>, RandomGentor>();
+ case cluster_star: return new LawValidater<BinaryPushout<typename Type::atomized_type, Type, Interval::Cluster, inplace_star>, RandomGentor>();
+ case atomize_insert: return new LawValidater<BinaryPushout<Type, typename Type::atomized_type, Interval::Atomize, inserter>, RandomGentor>();
+ case atomize_erase: return new LawValidater<BinaryPushout<Type, typename Type::atomized_type, Interval::Atomize, eraser>, RandomGentor>();
+ case cluster_insert: return new LawValidater<BinaryPushout<typename Type::atomized_type, Type, Interval::Cluster, inserter>, RandomGentor>();
+ case cluster_erase: return new LawValidater<BinaryPushout<typename Type::atomized_type, Type, Interval::Cluster, eraser>, RandomGentor>();
+ case join_plus: return new LawValidater<BinaryPushout<Type, typename Type::joint_type, Interval::Join, inplace_plus>, RandomGentor>();
+ //JODO absorb_plus holds for interval_map. For split_interval_map element_equal has to be used as equality-relation.
+ //case absorb_plus: return new LawValidater<BinaryPushout<Type, typename Type::neutron_absorber_type, Interval::AbsorbNeutrons, inplace_plus>, RandomGentor>();
+ //JODO doc: violated: inverse required: case absorb_minus: return new LawValidater<BinaryPushout<Type, typename Type::neutron_absorber_type, Interval::AbsorbNeutrons, inplace_minus>, RandomGentor>();
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+ private:
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ };
+
+
+ template <typename Type>
+ class IntervalSetValidater : public InplaceSetValidater<Type>
+ {
+ public:
+ enum Laws
+ {
+ inplaceSetLaws,
+ homomorphismLaws,
+ Laws_size
+ };
+
+ IntervalSetValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ const bool morphism_exists = !is_continuous<typename Type::domain_type>::value;
+ const int morphism_share = 15;
+ _lawChoice[inplaceSetLaws] = morphism_exists ? 100 - morphism_share : 100;
+ _lawChoice[homomorphismLaws] = 100 - _lawChoice[inplaceSetLaws];
+ _lawChoice.init();
+ }
+
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case inplaceSetLaws: return InplaceSetValidater<Type>::chooseValidater();
+ case homomorphismLaws: return _morphicValidater.chooseValidater();
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+ private:
+ IntervalMorphicValidater<Type> _morphicValidater;
+
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ };
+
+
+ template <typename Type>
+ class IntervalMapValidater : public InplaceMapValidater<Type>
+ {
+ public:
+ enum Laws
+ {
+ inplaceMapLaws,
+ homomorphismLaws,
+ Laws_size
+ };
+
+ IntervalMapValidater() {setProfile();}
+
+ void setProfile()
+ {
+ _lawChoice.setSize(Laws_size);
+ _lawChoice.setMaxWeights(100);
+ const bool morphism_exists = !is_continuous<typename Type::domain_type>::value;
+ const int morphism_share = 30;
+ _lawChoice[inplaceMapLaws]= morphism_exists ? 100 - morphism_share : 100;
+ _lawChoice[homomorphismLaws] = 100 - _lawChoice[inplaceMapLaws];
+ _lawChoice.init();
+ }
+
+ bool hasValidProfile()
+ {
+ }
+
+ LawValidaterI* chooseValidater()
+ {
+ switch(_lawChoice.some())
+ {
+ case inplaceMapLaws: return InplaceMapValidater<Type>::chooseValidater();
+ case homomorphismLaws: return _morphicValidater.chooseValidater();
+ default: return NULL;
+ }
+ }
+
+ void validate()
+ {
+ _validater = chooseValidater();
+ if(_validater)
+ {
+ _validater->run();
+ _validater->addFrequencies(_frequencies);
+ _validater->addViolations(_violationsCount, _violations);
+ delete _validater;
+ }
+ }
+
+ void addFrequencies(ValidationCounterT& summary) { summary += _frequencies; }
+ void addViolations(ViolationCounterT& summary, ViolationMapT& collector)
+ {
+ summary += _violationsCount;
+ collector += _violations;
+ }
+
+ private:
+ IntervalMorphicValidater<Type> _morphicValidater;
+
+ ChoiceT _lawChoice;
+ LawValidaterI* _validater;
+ ValidationCounterT _frequencies;
+ ViolationCounterT _violationsCount;
+ ViolationMapT _violations;
+ };
+
+
+}} // namespace itl boost
+
Added: sandbox/itl/libs/itl/build/cygwin/makefile
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/build/cygwin/makefile 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,310 @@
+#------------------------------------------------------------------------------
+# makefile for the inteval template library
+#------------------------------------------------------------------------------
+
+#--- Platformdependent variables ----------------------------------------------
+#--- cygwin
+EXE_TAG = .exe
+#--- unix
+#EXE_TAG =
+
+
+#------------------------------------------------------------------------------
+# Locations
+#------------------------------------------------------------------------------
+
+#--- location of this makefile ------------------------------------------------
+MAKE_PATH = .
+#--- location of the interval template library rootpath -----------------------
+# build.itl.libs.itl
+ITL_ROOT_PATH = ../../../..
+#--- root directory of the interval template library --------------------------
+ITL_SRC_PATH = $(ITL_ROOT_PATH)/boost/itl
+ITL_LIBS_PATH = $(ITL_ROOT_PATH)/libs/itl
+ITL_EXAMPLE_PATH = $(ITL_LIBS_PATH)/example
+ITL_TEST_PATH = $(ITL_LIBS_PATH)/test
+
+#BOOST_PATH = /usr/include/boost-1_33_1
+BOOST_PATH = /usr/include/boost_1_35_0
+
+#--- binaries -----------------------------------------------------------------
+BIN_PATH = $(ITL_ROOT_PATH)/bin
+OBJ_PATH = $(BIN_PATH)/obj
+
+#--- include pathes -----------------------------------------------------------
+ITL_INCL = $(addprefix -I,$(ITL_SRC_PATH))
+BOOST_INCL = $(addprefix -I,$(BOOST_PATH))
+STD_INCL = -I/usr/include
+#GCC_INCL = $(addprefix -I,$(CMP_PATH))/include
+#CONCEPTGCC_INCL = -I/opt/conceptgcc-boostcon/include
+CONCEPTGCC_INCL = -I/opt/conceptgcc-4.3.0-alpha-7/include
+
+INCLUDE = $(CONCEPTGCC_INCL) $(ITL_INCL) $(BOOST_INCL)
+#NCLUDE = $(STD_INCL) $(ITL_INCL) $(BOOST_INCL)
+
+#--- libraries ----------------------------------------------------------------
+#LOAD_LIBS = -L$(CMP_PATH)/lib
+LOAD_LIBS = -L/usr/lib
+#--- LIBS for 64bit processors:
+#LOAD_LIBS = -L/usr/lib64
+
+#--- loadflags ----------------------------------------------------------------
+LOAD_FLAGS = $(LOAD_LIBS) -lstdc++
+LOAD_FLAGS4BOOST = $(LOAD_FLAGS) -lboost_date_time-gcc-mt-s
+
+#--- compileflags ---------------------------------------------------
+# COMPILE_FLAGS = -o2 -DUSE_CONCEPTS
+COMPILE_FLAGS = -O2
+
+#--- compiler -----------------------------------------------------------------
+#--- location of the compiler -------------------------------------------------
+#CMP_PATH = /opt/conceptgcc-boostcon
+#COMPILE = $(CMP_PATH)/bin/gcc
+COMPILE = /opt/conceptgcc-4.3.0-alpha-7/bin/gcc
+#COMPILE = gcc
+
+
+all:
+ make examples
+ make boost_examples
+ make tests
+
+# The concept_gcc compiler does not yet digest my loki::typelist based tuple type
+# tag 'all_concept' covers the parts that can be compiled
+all_concept:
+ make examples
+ make itvset_shell
+ make splititvmap_shell
+ make auto_itv_test
+
+examples:
+ make party
+ make interval
+ make interval_container
+ make overlap_counter
+ make history
+ make amount_cube
+
+boost_examples:
+ make boost_party
+ make user_groups
+ make month_and_week_grid
+ make man_power
+
+all_examples:
+ examples
+ boost_examples
+
+tests:
+ make itvset_shell
+ make splititvmap_shell
+ make auto_itv_test
+# labatea is cureently not compiling with gcc. It only compiles with msvc
+# make labatea
+
+devels:
+ make validate
+
+#--- projects -----------------------------------------------------------------
+#--- group examples -----------------------------------------------------------
+
+#--- project party ---------------------------------------------------------
+EXAMPLE_DIR = example
+party_PATH = $(ITL_EXAMPLE_PATH)/party
+party_MAIN = $(party_PATH)/party.cpp
+party_SOURCES = $(party_MAIN)
+party_TARGET = $(BIN_PATH)/party$(EXE_TAG)
+
+party:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(party_SOURCES) $(LOAD_FLAGS) -o $(party_TARGET)
+
+#--- project interval ---------------------------------------------------------
+interval_PATH = $(ITL_EXAMPLE_PATH)/interval
+interval_MAIN = $(interval_PATH)/interval.cpp
+interval_SOURCES = $(interval_MAIN)
+interval_TARGET = $(BIN_PATH)/interval$(EXE_TAG)
+
+interval:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(interval_SOURCES) $(LOAD_FLAGS) -o $(interval_TARGET)
+
+#--- project interval_container --------------------------------------------------
+interval_container_PATH = $(ITL_EXAMPLE_PATH)/interval_container
+interval_container_MAIN = $(interval_container_PATH)/interval_container.cpp
+interval_container_SOURCES = $(interval_container_MAIN)
+interval_container_TARGET = $(BIN_PATH)/interval_container$(EXE_TAG)
+
+interval_container:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(interval_container_SOURCES) $(LOAD_FLAGS) -o $(interval_container_TARGET)
+
+#--- project overlap_counter --------------------------------------------------
+overlap_counter_PATH = $(ITL_EXAMPLE_PATH)/overlap_counter
+overlap_counter_MAIN = $(overlap_counter_PATH)/overlap_counter.cpp
+overlap_counter_SOURCES = $(overlap_counter_MAIN)
+overlap_counter_TARGET = $(BIN_PATH)/overlap_counter$(EXE_TAG)
+
+overlap_counter:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(overlap_counter_SOURCES) $(LOAD_FLAGS) -o $(overlap_counter_TARGET)
+
+#--- project history --------------------------------------------------
+history_PATH = $(ITL_EXAMPLE_PATH)/history
+history_MAIN = $(history_PATH)/history.cpp
+history_SOURCES = $(history_MAIN)
+history_TARGET = $(BIN_PATH)/history$(EXE_TAG)
+
+history:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(history_SOURCES) $(LOAD_FLAGS) -o $(history_TARGET)
+
+#--- project amount_cube --------------------------------------------------
+amount_cube_PATH = $(ITL_EXAMPLE_PATH)/amount_cube
+amount_cube_MAIN = $(amount_cube_PATH)/amount_cube.cpp
+amount_cube_SOURCES = $(amount_cube_MAIN)
+amount_cube_TARGET = $(BIN_PATH)/amount_cube$(EXE_TAG)
+
+amount_cube:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(amount_cube_SOURCES) $(LOAD_FLAGS) -o $(amount_cube_TARGET)
+
+#--- project boost_party --------------------------------------------------
+boost_party_PATH = $(ITL_EXAMPLE_PATH)/boost_party
+boost_party_MAIN = $(boost_party_PATH)/boost_party.cpp
+boost_party_SOURCES = $(boost_party_MAIN)
+boost_party_TARGET = $(BIN_PATH)/boost_party$(EXE_TAG)
+
+boost_party:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(boost_party_SOURCES) $(LOAD_FLAGS4BOOST) -o $(boost_party_TARGET)
+
+#--- project user_groups --------------------------------------------------
+user_groups_PATH = $(ITL_EXAMPLE_PATH)/user_groups
+user_groups_MAIN = $(user_groups_PATH)/user_groups.cpp
+user_groups_SOURCES = $(user_groups_MAIN)
+user_groups_TARGET = $(BIN_PATH)/user_groups$(EXE_TAG)
+
+user_groups:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(user_groups_SOURCES) $(LOAD_FLAGS4BOOST) -o $(user_groups_TARGET)
+
+#--- project month_and_week_grid --------------------------------------------------
+month_and_week_grid_PATH = $(ITL_EXAMPLE_PATH)/month_and_week_grid
+month_and_week_grid_MAIN = $(month_and_week_grid_PATH)/month_and_week_grid.cpp
+month_and_week_grid_SOURCES = $(month_and_week_grid_MAIN)
+month_and_week_grid_TARGET = $(BIN_PATH)/month_and_week_grid$(EXE_TAG)
+
+month_and_week_grid:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(month_and_week_grid_SOURCES) $(LOAD_FLAGS4BOOST) -o $(month_and_week_grid_TARGET)
+
+#--- project man_power --------------------------------------------------
+man_power_PATH = $(ITL_EXAMPLE_PATH)/man_power
+man_power_MAIN = $(man_power_PATH)/man_power.cpp
+man_power_SOURCES = $(man_power_MAIN)
+man_power_TARGET = $(BIN_PATH)/man_power$(EXE_TAG)
+
+man_power:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(man_power_SOURCES) $(LOAD_FLAGS4BOOST) -o $(man_power_TARGET)
+
+
+
+#--- group tests --------------------------------------------------------------
+#--- project itvset_shell -----------------------------------------------------
+itvset_shell_PATH = $(ITL_TEST_PATH)/itvset_shell
+itvset_shell_MAIN = $(itvset_shell_PATH)/itvset_shell.cpp
+itvset_shell_SOURCES = $(itvset_shell_MAIN)
+itvset_shell_TARGET = $(BIN_PATH)/itvset_shell$(EXE_TAG)
+
+itvset_shell:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(itvset_shell_SOURCES) $(LOAD_FLAGS) -o $(itvset_shell_TARGET)
+
+#--- project splititvmap_shell ------------------------------------------------
+splititvmap_shell_PATH = $(ITL_TEST_PATH)/splititvmap_shell
+splititvmap_shell_MAIN = $(splititvmap_shell_PATH)/splititvmap_shell.cpp
+splititvmap_shell_SOURCES = $(splititvmap_shell_MAIN)
+splititvmap_shell_TARGET = $(BIN_PATH)/splititvmap_shell$(EXE_TAG)
+
+splititvmap_shell:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(splititvmap_shell_SOURCES) $(LOAD_FLAGS) -o $(splititvmap_shell_TARGET)
+
+#--- project auto_itv_test -----------------------------------------------------
+auto_itv_test_PATH = $(ITL_TEST_PATH)/auto_itv_test
+auto_itv_test_MAIN = $(auto_itv_test_PATH)/auto_itv_test.cpp
+auto_itv_test_SOURCES = $(auto_itv_test_MAIN)
+auto_itv_test_TARGET = $(BIN_PATH)/auto_itv_test$(EXE_TAG)
+
+auto_itv_test:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(auto_itv_test_SOURCES) $(LOAD_FLAGS) -o $(auto_itv_test_TARGET)
+
+#--- project labatea -----------------------------------------------------
+labatea_PATH = $(ITL_TEST_PATH)/labatea
+labatea_MAIN = $(labatea_PATH)/labatea.cpp
+labatea_SOURCES = $(ITL_SRC_PATH)/validate/gentor/gentorprofile.cpp $(labatea_MAIN)
+labatea_TARGET = $(BIN_PATH)/labatea$(EXE_TAG)
+
+labatea:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(labatea_SOURCES) $(LOAD_FLAGS) -o $(labatea_TARGET)
+
+
+#--- group devels --------------------------------------------------------------
+#--- project itvset_shell -----------------------------------------------------
+DEVEL_DIR = devel
+validate_PATH = $(ITL_ROOT_PATH)/$(DEVEL_DIR)/validate
+validate_MAIN = $(validate_PATH)/validate.cpp
+validate_SOURCES = $(ITL_SRC_PATH)/validate/gentor/gentorprofile.cpp $(validate_MAIN)
+validate_TARGET = $(BIN_PATH)/validate$(EXE_TAG)
+
+validate:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(validate_SOURCES) $(LOAD_FLAGS) -o $(validate_TARGET)
+
+#--- project template_match ---------------------------------------------
+template_match_PATH = $(ITL_ROOT_PATH)/$(DEVEL_DIR)/template_match
+template_match_MAIN = $(template_match_PATH)/template_match.cpp
+template_match_SOURCES = $(template_match_MAIN)
+template_match_TARGET = $(BIN_PATH)/template_match$(EXE_TAG)
+
+template_match:
+ $(COMPILE) $(COMPILE_FLAGS) $(INCLUDE) $(template_match_SOURCES) $(LOAD_FLAGS) -o $(template_match_TARGET)
+
+
+show_temps:
+ find $(ITL_LIBS_PATH) -name \*.pdb; \
+ find $(ITL_LIBS_PATH) -name \*.exe; \
+ find $(ITL_LIBS_PATH) -name \*.obj; \
+ find $(ITL_LIBS_PATH) -name \*.pdb; \
+ find $(ITL_LIBS_PATH) -name \*.idb; \
+ find $(ITL_LIBS_PATH) -name \*.ilk; \
+ find $(ITL_LIBS_PATH) -name \*.dep; \
+ find $(ITL_LIBS_PATH) -name \*.manifest*; \
+ find $(ITL_LIBS_PATH) -name BuildLog.htm; \
+ find $(ITL_LIBS_PATH)/doc/html -name *; \
+ find $(ITL_LIBS_PATH) -name \*.ncb; \
+ find $(ITL_LIBS_PATH) -name \*.suo; \
+ find $(ITL_LIBS_PATH) -name \*.user; \
+ find $(ITL_LIBS_PATH) -name stdafx.h; \
+
+win_clean:
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.exe; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.obj; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.pdb; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.idb; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.ilk; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.dep; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.manifest; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin \*.manifest.*; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/bin BuildLog.htm; \
+ ../script/rm_temps $(ITL_LIBS_PATH) \*.ncb; \
+ ../script/rm_temps $(ITL_LIBS_PATH) \*.suo; \
+ ../script/rm_temps $(ITL_LIBS_PATH) \*.user;
+
+bin_clean:
+ rm $(ITL_LIBS_PATH)/bin/* ;
+
+dox_clean:
+ ../script/rm_temps $(ITL_LIBS_PATH)/doc/html \*.html; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/doc/html \*.png; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/doc/html \*.css; \
+ ../script/rm_temps $(ITL_LIBS_PATH)/doc/html \*.gif; \
+
+clean:
+ make win_clean
+ make dox_clean
+
+svn_clean:
+ ../script/rm_svn $(ITL_ROOT_PATH)
+
+
+
\ No newline at end of file
Added: sandbox/itl/libs/itl/build/script/rm_svn
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/build/script/rm_svn 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "recursively removing .svn folders from $1"
+rm -rf `find $1 -type d -name .svn`
Added: sandbox/itl/libs/itl/build/script/rm_temps
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/build/script/rm_temps 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "removing $2 from $1"
+rm -rf `find $1 -name $2` ;
\ No newline at end of file
Added: sandbox/itl/libs/itl/build/win32/vc9_all.sln
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/build/win32/vc9_all.sln 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,146 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_interval", "..\..\example\interval\vc9_interval.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F7C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_interval_container", "..\..\example\interval_container\vc9_interval_container.vcproj", "{278324CE-9EC1-4D16-B637-E91A07F9DD81}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_party", "..\..\example\party\vc9_party.vcproj", "{6BE62DDE-21B9-4333-BF11-AA054DD43759}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_overlap_counter", "..\..\example\overlap_counter\vc9_overlap_counter.vcproj", "{8DC9BDE4-E5A4-4294-A12F-D75FD6990B83}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_boost_party", "..\..\example\boost_party\vc9_boost_party.vcproj", "{0D1DB87E-E72A-4FE9-A067-1907CC6613F8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_man_power", "..\..\example\man_power\vc9_man_power.vcproj", "{8B9B91C9-E79C-4F24-BD5C-04ED0F38E8C2}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_user_groups", "..\..\example\user_groups\vc9_user_groups.vcproj", "{900B8478-E01B-4ECD-A4D6-DC88DD5BF4A1}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_auto_itv_test", "..\..\..\itl_xt\test\auto_itv_test\vc9_auto_itv_test.vcproj", "{EF64A2C7-DE78-46C2-953F-C4685A5D2A97}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_itvset_shell", "..\..\example\itvset_shell\vc9_itvset_shell.vcproj", "{FC32CF3E-293A-4576-A5C2-9373AECAF5BB}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_splititvmap_shell", "..\..\example\splititvmap_shell\vc9_splititvmap_shell.vcproj", "{639F6AD9-CD50-40BF-92B9-CC9DD069D65A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_history", "..\..\..\itl_xt\example\history\vc9_history.vcproj", "{DD506ECC-2DE5-4C26-B810-B85A61BAA7EC}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_amount_cube", "..\..\..\itl_xt\example\amount_cube\vc9_amount_cube.vcproj", "{5B6AE5B3-FAF3-4D98-A6F9-C8889C62A0E5}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_labatea", "..\..\..\validate\example\labatea\vc9_labatea.vcproj", "{BF42574F-66E2-42DD-90D9-3A8FCE6F4719}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_itl_interval", "..\..\test\test_itl_interval\vc9_test_itl_interval.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F8C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_interval_set", "..\..\test\test_interval_set\vc9_test_interval_set.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_separate_interval_set", "..\..\test\test_separate_interval_set\vc9_test_separate_interval_set.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D3A9F9C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_split_interval_set", "..\..\test\test_split_interval_set\vc9_test_split_interval_set.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D4A9F9C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_interval_set_mixed", "..\..\test\test_interval_set_mixed\vc9_test_interval_set_mixed.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_interval_map", "..\..\test\test_interval_map\vc9_test_interval_map.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_split_interval_map", "..\..\test\test_split_interval_map\vc9_test_split_interval_map.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_test_interval_map_mixed", "..\..\test\test_interval_map_mixed\vc9_test_interval_map_mixed.vcproj", "{EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc9_month_and_week_grid", "..\..\example\month_and_week_grid\vc9_month_and_week_grid.vcproj", "{360BCFA9-9EB6-4D22-8469-CDC290478F78}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F7C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F7C}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F7C}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F7C}.Release|Win32.Build.0 = Release|Win32
+ {278324CE-9EC1-4D16-B637-E91A07F9DD81}.Debug|Win32.ActiveCfg = Debug|Win32
+ {278324CE-9EC1-4D16-B637-E91A07F9DD81}.Debug|Win32.Build.0 = Debug|Win32
+ {278324CE-9EC1-4D16-B637-E91A07F9DD81}.Release|Win32.ActiveCfg = Release|Win32
+ {278324CE-9EC1-4D16-B637-E91A07F9DD81}.Release|Win32.Build.0 = Release|Win32
+ {6BE62DDE-21B9-4333-BF11-AA054DD43759}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6BE62DDE-21B9-4333-BF11-AA054DD43759}.Debug|Win32.Build.0 = Debug|Win32
+ {6BE62DDE-21B9-4333-BF11-AA054DD43759}.Release|Win32.ActiveCfg = Release|Win32
+ {6BE62DDE-21B9-4333-BF11-AA054DD43759}.Release|Win32.Build.0 = Release|Win32
+ {8DC9BDE4-E5A4-4294-A12F-D75FD6990B83}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8DC9BDE4-E5A4-4294-A12F-D75FD6990B83}.Debug|Win32.Build.0 = Debug|Win32
+ {8DC9BDE4-E5A4-4294-A12F-D75FD6990B83}.Release|Win32.ActiveCfg = Release|Win32
+ {8DC9BDE4-E5A4-4294-A12F-D75FD6990B83}.Release|Win32.Build.0 = Release|Win32
+ {0D1DB87E-E72A-4FE9-A067-1907CC6613F8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0D1DB87E-E72A-4FE9-A067-1907CC6613F8}.Debug|Win32.Build.0 = Debug|Win32
+ {0D1DB87E-E72A-4FE9-A067-1907CC6613F8}.Release|Win32.ActiveCfg = Release|Win32
+ {0D1DB87E-E72A-4FE9-A067-1907CC6613F8}.Release|Win32.Build.0 = Release|Win32
+ {8B9B91C9-E79C-4F24-BD5C-04ED0F38E8C2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8B9B91C9-E79C-4F24-BD5C-04ED0F38E8C2}.Debug|Win32.Build.0 = Debug|Win32
+ {8B9B91C9-E79C-4F24-BD5C-04ED0F38E8C2}.Release|Win32.ActiveCfg = Release|Win32
+ {8B9B91C9-E79C-4F24-BD5C-04ED0F38E8C2}.Release|Win32.Build.0 = Release|Win32
+ {900B8478-E01B-4ECD-A4D6-DC88DD5BF4A1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {900B8478-E01B-4ECD-A4D6-DC88DD5BF4A1}.Debug|Win32.Build.0 = Debug|Win32
+ {900B8478-E01B-4ECD-A4D6-DC88DD5BF4A1}.Release|Win32.ActiveCfg = Release|Win32
+ {900B8478-E01B-4ECD-A4D6-DC88DD5BF4A1}.Release|Win32.Build.0 = Release|Win32
+ {EF64A2C7-DE78-46C2-953F-C4685A5D2A97}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EF64A2C7-DE78-46C2-953F-C4685A5D2A97}.Debug|Win32.Build.0 = Debug|Win32
+ {EF64A2C7-DE78-46C2-953F-C4685A5D2A97}.Release|Win32.ActiveCfg = Release|Win32
+ {EF64A2C7-DE78-46C2-953F-C4685A5D2A97}.Release|Win32.Build.0 = Release|Win32
+ {FC32CF3E-293A-4576-A5C2-9373AECAF5BB}.Debug|Win32.ActiveCfg = Debug|Win32
+ {FC32CF3E-293A-4576-A5C2-9373AECAF5BB}.Debug|Win32.Build.0 = Debug|Win32
+ {FC32CF3E-293A-4576-A5C2-9373AECAF5BB}.Release|Win32.ActiveCfg = Release|Win32
+ {FC32CF3E-293A-4576-A5C2-9373AECAF5BB}.Release|Win32.Build.0 = Release|Win32
+ {639F6AD9-CD50-40BF-92B9-CC9DD069D65A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {639F6AD9-CD50-40BF-92B9-CC9DD069D65A}.Debug|Win32.Build.0 = Debug|Win32
+ {639F6AD9-CD50-40BF-92B9-CC9DD069D65A}.Release|Win32.ActiveCfg = Release|Win32
+ {639F6AD9-CD50-40BF-92B9-CC9DD069D65A}.Release|Win32.Build.0 = Release|Win32
+ {DD506ECC-2DE5-4C26-B810-B85A61BAA7EC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DD506ECC-2DE5-4C26-B810-B85A61BAA7EC}.Debug|Win32.Build.0 = Debug|Win32
+ {DD506ECC-2DE5-4C26-B810-B85A61BAA7EC}.Release|Win32.ActiveCfg = Release|Win32
+ {DD506ECC-2DE5-4C26-B810-B85A61BAA7EC}.Release|Win32.Build.0 = Release|Win32
+ {5B6AE5B3-FAF3-4D98-A6F9-C8889C62A0E5}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5B6AE5B3-FAF3-4D98-A6F9-C8889C62A0E5}.Debug|Win32.Build.0 = Debug|Win32
+ {5B6AE5B3-FAF3-4D98-A6F9-C8889C62A0E5}.Release|Win32.ActiveCfg = Release|Win32
+ {5B6AE5B3-FAF3-4D98-A6F9-C8889C62A0E5}.Release|Win32.Build.0 = Release|Win32
+ {BF42574F-66E2-42DD-90D9-3A8FCE6F4719}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BF42574F-66E2-42DD-90D9-3A8FCE6F4719}.Debug|Win32.Build.0 = Debug|Win32
+ {BF42574F-66E2-42DD-90D9-3A8FCE6F4719}.Release|Win32.ActiveCfg = Release|Win32
+ {BF42574F-66E2-42DD-90D9-3A8FCE6F4719}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F8C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F8C}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F8C}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F8C}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9C}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9C}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9C}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D3A9F9C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D3A9F9C}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D3A9F9C}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D3A9F9C}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D4A9F9C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D4A9F9C}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D4A9F9C}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D4A9F9C}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9E}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9E}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9E}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9D}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9D}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9D}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9E}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9E}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9E}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9F}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9F}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9F}.Release|Win32.Build.0 = Release|Win32
+ {360BCFA9-9EB6-4D22-8469-CDC290478F78}.Debug|Win32.ActiveCfg = Debug|Win32
+ {360BCFA9-9EB6-4D22-8469-CDC290478F78}.Debug|Win32.Build.0 = Debug|Win32
+ {360BCFA9-9EB6-4D22-8469-CDC290478F78}.Release|Win32.ActiveCfg = Release|Win32
+ {360BCFA9-9EB6-4D22-8469-CDC290478F78}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: sandbox/itl/libs/itl/example/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/Jamfile.v2 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,90 @@
+# (C) Copyright 2008: Joachim Faulhaber
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# Examples that do not use boost_date_time
+exe interval
+ :
+ interval/interval.cpp
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe interval_container
+ :
+ interval_container/interval_container.cpp
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe overlap_counter
+ :
+ overlap_counter/overlap_counter.cpp
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe party
+ :
+ party/party.cpp
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+# Examples using boost_date_time
+exe boost_party
+ :
+ boost_party/boost_party.cpp
+ /boost/date_time//boost_date_time
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe man_power
+ :
+ man_power/man_power.cpp
+ /boost/date_time//boost_date_time
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe month_and_week_grid
+ :
+ month_and_week_grid/month_and_week_grid.cpp
+ /boost/date_time//boost_date_time
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe user_groups
+ :
+ user_groups/user_groups.cpp
+ /boost/date_time//boost_date_time
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe itvset_shell
+ :
+ itvset_shell/itvset_shell.cpp
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
+exe splititvmap_shell
+ :
+ splititvmap_shell/splititvmap_shell.cpp
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
+
Added: sandbox/itl/libs/itl/example/boost_party/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/boost_party/Jamfile.v2 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,12 @@
+# (C) Copyright 2008: Joachim Faulhaber
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+exe boost_party
+ :
+ boost_party.cpp
+ /boost/date_time//boost_date_time
+ :
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
Added: sandbox/itl/libs/itl/example/boost_party/boost_party.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/boost_party/boost_party.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,181 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+
+// The next line includes <boost/date_time/posix_time/posix_time.hpp>
+// and a few lines of adapter code.
+#include <boost/itl/ptime.hpp>
+
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/interval_map.hpp>
+
+using namespace std;
+using namespace boost::posix_time;
+using namespace boost::itl;
+
+/** Example boost_party.cpp \file boost_party.cpp
+
+ boost_party.cpp demonstrates the possibilities of an interval map
+ (interval_map or split_interval_map). Boost::posix_time::ptime is used as time
+ parameter. An interval_map maps intervals to a given content. In this case the
+ content is a set of party guests represented by their name strings.
+
+ As time goes by, groups of people join the party and leave later in the evening.
+ So we add a time interval and a name set to the interval_map for the attendance
+ of each group of people, that come together and leave together.
+
+ On every overlap of intervals, the corresponding name sets are accumulated. At
+ the points of overlap the intervals are split. The accumulation of content on
+ overlap of intervals is done via an operator += that has to be implemented
+ for the content parameter of the interval_map.
+
+ Finally the interval_map contains the history of attendance and all points in
+ time, where the group of party guests changed.
+
+ boost_party.cpp demonstrates a principle that we call
+ <b><em>aggregate on overlap (aggovering;)</em></b>:
+ On insertion a value associated to the interval is aggregated (added) to those
+ values in the interval_map that overlap with the inserted value.
+
+ There are two behavioral aspects to <b>aggovering</b>: a <em>decompositional
+ behavior</em> and a <em>accumulative behavior</em>.
+
+ The <em>decompositional behavior</em> splits up intervals on the time dimension of the
+ interval_map so that the intervals change whenever associated values
+ change.
+
+ The <em>accumulative behavior</em> accumulates associated values on every overlap of
+ an insertion for the associated values.
+
+ \include boost_party/boost_party.cpp
+*/
+
+// Type itl::set<string> collects the names of party guests. Therefore it needs to
+// implement operator += that performs a set union on overlap of intervals.
+typedef boost::itl::set<string> GuestSetT;
+
+// boost::posix_time::ptime is the domain type the the interval_map.
+// It's key values are therefore time intervals: interval<ptime>. The content
+// is the set of names: GuestSetT.
+typedef interval_map<ptime, GuestSetT> BoostPartyAttendenceHistoryT;
+
+// A party's height shall be defined as the maximum height of all guests ;-)
+typedef interval_map<ptime, int> BoostPartyHeightHistoryT;
+
+void boost_party()
+{
+ GuestSetT mary_harry;
+ mary_harry.insert("Mary");
+ mary_harry.insert("Harry");
+
+ GuestSetT diana_susan;
+ diana_susan.insert("Diana");
+ diana_susan.insert("Susan");
+
+ GuestSetT peter;
+ peter.insert("Peter");
+
+ BoostPartyAttendenceHistoryT party;
+
+ party.add( // add and element
+ make_pair(
+ rightopen_interval<ptime>(
+ time_from_string("2008-05-20 19:30"),
+ time_from_string("2008-05-20 23:00")),
+ mary_harry));
+
+ party += // element addition can also be done via operator +=
+ make_pair(
+ rightopen_interval<ptime>(
+ time_from_string("2008-05-20 20:10"),
+ time_from_string("2008-05-21 00:00")),
+ diana_susan);
+ party +=
+ make_pair(
+ rightopen_interval<ptime>(
+ time_from_string("2008-05-20 22:15"),
+ time_from_string("2008-05-21 00:30")),
+ peter);
+
+ //-------------------------------------------------------------------------
+ BoostPartyHeightHistoryT tallest_guest;
+
+ // adding an element can be done wrt. simple aggregate functions
+ // like e.g. min, max etc. in their 'inplace' or op= incarnation
+ tallest_guest.add<inplace_max>(
+ make_pair(
+ rightopen_interval<ptime>(
+ time_from_string("2008-05-20 19:30"),
+ time_from_string("2008-05-20 23:00")),
+ 180));
+
+ tallest_guest.add<inplace_max>(
+ make_pair(
+ rightopen_interval<ptime>(
+ time_from_string("2008-05-20 20:10"),
+ time_from_string("2008-05-21 00:00")),
+ 170));
+
+ tallest_guest.add<inplace_max>(
+ make_pair(
+ rightopen_interval<ptime>(
+ time_from_string("2008-05-20 22:15"),
+ time_from_string("2008-05-21 00:30")),
+ 200));
+
+
+ BoostPartyAttendenceHistoryT::iterator it = party.begin();
+ cout << "----- Histrory of party guests ------------------------\n";
+ while(it != party.end())
+ {
+ interval<ptime> when = (*it).first;
+ // Who is at the party within the time interval 'when' ?
+ GuestSetT who = (*it++).second;
+ cout << "[" << when.first() << " - " << when.upper() << ")"
+ << ": " << who.as_string() << endl;
+ }
+
+ BoostPartyHeightHistoryT::iterator height_ = tallest_guest.begin();
+ cout << "----- Histrory of maximum guest height ----------------\n";
+ while(height_ != tallest_guest.end())
+ {
+ interval<ptime> when = height_->first;
+ // Of what height are the tallest guests within the time interval 'when' ?
+ int height = (*height_++).second;
+ cout << "[" << when.first() << " - " << when.upper() << ")"
+ << ": " << height <<" cm = " << height/30.48 << " ft" << endl;
+ }
+}
+
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample boost_party.cpp <<\n";
+ cout << "-------------------------------------------------------\n";
+ boost_party();
+ return 0;
+}
+
+// Program output:
+/*-----------------------------------------------------------------------------
+>> Interval Template Library: Sample boost_party.cpp <<
+-------------------------------------------------------
+----- Histrory of party guests ------------------------
+[2008-May-20 19:30:00 - 2008-May-20 20:10:00): Harry Mary
+[2008-May-20 20:10:00 - 2008-May-20 22:15:00): Diana Harry Mary Susan
+[2008-May-20 22:15:00 - 2008-May-20 23:00:00): Diana Harry Mary Peter Susan
+[2008-May-20 23:00:00 - 2008-May-21 00:00:00): Diana Peter Susan
+[2008-May-21 00:00:00 - 2008-May-21 00:30:00): Peter
+----- Histrory of maximum guest height ----------------
+[2008-May-20 19:30:00 - 2008-May-20 22:15:00): 180 cm = 5.90551 ft
+[2008-May-20 22:15:00 - 2008-May-21 00:30:00): 200 cm = 6.56168 ft
+-----------------------------------------------------------------------------*/
Added: sandbox/itl/libs/itl/example/boost_party/vc9_boost_party.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/boost_party/vc9_boost_party.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_boost_party"
+ ProjectGUID="{0D1DB87E-E72A-4FE9-A067-1907CC6613F8}"
+ RootNamespace="Boost_party"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="true"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ UseUnicodeResponseFiles="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="false"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\boost_party.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_base_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_map.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/interval/interval.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/interval/interval.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,63 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <iostream>
+#include <string>
+#include <math.h>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/interval.hpp>
+#include "../toytime.h"
+
+using namespace std;
+using namespace boost::itl;
+
+/** Example interval.cpp \file interval.cpp
+
+ Of course much of the library code deals with intervals which are implemented
+ as class interval.
+
+ This program gives a very short samlpe of different interval instances.
+
+ \include example/interval/interval.cpp
+*/
+int main()
+{
+ cout << ">> Interval Template Library: Sample interval.cpp <<\n";
+ cout << "---------------------------------------------------\n";
+
+ interval<int> int_Itv = closed_interval(3,7);
+ interval<double> sqrt_Itv = rightopen_interval(1/sqrt(2.0), sqrt(2.0));
+ interval<string> city_Itv = leftopen_interval<string>("Barcelona", "Boston");
+ interval<Time> time_Itv = open_interval(Time(monday,8,30), Time(monday,17,20));
+
+ cout << "Interval<int>: " << int_Itv.as_string() << endl;
+ cout << "Interval<double>: " << sqrt_Itv.as_string() << " does "
+ << string(sqrt_Itv.contains(sqrt(2.0))?"":"NOT")
+ << " contain sqrt(2)" << endl;
+ cout << "Interval<string>: " << city_Itv.as_string() << " does "
+ << string(city_Itv.contains("Barcelona")?"":"NOT")
+ << " contain 'Barcelona'" << endl;
+ cout << "Interval<string>: " << city_Itv.as_string() << " does "
+ << string(city_Itv.contains("Berlin")?"":"NOT")
+ << " contain 'Berlin'" << endl;
+ cout << "Interval<Time>: " << time_Itv.as_string() << endl;
+
+ return 0;
+}
+
+// Program output:
+
+// >> Interval Template Library: Sample interval.cpp <<
+// ---------------------------------------------------
+// Interval<int>: [3,7]
+// Interval<double>: [0.707107,1.41421) does NOT contain sqrt(2)
+// Interval<string>: (Barcelona,Boston] does NOT contain 'Barcelona'
+// Interval<string>: (Barcelona,Boston] does contain 'Berlin'
+// Interval<Time>: (mon:08:30,mon:17:20)
Added: sandbox/itl/libs/itl/example/interval/vc9_interval.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/interval/vc9_interval.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_interval"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F7C}"
+ RootNamespace="Interval"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\interval.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/interval_container/interval_container.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/interval_container/interval_container.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,102 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl/separate_interval_set.hpp>
+#include <boost/itl/split_interval_set.hpp>
+#include <boost/itl/split_interval_map.hpp>
+#include "../toytime.h"
+
+using namespace std;
+using namespace boost::itl;
+
+/** Example interval_container.cpp \file interval_container.cpp
+
+ Sample file interval_container.cpp demontrates basic charactersistics of
+ interval container objects.
+
+ Simple interactive shells for the manipulation of interval containers can be found
+ in the 'tests.sln' project.
+
+ \include interval_container/interval_container.cpp
+*/
+void interval_container_basics()
+{
+ interval<Time> night_and_day = rightopen_interval(Time(monday, 20,00), Time(tuesday, 20,00));
+ interval<Time> day_and_night = rightopen_interval(Time(tuesday, 7,00), Time(wednesday, 7,00));
+ interval<Time> next_morning = rightopen_interval(Time(wednesday, 7,00), Time(wednesday,10,00));
+ interval<Time> next_evening = rightopen_interval(Time(wednesday,18,00), Time(wednesday,21,00));
+
+ // An interval set of type interval_set joins intervals that that overlap or touch each other.
+ interval_set<Time> joinedTimes;
+ joinedTimes.insert(night_and_day);
+ joinedTimes.insert(day_and_night); //overlapping in 'day' [07:00, 20.00)
+ joinedTimes.insert(next_morning); //touching
+ joinedTimes.insert(next_evening); //disjoint
+
+ cout << "Joined times :" << joinedTimes.as_string() << endl;
+
+ // A separate interval set of type separate_interval_set joins intervals that that
+ // overlap but it preserves interval borders that just touch each other. You may
+ // represent time grids like the months of a year as a split_interval_set.
+ separate_interval_set<Time> separateTimes;
+ separateTimes.insert(night_and_day);
+ separateTimes.insert(day_and_night); //overlapping in 'day' [07:00, 20.00)
+ separateTimes.insert(next_morning); //touching
+ separateTimes.insert(next_evening); //disjoint
+
+ cout << "Separate times:" << separateTimes.as_string() << endl;
+
+ // A split interval set of type split_interval_set preserves all interval
+ // borders. On insertion of overlapping intervals the intervals in the
+ // set are split up at the interval boreders of the inserted interval.
+ split_interval_set<Time> splitTimes;
+ splitTimes += night_and_day;
+ splitTimes += day_and_night; //overlapping in 'day' [07:00, 20:00)
+ splitTimes += next_morning; //touching
+ splitTimes += next_evening; //disjoint
+
+ cout << "Split times :\n" << splitTimes.as_string() << endl;
+
+ // A split interval map splits up inserted intervals on overlap and aggregates the
+ // associated quantities via the operator +=
+ split_interval_map<Time, int> overlapCounter;
+ overlapCounter += make_pair(night_and_day,1);
+ overlapCounter += make_pair(day_and_night,1); //overlapping in 'day' [07:00, 20.00)
+ overlapCounter += make_pair(next_morning, 1); //touching
+ overlapCounter += make_pair(next_evening, 1); //disjoint
+
+ cout << "Split times overlap counted:\n" << overlapCounter.as_string() << endl;
+}
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample interval_container.cpp <<\n";
+ cout << "--------------------------------------------------------------\n";
+ interval_container_basics();
+ return 0;
+}
+
+
+// Program output:
+/* ----------------------------------------------------------------------------
+>> Interval Template Library: Sample interval_container.cpp <<
+--------------------------------------------------------------
+Joined times :[mon:20:00,wed:10:00)[wed:18:00,wed:21:00)
+Separate times:[mon:20:00,wed:07:00)[wed:07:00,wed:10:00)[wed:18:00,wed:21:00)
+Split times :[mon:20:00,tue:07:00)[tue:07:00,tue:20:00)[tue:20:00,wed:07:00)
+ [wed:07:00,wed:10:00)[wed:18:00,wed:21:00)
+Split times overlap counted:
+([mon:20:00,tue:07:00),1)([tue:07:00,tue:20:00),2)([tue:20:00,wed:07:00),1)
+([wed:07:00,wed:10:00),1)([wed:18:00,wed:21:00),1)
+-----------------------------------------------------------------------------*/
Added: sandbox/itl/libs/itl/example/interval_container/vc9_interval_container.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/interval_container/vc9_interval_container.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_interval_container"
+ ProjectGUID="{278324CE-9EC1-4D16-B637-E91A07F9DD81}"
+ RootNamespace="interval_container"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\interval_container.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_base_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_base_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\separate_interval_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\split_interval_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\split_interval_set.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/itvset_shell/itvset_shell.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/itvset_shell/itvset_shell.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,149 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------+
+itvset_shell.cpp provides a simple test shells for interval sets.
+The shell also gives you a good idea how interval container are working.
++----------------------------------------------------------------------------*/
+#include <iostream>
+
+#include <boost/itl/split_interval_set.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
+using namespace std;
+using namespace boost::itl;
+
+void instructions()
+{
+ cout << "+++++ Test shell for interval set +++++\n";
+ cout << "Type: q e or 0 to quit\n";
+ cout << "Type: + for insertions\n";
+ cout << "Type: - for subtraction\n";
+ cout << "Type: j to join contiguous intervals\n";
+ cout << "Type: s to compute total size\n";
+}
+
+void wrongInput()
+{
+ cout << "Wrong Input ------------------\n";
+ instructions();
+}
+
+
+template <class SetTV>
+void setTestShell()
+{
+ SetTV m1;
+
+ try {
+ char cmd = 'b';
+ typename SetTV::domain_type lwb = typename SetTV::domain_type();
+ typename SetTV::domain_type upb = typename SetTV::domain_type();
+
+ instructions();
+
+ while(true)
+ {
+ cout << "> ";
+ cin >> cmd ;
+
+ switch(cmd)
+ {
+ case 'q':
+ case 'e':
+ case '0': cout << "good bye\n"; return;
+ case '+':
+ {
+ cout << "input: lwb upb >> ";
+ cin >> lwb >> upb;
+ typename SetTV::interval_type itv
+ = typename SetTV::interval_type(lwb,upb);
+ // SetTV::IntervalTD itv = rightOpenInterval(lwb,upb);
+ m1.insert(itv);
+
+ cout << "+" << itv.as_string().c_str() << " =" << endl;
+ cout << "{" << m1.as_string() << "}" << endl;
+
+ }
+ break;
+ case '-':
+ {
+ cout << "input: lwb upb >> ";
+ cin >> lwb >> upb;
+ typename SetTV::interval_type itv
+ = typename SetTV::interval_type(lwb,upb);
+ // m1.subtract(itv);
+ SetTV tmp;
+ tmp.insert(itv);
+ m1 -= tmp;
+
+ cout << "-" << itv.as_string().c_str()<<" =" << endl;
+ cout << "{" << m1.as_string() << "}" << endl;
+
+ }
+ break;
+ case 'j':
+ {
+ m1.join();
+ cout << "{" << m1.as_string() << "}" << endl;
+ }
+ break;
+ case 's':
+ {
+ cout << "size = " << m1.size() << endl;
+ }
+ break;
+
+ default: wrongInput();
+ }
+ }
+
+ }
+ catch (exception& e)
+ {
+ cout << "itvset_shell: exception caught: " << endl
+ << e.what() << endl;
+ }
+ catch (...)
+ {
+ cout << "itvset_shell: unknown exception caught" << endl;
+ }
+}
+
+
+
+
+int main()
+{
+ cout << ">> Interval Template Library: Test itvset_shell.cpp <<\n";
+ cout << "------------------------------------------------------\n";
+ setTestShell< interval_set<int> >();
+
+ return 0;
+}
+
Added: sandbox/itl/libs/itl/example/itvset_shell/vc9_itvset_shell.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/itvset_shell/vc9_itvset_shell.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_itvset_shell"
+ ProjectGUID="{FC32CF3E-293A-4576-A5C2-9373AECAF5BB}"
+ RootNamespace="vc9_itvset_shell"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\itvset_shell.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/man_power/man_power.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/man_power/man_power.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,186 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+
+// The next line includes <boost/gregorian/date.hpp>
+// and a few lines of adapter code.
+#include <boost/itl/gregorian.hpp>
+
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/interval_map.hpp>
+
+using namespace std;
+using namespace boost::gregorian;
+using namespace boost::itl;
+
+/** Example man_power.cpp \file man_power.cpp
+
+ Interval sets and maps can be filled and manipulated using
+ set style operation like union (+=), difference (-=) and intersection
+ (*=).
+
+ In this example 'man_power' a number of those operations are
+ demonstrated in the process of calculation the available working
+ times (man-power) of a company's employees accounting for weekends,
+ holidays, sickness times and vacations.
+
+ \include man_power/man_power.cpp
+*/
+
+
+// Function weekends returns the interval_set of weekends that are contained in
+// the date interval 'scope'
+interval_set<date> weekends(const interval<date>& scope)
+{
+ interval_set<date> weekends;
+
+ date cur_weekend_sat
+ = scope.first()
+ + days(days_until_weekday(scope.first(), greg_weekday(Saturday)))
+ - weeks(1);
+ week_iterator week_iter(cur_weekend_sat);
+
+ for(; week_iter <= scope.last(); ++week_iter)
+ weekends += rightopen_interval(*week_iter, *week_iter + days(2));
+
+ weekends *= scope; // cut off the surplus
+
+ return weekends;
+}
+
+// The avalable working time for the employees of a company is calculated
+// for a period of 3 months accounting for weekends and holidays.
+// The available daily working time for the employees is calculated
+// using interval_sets and interval_maps demonstrating a number of
+// addition, subtraction and intersection operations.
+void man_power()
+{
+ date someday = from_string("2008-08-01");
+ date thenday = someday + months(3);
+
+ interval<date> scope = rightopen_interval(someday, thenday);
+
+ // ------------------------------------------------------------------------
+ // (1) In a first step, the regular working times are computed for the
+ // company within the given scope. From all available days, the weekends
+ // and holidays have to be subtracted:
+ interval_set<date> worktime(scope);
+ // Subtract the weekends
+ worktime -= weekends(scope);
+ // Subtract holidays
+ worktime -= from_string("2008-10-03"); //german reunification ;)
+
+ // company holidays (fictitious ;)
+ worktime -= closed_interval(from_string("2008-08-18"),
+ from_string("2008-08-22"));
+
+ //-------------------------------------------------------------------------
+ // (2) Now we calculate the individual worktimes for some employees
+ //-------------------------------------------------------------------------
+ // In the company works Claudia.
+ // This is the map of her regular working times:
+ interval_map<date,int> claudias_working_hours;
+
+ // Claudia is working 8 hours a day. So the next statement says
+ // that every day in the whole scope is mapped to 8 hours worktime.
+ claudias_working_hours += make_pair(scope, 8);
+
+ // But Claudia only works 8 hours on regular working days so we do
+ // an intersection of the interval_map with the interval_set worktime:
+ claudias_working_hours *= worktime;
+
+ // Yet, in addition Claudia has her own absence times like
+ interval<date> claudias_seminar (from_string("2008-09-16"),
+ from_string("2008-09-24"));
+ interval<date> claudias_vacation(from_string("2008-08-01"),
+ from_string("2008-08-14"));
+
+ interval_set<date> claudias_absence_times(claudias_seminar);
+ claudias_absence_times += claudias_vacation;
+
+ // All the absencetimes have to subtracted from the map of her working times
+ claudias_working_hours -= claudias_absence_times;
+
+ //-------------------------------------------------------------------------
+ // Claudia's boss is Bodo. He only works part time.
+ // This is the map of his regular working times:
+ interval_map<date,int> bodos_working_hours;
+
+ // Bodo is working 4 hours a day.
+ bodos_working_hours += make_pair(scope, 4);
+
+ // Bodo works only on regular working days
+ bodos_working_hours *= worktime;
+
+ // Bodos additional absence times
+ interval<date> bodos_flu(from_string("2008-09-19"), from_string("2008-09-29"));
+ interval<date> bodos_vacation(from_string("2008-08-15"), from_string("2008-09-03"));
+
+ interval_set<date> bodos_absence_times(bodos_flu);
+ bodos_absence_times += bodos_vacation;
+
+ // All the absencetimes have to be subtracted from the map of his working times
+ bodos_working_hours -= bodos_absence_times;
+
+ //-------------------------------------------------------------------------
+ // (3) Finally we want to calculate the available manpower of the company
+ // for the selected time scope: This is done by adding up the employees
+ // working time maps:
+ interval_map<date,int> manpower;
+ manpower += claudias_working_hours;
+ manpower += bodos_working_hours;
+
+
+ cout << scope.first() << " - " << scope.last()
+ << " available man-power:" << endl;
+ cout << "---------------------------------------------------------------\n";
+
+ for(interval_map<date,int>::iterator it = manpower.begin();
+ it != manpower.end(); it++)
+ {
+ cout << it->first.first() << " - " << it->first.last()
+ << " -> " << it->second << endl;
+ }
+}
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample man_power.cpp <<\n";
+ cout << "---------------------------------------------------------------\n";
+ man_power();
+ return 0;
+}
+
+// Program output:
+/*
+>> Interval Template Library: Sample man_power.cpp <<
+---------------------------------------------------------------
+2008-Aug-01 - 2008-Oct-31 available man-power:
+---------------------------------------------------------------
+2008-Aug-01 - 2008-Aug-01 -> 4
+2008-Aug-04 - 2008-Aug-08 -> 4
+2008-Aug-11 - 2008-Aug-14 -> 4
+2008-Aug-15 - 2008-Aug-15 -> 8
+2008-Aug-25 - 2008-Aug-29 -> 8
+2008-Sep-01 - 2008-Sep-03 -> 8
+2008-Sep-04 - 2008-Sep-05 -> 12
+2008-Sep-08 - 2008-Sep-12 -> 12
+2008-Sep-15 - 2008-Sep-15 -> 12
+2008-Sep-16 - 2008-Sep-18 -> 4
+2008-Sep-25 - 2008-Sep-26 -> 8
+2008-Sep-29 - 2008-Sep-29 -> 8
+2008-Sep-30 - 2008-Oct-02 -> 12
+2008-Oct-06 - 2008-Oct-10 -> 12
+2008-Oct-13 - 2008-Oct-17 -> 12
+2008-Oct-20 - 2008-Oct-24 -> 12
+2008-Oct-27 - 2008-Oct-31 -> 12
+*/
Added: sandbox/itl/libs/itl/example/man_power/vc9_man_power.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/man_power/vc9_man_power.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_man_power"
+ ProjectGUID="{8B9B91C9-E79C-4F24-BD5C-04ED0F38E8C2}"
+ RootNamespace="Party"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="true"
+ AdditionalDependencies="boost_date_time-vc80-mt-gd-1_35.lib"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ UseUnicodeResponseFiles="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="false"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\man_power.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_base_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_base_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_set.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/month_and_week_grid/month_and_week_grid.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/month_and_week_grid/month_and_week_grid.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,141 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+
+// The next line includes <boost/gregorian/date.hpp>
+// and a few lines of adapter code.
+#include <boost/itl/gregorian.hpp>
+
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
+using namespace std;
+using namespace boost::gregorian;
+using namespace boost::itl;
+
+/** Example month_and_week_grid.cpp \file month_and_week_grid.cpp
+
+ As split_interval_set preserves all interval borders on insertion
+ and intersection operations. So given a split_interval_set
+ \code
+ x = {[1, 3)}
+ x.add( [2, 4)) then
+ x == {[1,2)[2,3)[3,4)}
+ \endcode
+ Using this property we can intersect split_interval_maps in
+ order to iterate over intervals accounting for all occurring
+ changes of interval borders.
+
+ In this example we provide an intersection of two split_interval_sets
+ representing a month and week time grid.
+
+ \include month_and_week_grid/month_and_week_grid.cpp
+*/
+
+typedef split_interval_set<boost::gregorian::date> date_grid;
+
+// This function splits a gregorian::date interval 'scope' into a month grid:
+// For every month contained in 'scope' that month is contained as interval
+// in the resulting split_interval_set.
+date_grid month_grid(const interval<date>& scope)
+{
+ split_interval_set<date> month_grid;
+
+ date frame_months_1st = scope.first().end_of_month() + days(1) - months(1);
+ month_iterator month_iter(frame_months_1st);
+
+ for(; month_iter <= scope.last(); ++month_iter)
+ month_grid += rightopen_interval(*month_iter, *month_iter + months(1));
+
+ month_grid *= scope; // cut off the surplus
+
+ return month_grid;
+}
+
+// This function splits a gregorian::date interval 'scope' into a week grid:
+// For every week contained in 'scope' that month is contained as interval
+// in the resulting split_interval_set.
+date_grid week_grid(const interval<date>& scope)
+{
+ split_interval_set<date> week_grid;
+
+ date frame_weeks_1st = scope.first() + days(days_until_weekday(scope.first(), greg_weekday(Monday))) - weeks(1);
+ week_iterator week_iter(frame_weeks_1st);
+
+ for(; week_iter <= scope.last(); ++week_iter)
+ week_grid.insert(rightopen_interval(*week_iter, *week_iter + weeks(1)));
+
+ week_grid *= scope; // cut off the surplus
+
+ return week_grid;
+}
+
+// For a period of two months, starting from today, the function
+// computes a partitioning for months and weeks using intersection
+// operator *= on split_interval_sets.
+void month_and_time_grid()
+{
+ date someday = day_clock::local_day();
+ date thenday = someday + months(2);
+
+ interval<date> itv = rightopen_interval(someday, thenday);
+
+ // Compute a month grid
+ date_grid month_and_week_grid = month_grid(itv);
+ // Intersection of the month and week grids:
+ month_and_week_grid *= week_grid(itv);
+
+ cout << "interval : " << itv.first() << " - " << itv.last()
+ << " month and week partitions:" << endl;
+ cout << "---------------------------------------------------------------\n";
+
+ for(date_grid::iterator it = month_and_week_grid.begin();
+ it != month_and_week_grid.end(); it++)
+ {
+ if(it->first().day() == 1)
+ cout << "new month: ";
+ else if(it->first().day_of_week()==greg_weekday(Monday))
+ cout << "new week : " ;
+ else if(it == month_and_week_grid.begin())
+ cout << "first day: " ;
+ cout << it->first() << " - " << it->last() << endl;
+ }
+}
+
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample month_and_time_grid.cpp <<\n";
+ cout << "---------------------------------------------------------------\n";
+ month_and_time_grid();
+ return 0;
+}
+
+// Program output:
+/*
+>> Interval Template Library: Sample month_and_time_grid.cpp <<
+---------------------------------------------------------------
+interval : 2008-Jun-22 - 2008-Aug-21 month and week partitions:
+---------------------------------------------------------------
+first day: 2008-Jun-22 - 2008-Jun-22
+new week : 2008-Jun-23 - 2008-Jun-29
+new week : 2008-Jun-30 - 2008-Jun-30
+new month: 2008-Jul-01 - 2008-Jul-06
+new week : 2008-Jul-07 - 2008-Jul-13
+new week : 2008-Jul-14 - 2008-Jul-20
+new week : 2008-Jul-21 - 2008-Jul-27
+new week : 2008-Jul-28 - 2008-Jul-31
+new month: 2008-Aug-01 - 2008-Aug-03
+new week : 2008-Aug-04 - 2008-Aug-10
+new week : 2008-Aug-11 - 2008-Aug-17
+new week : 2008-Aug-18 - 2008-Aug-21
+*/
Added: sandbox/itl/libs/itl/example/month_and_week_grid/vc9_month_and_week_grid.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/month_and_week_grid/vc9_month_and_week_grid.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_month_and_week_grid"
+ ProjectGUID="{360BCFA9-9EB6-4D22-8469-CDC290478F78}"
+ RootNamespace="Party"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../bin/debug/"
+ IntermediateDirectory="../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="true"
+ AdditionalDependencies="boost_date_time-vc80-mt-gd-1_35.lib"
+ OutputFile="../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ UseUnicodeResponseFiles="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../bin/release/"
+ IntermediateDirectory="../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="false"
+ OutputFile="../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\month_and_week_grid.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\src\itl\interval_base_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\itl_interval.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\split_interval_map.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/overlap_counter/overlap_counter.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/overlap_counter/overlap_counter.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,104 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
+using namespace std;
+using namespace boost::itl;
+
+
+/** Example overlap_counter.cpp \file overlap_counter.cpp
+
+ The most basic application of an interval_map is a counter counting
+ the number of overlaps of intervals inserted into it.
+
+ On could call an interval_map an aggregate on overlap machine. A very basic
+ aggregation is summation of an integer. A interval_map<int,int> maps
+ intervals of int to ints.
+
+ If we insert a value pair (interval<int>(2,6), 1) into the interval_map, it
+ increases the content of all value pairs in the map by 1, if their interval
+ part overlaps with interval<int>(2,6).
+
+ \include overlap_counter/overlap_counter.cpp
+*/
+
+/* A interval_map<int, int> is a map<Interval<int>, int> that maps intervals
+ to int values. On overlap of intervals it sums up the associated int
+ values. */
+typedef interval_map<int, int> OverlapCounterTD;
+
+void print_overlaps(const OverlapCounterTD& counter)
+{
+ for(OverlapCounterTD::const_iterator it = counter.begin(); it != counter.end(); it++)
+ {
+ interval<int> itv = (*it).first;
+ int overlaps_count = (*it).second;
+ if(overlaps_count == 1)
+ cout << "in interval " << itv.as_string() << " intervals do not overlap" << endl;
+ else
+ cout << "in interval " << itv.as_string() << ": "<< overlaps_count << " intervals overlap" << endl;
+ }
+}
+
+void overlap_counter()
+{
+ OverlapCounterTD overlap_counter;
+ interval<int> itv;
+
+ itv = rightopen_interval(4,8);
+ cout << "-- adding " << itv.as_string() << " -----------------------------------------" << endl;
+ overlap_counter += make_pair(itv, 1);
+ print_overlaps(overlap_counter);
+ cout << "-----------------------------------------------------------" << endl;
+
+ itv = rightopen_interval(6,9);
+ cout << "-- adding " << itv.as_string() << " -----------------------------------------" << endl;
+ overlap_counter += make_pair(itv, 1);
+ print_overlaps(overlap_counter);
+ cout << "-----------------------------------------------------------" << endl;
+
+ itv = rightopen_interval(1,9);
+ cout << "-- adding " << itv.as_string() << " -----------------------------------------" << endl;
+ overlap_counter += make_pair(itv, 1);
+ print_overlaps(overlap_counter);
+ cout << "-----------------------------------------------------------" << endl;
+
+}
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample overlap_counter.cpp <<\n";
+ cout << "-----------------------------------------------------------\n";
+ overlap_counter();
+ return 0;
+}
+
+// Program output:
+
+// >> Interval Template Library: Sample overlap_counter.cpp <<
+// -----------------------------------------------------------
+// -- adding [4,8) -----------------------------------------
+// in interval [4,8) intervals do not overlap
+// -----------------------------------------------------------
+// -- adding [6,9) -----------------------------------------
+// in interval [4,6) intervals do not overlap
+// in interval [6,8): 2 intervals overlap
+// in interval [8,9) intervals do not overlap
+// -----------------------------------------------------------
+// -- adding [1,9) -----------------------------------------
+// in interval [1,4) intervals do not overlap
+// in interval [4,6): 2 intervals overlap
+// in interval [6,8): 3 intervals overlap
+// in interval [8,9): 2 intervals overlap
+// -----------------------------------------------------------
Added: sandbox/itl/libs/itl/example/overlap_counter/vc9_overlap_counter.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/overlap_counter/vc9_overlap_counter.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_overlap_counter"
+ ProjectGUID="{8DC9BDE4-E5A4-4294-A12F-D75FD6990B83}"
+ RootNamespace="overlap_counter"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\overlap_counter.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/party/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/party/Jamfile.v2 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,12 @@
+# (C) Copyright 2008: Joachim Faulhaber
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+exe party
+ :
+ party.cpp
+ :
+ <include>..
+ <include>../../..
+ <include>$(BOOST_ROOT)
+ ;
Added: sandbox/itl/libs/itl/example/party/party.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/party/party.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/interval_map.hpp>
+#include "../toytime.h"
+
+using namespace std;
+using namespace boost::itl;
+
+/** Example party.cpp \file Party.cpp
+
+ Party.cpp demonstrates the possibilities of an interval map (interval_map or
+ split_interval_map). An interval_map maps intervals to a given content. In
+ this case the content is a set of party guests represented by their name
+ strings.
+
+ As time goes by, groups of people join the party and leave later in the
+ evening. So we add a time interval and a name set to the interval_map for
+ the attendance of each group of people, that come together and leave
+ together.
+
+ On every overlap of intervals, the corresponding name sets are accumulated.
+ At the points of overlap the intervals are split. The accumulation of content
+ on overlap of intervals is always done via an operator += that has to be
+ implemented for the content parameter of the interval_map.
+
+ Finally the interval_map contains the history of attendance and all points
+ in time, where the group of party guests changed.
+
+ Party.cpp demonstrates a principle that we call aggregate on overlap
+ (aggovering;) On insertion a value associated to the interval is aggregated
+ (added) to those values in the interval_map that overlap with the inserted
+ value.
+
+ There are two behavioral aspects to aggovering: a decompositional behavior
+ and a accumulative behavior.
+
+ The decompositional behavior splits up intervals on the time dimension of
+ the interval_map so that the intervals change whenever associated values
+ change.
+
+ The accumulative behavior accumulates associated values on every overlap of
+ an insertion for the associated values.
+
+ \include party/party.cpp
+*/
+
+// Type itl::set<string> collects the names of party guests. Therefore it needs to
+// implement operator += that performs a set union on overlap of intervals.
+typedef boost::itl::set<string> GuestSetT;
+
+// Time is the domain type the the split_interval_map. It's key values are therefore
+// time intervals: interval<Time>. The content is the set of names: GuestSetT.
+
+typedef interval_map<Time, GuestSetT> PartyAttendenceHistoryT;
+
+void party()
+{
+ GuestSetT mary_harry;
+ mary_harry.insert("Mary");
+ mary_harry.insert("Harry");
+
+ GuestSetT diana_susan;
+ diana_susan.insert("Diana");
+ diana_susan.insert("Susan");
+
+ GuestSetT peter;
+ peter.insert("Peter");
+
+ PartyAttendenceHistoryT party;
+
+ party += make_pair( rightopen_interval<Time>(Time(19,30), Time(23,00)), mary_harry);
+ party += make_pair( rightopen_interval<Time>(Time(20,10), Time(monday,0,0)), diana_susan);
+ party += make_pair( rightopen_interval<Time>(Time(22,15), Time(monday,0,30)), peter);
+
+ PartyAttendenceHistoryT::iterator it = party.begin();
+ while(it != party.end())
+ {
+ interval<Time> when = (*it).first;
+ // Who is at the party within the time interval 'when' ?
+ GuestSetT who = (*it++).second;
+ cout << when.as_string() << ": " << who.as_string() << endl;
+ }
+}
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample party.cpp <<\n";
+ cout << "-------------------------------------------------------\n";
+ party();
+ return 0;
+}
+
+// Program output:
+
+// >> Interval Template Library: Sample party.cpp <<
+// -------------------------------------------------
+// [sun:19:30,sun:20:10): Harry Mary
+// [sun:20:10,sun:22:15): Diana Harry Mary Susan
+// [sun:22:15,sun:23:00): Diana Harry Mary Peter Susan
+// [sun:23:00,mon:00:00): Diana Peter Susan
+// [mon:00:00,mon:00:30): Peter
Added: sandbox/itl/libs/itl/example/party/vc9_party.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/party/vc9_party.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_party"
+ ProjectGUID="{6BE62DDE-21B9-4333-BF11-AA054DD43759}"
+ RootNamespace="Party"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="true"
+ AdditionalDependencies="boost_date_time-vc80-mt-gd-1_35.lib"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib;../../boost_1_35_0/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ UseUnicodeResponseFiles="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="false"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib;../../boost_1_35_0/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\party.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval_map.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/splititvmap_shell/splititvmap_shell.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/splititvmap_shell/splititvmap_shell.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,165 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2007-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------+
+splititvmap_shell.cpp provides a simple test shell for splitting interval maps.
+The shell also gives you a good idea how interval container are working.
++----------------------------------------------------------------------------*/
+#include <iostream>
+
+#include <boost/itl/split_interval_set.hpp>
+#include <boost/itl/split_interval_map.hpp>
+#include <boost/itl/interval_map.hpp>
+
+using namespace std;
+using namespace boost::itl;
+
+void instructions()
+{
+ cout << "+++++ Test shell for split interval map +++++\n";
+ cout << "Type: q e or 0 to quit\n";
+ cout << "Type: + for insertions\n";
+ cout << "Type: - for subtraction of ([a,b],value)\n";
+ cout << "Type: _ for subtraction of [a,b]\n";
+ cout << "Type: j to join contiguous intervals\n";
+ cout << "Type: s to compute total size\n";
+}
+
+void wrongInput()
+{
+ cout << "Wrong Input ------------------\n";
+ instructions();
+}
+
+
+template <class MapTV>
+void mapTestShell()
+{
+ MapTV m1;
+
+ try {
+ char cmd = 'b';
+ typename MapTV::domain_type
+ lwb = typename MapTV::domain_type(),
+ upb = typename MapTV::domain_type();
+
+ typename MapTV::codomain_type
+ val = typename MapTV::codomain_type();
+
+ instructions();
+
+ while(true)
+ {
+ cout << "> ";
+ cin >> cmd ;
+
+ switch(cmd)
+ {
+ case 'q':
+ case 'e':
+ case '0': cout << "good bye\n"; return;
+ case '+':
+ {
+ cout << "input: lwb upb val >> ";
+ cin >> lwb >> upb >> val;
+ typename MapTV::interval_type
+ itv = typename MapTV::interval_type(lwb,upb);
+ m1 += make_pair(itv,val);
+
+ cout << "+" << itv.as_string().c_str()<<" "<<val<< " =" << endl;
+ cout << "{" << m1.as_string() << "}" << endl;
+
+ }
+ break;
+ case '-':
+ {
+ cout << "input: lwb upb val >> ";
+ cin >> lwb >> upb >> val;
+ typename MapTV::interval_type
+ itv = typename MapTV::interval_type(lwb,upb);
+ m1 -= make_pair(itv,val);
+
+ cout << "-" << itv.as_string().c_str()<<" "<<val<< " =" << endl;
+ cout << "{" << m1.as_string() << "}" << endl;
+
+ }
+ break;
+ //JODO REV
+ //case '_':
+ // {
+ // cout << "input: lwb upb >> ";
+ // cin >> lwb >> upb;
+ // typename MapTV::interval_type
+ // itv = typename MapTV::interval_type(lwb,upb);
+ // split_interval_set<typename MapTV::domain_type> sgl(itv);
+ // m1.erase(itv);
+
+ // cout << "_" << itv.as_string().c_str()<<" "<< " =" << endl;
+ // cout << "{" << m1.as_string() << "}" << endl;
+
+ // }
+ // break;
+ case 'j':
+ {
+ m1.join();
+ cout << "{" << m1.as_string() << "}" << endl;
+ }
+ break;
+ case 's':
+ {
+ cout << "size = " << m1.size() << endl;
+ }
+ break;
+
+ default: wrongInput();
+ }
+ } // end while
+ }
+ catch (exception& e)
+ {
+ cout << "splititvmap_shell: exception caught: " << endl
+ << e.what() << endl;
+ }
+ catch (...)
+ {
+ cout << "splititvmap_shell: unknown exception caught" << endl;
+ }
+}
+
+
+int main()
+{
+ cout << ">> Interval Template Library: Test splititvmap_shell.cpp <<\n";
+ cout << "-----------------------------------------------------------\n";
+ mapTestShell< interval_map<int, int> >(); //JODO REV
+
+ return 0;
+}
+
Added: sandbox/itl/libs/itl/example/splititvmap_shell/vc9_splititvmap_shell.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/splititvmap_shell/vc9_splititvmap_shell.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_splititvmap_shell"
+ ProjectGUID="{639F6AD9-CD50-40BF-92B9-CC9DD069D65A}"
+ RootNamespace="splititvmap_shell"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/Debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\splititvmap_shell.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\interval.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\itl\split_interval_map.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/example/toytime.h
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/toytime.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,75 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+namespace boost{namespace itl
+{
+
+/** Time is a toy-class to demonstrate a class that conforms the requirements of
+ a template parameter for class IntervalT.
+
+ In real world applications you may want to use the integer representation of a
+ time variable. That way intervals and their containers are working most efficiently.
+*/
+
+enum {sunday=0, monday, tuesday, wednesday, thursday, friday, saturday};
+static const char* daynames[] = {"sun", "mon", "tue", "wed", "thu", "fri", "sat"};
+
+class Time
+{
+public:
+ Time(): m_time(0) {}
+ Time(int hours, int minutes): m_time(60*hours+minutes) {}
+ Time(int day, int hours, int minutes): m_time((24*60)*day+60*hours+minutes) {}
+ int getDay()const { return m_time/(24*60); }
+ int getHours()const { return (m_time%(24*60))/60; }
+ int getMinutes()const { return (m_time%(24*60))%60; }
+ int asInt()const { return m_time; }
+ std::string getDayString()const { return daynames[getDay()]; }
+
+ std::string as_string()const
+ {
+ const int MAX_TIMESTING_LEN = 256;
+ char repr[MAX_TIMESTING_LEN];
+ sprintf(repr, "%3s:%02d:%02d", getDayString().c_str(), getHours(), getMinutes());
+ return std::string(repr);
+ }
+
+ Time& operator ++ () { m_time++; return *this; }
+ Time& operator -- () { m_time--; return *this; }
+
+private:
+ int m_time;
+};
+
+
+bool operator < (const Time& x1, const Time& x2) { return x1.asInt() < x2.asInt(); }
+bool operator == (const Time& x1, const Time& x2) { return x1.asInt() == x2.asInt(); }
+bool operator <= (const Time& x1, const Time& x2) { return x1.asInt() <= x2.asInt(); }
+
+}} // namespace itl boost
+
Added: sandbox/itl/libs/itl/example/user_groups/user_groups.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/user_groups/user_groups.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,202 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+
+// The next line includes <boost/gregorian/date.hpp>
+// and a few lines of adapter code.
+#include <boost/itl/gregorian.hpp>
+
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
+using namespace std;
+using namespace boost::gregorian;
+using namespace boost::itl;
+
+/** Example user_groups.cpp \file user_groups.cpp
+
+ Example user_groups.cpp shows the availability of set operations
+ on interval maps.
+
+ In the example there is a user group 'med_users' of a hospial staff
+ that has the authorisation to handle medical data of patients.
+ User group 'admin_users' has access to aministrative data like
+ health inshurance and financial data.
+
+ The membership for each user in one of the user groups has a time
+ interval of validity. The group membership begins and ends.
+
+ Using a union operation += we can have an overview over both
+ user groups and the memebership dates of employees.
+
+ Computing an intersection (*=) shows who is member of both med_users
+ and admin_users at what times.
+
+ \include user_groups/user_groups.cpp
+*/
+
+// Type itl::set<string> collects the names a user group's members. Therefore
+// it needs to implement operator += that performs a set union on overlap of
+// intervals.
+typedef boost::itl::set<string> MemberSetT;
+
+// boost::gregorian::date is the domain type the the interval map.
+// It's key values are therefore time intervals: interval<date>. The content
+// is the set of names: MemberSetT.
+typedef interval_map<date, MemberSetT> MembershipT;
+
+// Collect user groups for medical and administrative staff and perform
+// union and intersection operations on the collected membership schedules.
+void user_groups()
+{
+ MemberSetT mary_harry;
+ mary_harry.insert("Mary");
+ mary_harry.insert("Harry");
+
+ MemberSetT diana_susan;
+ diana_susan.insert("Diana");
+ diana_susan.insert("Susan");
+
+ MemberSetT chief_physician;
+ chief_physician.insert("Dr.Jekyll");
+
+ MemberSetT director_of_admin;
+ director_of_admin.insert("Mr.Hyde");
+
+ //----- Collecting members of user group: med_users -------------------
+ MembershipT med_users;
+
+ med_users.add( // add and element
+ make_pair(
+ closed_interval<date>(
+ from_string("2008-01-01"), from_string("2008-12-31")), mary_harry));
+
+ med_users += // element addition can also be done via operator +=
+ make_pair(
+ closed_interval<date>(
+ from_string("2008-01-15"), from_string("2008-12-31")),
+ chief_physician);
+
+ med_users +=
+ make_pair(
+ closed_interval<date>(
+ from_string("2008-02-01"), from_string("2008-10-15")),
+ director_of_admin);
+
+ //----- Collecting members of user group: admin_users ------------------
+ MembershipT admin_users;
+
+ admin_users += // element addition can also be done via operator +=
+ make_pair(
+ closed_interval<date>(
+ from_string("2008-03-20"), from_string("2008-09-30")), diana_susan);
+
+ admin_users +=
+ make_pair(
+ closed_interval<date>(
+ from_string("2008-01-15"), from_string("2008-12-31")),
+ chief_physician);
+
+ admin_users +=
+ make_pair(
+ closed_interval<date>(
+ from_string("2008-02-01"), from_string("2008-10-15")),
+ director_of_admin);
+
+ MembershipT all_users = med_users;
+ all_users += admin_users;
+
+ MembershipT super_users = med_users;
+ super_users *= admin_users;
+
+ MembershipT::iterator med_ = med_users.begin();
+ cout << "----- Membership of medical staff -----------------------------------\n";
+ while(med_ != med_users.end())
+ {
+ interval<date> when = (*med_).first;
+ // Who is member of group med_users within the time interval 'when' ?
+ MemberSetT who = (*med_++).second;
+ cout << "[" << when.first() << " - " << when.last() << "]"
+ << ": " << who.as_string() << endl;
+ }
+
+ MembershipT::iterator admin_ = admin_users.begin();
+ cout << "----- Membership of admin staff -------------------------------------\n";
+ while(admin_ != admin_users.end())
+ {
+ interval<date> when = (*admin_).first;
+ // Who is member of group admin_users within the time interval 'when' ?
+ MemberSetT who = (*admin_++).second;
+ cout << "[" << when.first() << " - " << when.last() << "]"
+ << ": " << who.as_string() << endl;
+ }
+
+ MembershipT::iterator all_ = all_users.begin();
+ cout << "----- Membership of all users (med + admin) -------------------------\n";
+ while(all_ != all_users.end())
+ {
+ interval<date> when = (*all_).first;
+ // Who is member of group med_users OR admin_users ?
+ MemberSetT who = (*all_++).second;
+ cout << "[" << when.first() << " - " << when.last() << "]"
+ << ": " << who.as_string() << endl;
+ }
+
+ MembershipT::iterator super_ = super_users.begin();
+ cout << "----- Membership of super users: intersection(med,admin) ------------\n";
+ while(super_ != super_users.end())
+ {
+ interval<date> when = (*super_).first;
+ // Who is member of group med_users AND admin_users ?
+ MemberSetT who = (*super_++).second;
+ cout << "[" << when.first() << " - " << when.last() << "]"
+ << ": " << who.as_string() << endl;
+ }
+
+}
+
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample user_groups.cpp <<\n";
+ cout << "-------------------------------------------------------\n";
+ user_groups();
+ return 0;
+}
+
+// Program output:
+/*-----------------------------------------------------------------------------
+>> Interval Template Library: Sample user_groups.cpp <<
+-------------------------------------------------------
+----- Membership of medical staff -----------------------------------
+[2008-Jan-01 - 2008-Jan-14]: Harry Mary
+[2008-Jan-15 - 2008-Jan-31]: Dr.Jekyll Harry Mary
+[2008-Feb-01 - 2008-Oct-15]: Dr.Jekyll Harry Mary Mr.Hyde
+[2008-Oct-16 - 2008-Dec-31]: Dr.Jekyll Harry Mary
+----- Membership of admin staff -------------------------------------
+[2008-Jan-15 - 2008-Jan-31]: Dr.Jekyll
+[2008-Feb-01 - 2008-Mar-19]: Dr.Jekyll Mr.Hyde
+[2008-Mar-20 - 2008-Sep-30]: Diana Dr.Jekyll Mr.Hyde Susan
+[2008-Oct-01 - 2008-Oct-15]: Dr.Jekyll Mr.Hyde
+[2008-Oct-16 - 2008-Dec-31]: Dr.Jekyll
+----- Membership of all users (med + admin) -------------------------
+[2008-Jan-01 - 2008-Jan-14]: Harry Mary
+[2008-Jan-15 - 2008-Jan-31]: Dr.Jekyll Harry Mary
+[2008-Feb-01 - 2008-Mar-19]: Dr.Jekyll Harry Mary Mr.Hyde
+[2008-Mar-20 - 2008-Sep-30]: Diana Dr.Jekyll Harry Mary Mr.Hyde Susan
+[2008-Oct-01 - 2008-Oct-15]: Dr.Jekyll Harry Mary Mr.Hyde
+[2008-Oct-16 - 2008-Dec-31]: Dr.Jekyll Harry Mary
+----- Membership of super users: intersection(med,admin) ------------
+[2008-Jan-15 - 2008-Jan-31]: Dr.Jekyll
+[2008-Feb-01 - 2008-Oct-15]: Dr.Jekyll Mr.Hyde
+[2008-Oct-16 - 2008-Dec-31]: Dr.Jekyll
+-----------------------------------------------------------------------------*/
Added: sandbox/itl/libs/itl/example/user_groups/vc9_user_groups.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/example/user_groups/vc9_user_groups.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_user_groups"
+ ProjectGUID="{900B8478-E01B-4ECD-A4D6-DC88DD5BF4A1}"
+ RootNamespace="User_groups"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="true"
+ AdditionalDependencies="boost_date_time-vc90-mt-gd-1_35.lib"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ AssemblyDebug="1"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ UseUnicodeResponseFiles="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseUnicodeResponseFiles="false"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\user_groups.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\src\itl\interval.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\interval_base_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\split_interval_map.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/Jamfile.v2 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,27 @@
+# (C) Copyright 2008: Joachim Faulhaber
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# bring in rules for testing
+import testing ;
+import feature ;
+
+project
+ : requirements
+ <library>/boost/test//boost_unit_test_framework
+ <library>/boost/date_time//boost_date_time
+ <link>static
+ <include>../../..
+ ;
+
+test-suite "itl"
+ :
+ [ run test_itl_interval/test_itl_interval.cpp ]
+ [ run test_interval_set/test_interval_set.cpp ]
+ [ run test_separate_interval_set/test_separate_interval_set.cpp ]
+ [ run test_split_interval_set/test_split_interval_set.cpp ]
+ [ run test_interval_set_mixed/test_interval_set_mixed.cpp ]
+ [ run test_interval_map/test_interval_map.cpp ]
+ [ run test_split_interval_map/test_split_interval_map.cpp ]
+ [ run test_interval_map_mixed/test_interval_map_mixed.cpp ]
+ ;
Added: sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,35 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/interval_map.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+// -----------------------------------------------------------------------------
+// test_interval_set_shared are tests that should give identical results for all
+// interval_sets: interval_set, separate_interval_set and split_interval_set.
+#include "../test_interval_map_shared.hpp"
+
+// Due to limited expressiveness of the testing framework, the testcode in files
+// test_interval_map{,_split}_shared.cpp is generated through code
+// replication.
+#include "test_interval_map_shared.cpp"
+
+
Added: sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,52 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_fundamentals_4_ordered_types, T, ordered_types)
+{ interval_map_fundamentals_4_ordered_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_ctor_4_bicremental_types, T, bicremental_types)
+{ interval_map_ctor_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_add_sub_4_bicremental_types, T, bicremental_types)
+{ interval_map_add_sub_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_distinct_4_bicremental_types, T, bicremental_types)
+{ interval_map_distinct_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_distinct_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_map_distinct_4_bicremental_continuous_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_isolate_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_map_isolate_4_bicremental_continuous_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_contains_4_bicremental_types, T, bicremental_types)
+{ interval_map_contains_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_operators_4_bicremental_types, T, bicremental_types)
+{ interval_map_operators_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_base_intersect_4_bicremental_types, T, bicremental_types)
+{ interval_map_base_intersect_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_base_erase_4_bicremental_types, T, bicremental_types)
+{ interval_map_base_erase_4_bicremental_types<interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_base_is_disjoint_4_bicremental_types, T, bicremental_types)
+{ interval_map_base_is_disjoint_4_bicremental_types<interval_map, T, int>();}
+
Added: sandbox/itl/libs/itl/test/test_interval_map/vc9_test_interval_map.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_map/vc9_test_interval_map.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_interval_map"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9D}"
+ RootNamespace="Test_interval_map"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_interval_map.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\test_interval_map_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,1174 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl/separate_interval_set.hpp>
+#include <boost/itl/split_interval_set.hpp>
+#include <boost/itl/interval_map.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_ctor_4_ordered_types, T, ordered_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+
+ T v0 = neutron<T>::value();
+ U u1 = unon<U>::value();
+
+ SplitIntervalMapT split_map(make_pair(v0,u1));
+ IntervalMapT join_map(split_map);
+
+ BOOST_CHECK_EQUAL( split_map.lower(), join_map.lower() );
+ BOOST_CHECK_EQUAL( split_map.upper(), join_map.upper() );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_equal_4_ordered_types, T, ordered_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+
+ T v0 = neutron<T>::value();
+ U u1 = unon<U>::value();
+
+ SplitIntervalMapT split_empty, split_single(make_pair(v0,u1));
+ IntervalMapT join_empty, join_single(make_pair(v0,u1));
+
+ // mixed ==-equality is a strange thing. Most times is does not
+ // make sense. It is better to allow only for same type == equality.
+ BOOST_CHECK_EQUAL( split_empty == split_empty, true );
+ BOOST_CHECK_EQUAL( join_empty == join_empty, true );
+
+ // There were Problems with operator== and emtpy sets.
+ BOOST_CHECK_EQUAL( split_empty == split_single, false );
+ BOOST_CHECK_EQUAL( join_empty == join_single, false );
+
+ BOOST_CHECK_EQUAL( split_single == split_empty, false );
+ BOOST_CHECK_EQUAL( join_single == join_empty, false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, split_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, join_empty), true );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, split_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, join_empty), true );
+
+ //--------------------------------------------------------------------------
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, split_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, join_single), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, split_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, join_single), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_single, split_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(split_single, join_empty), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_single, split_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(join_single, join_empty), false );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_assign_4_ordered_types, T, ordered_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+
+ T v0 = neutron<T>::value();
+ T v1 = unon<T>::value();
+ U u1 = unon<U>::value();
+
+ base_pair<T,U> v0_u1(v0,u1);
+ base_pair<T,U> v1_u1(v1,u1);
+
+ SplitIntervalMapT split_map;
+ IntervalMapT join_map;
+ split_map.add(v0_u1); //JODO make_pair(v0,u1); fails
+ join_map = split_map;
+
+ BOOST_CHECK_EQUAL( split_map.lower(), join_map.lower() );
+ BOOST_CHECK_EQUAL( split_map.upper(), join_map.upper() );
+
+ SplitIntervalMapT split_self = SplitIntervalMapT().add(v0_u1);
+ IntervalMapT join_self = IntervalMapT().add(v1_u1);
+
+ split_self = split_self;
+ join_self = join_self;
+
+ BOOST_CHECK_EQUAL( split_self, split_self );
+ BOOST_CHECK_EQUAL( join_self, join_self );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_ctor_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I2_4D_1(I2_4D, u1);
+ std::pair<interval<T>,U> I4_5D_1(I4_5D, u1);
+
+ SplitIntervalMapT split_map;
+ split_map.add(I1_3D_1).add(I2_4D_1).add(I4_5D_1);
+ BOOST_CHECK_EQUAL( split_map.iterative_size(), 4 );
+ IntervalMapT join_map(split_map);
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_assign_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I2_4D_1(I2_4D, u1);
+ std::pair<interval<T>,U> I4_5D_1(I4_5D, u1);
+
+ SplitIntervalMapT split_map;
+ split_map.add(I1_3D_1).add(I2_4D_1).add(I4_5D_1);
+ BOOST_CHECK_EQUAL( split_map.iterative_size(), 4 );
+ IntervalMapT join_map;
+ join_map = split_map;
+ BOOST_CHECK_EQUAL( join_map.iterative_size(), 3 );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_equal_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I2_4D_1(I2_4D, u1);
+ std::pair<interval<T>,U> I4_5D_1(I4_5D, u1);
+
+ IntervalMapT join_map;
+ join_map.add(I1_3D_1).add(I2_4D_1).add(I4_5D_1);
+ IntervalMapT join_map2 = join_map;
+ BOOST_CHECK_EQUAL( join_map, join_map2 );
+ BOOST_CHECK_EQUAL( is_element_equal(join_map, join_map2), true );
+
+ SplitIntervalMapT split_map;
+ split_map.add(I1_3D_1).add(I2_4D_1).add(I4_5D_1);
+ SplitIntervalMapT split_map2 = split_map;
+ BOOST_CHECK_EQUAL( split_map, split_map2 );
+ BOOST_CHECK_EQUAL( is_element_equal(split_map2, split_map), true );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_map, join_map), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_map, split_map), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_add_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I2_4D_1(I2_4D, u1);
+ std::pair<interval<T>,U> I4_5D_1(I4_5D, u1);
+ base_pair<T,U> v1_1(v1, u1);
+ base_pair<T,U> v3_1(v3, u1);
+ base_pair<T,U> v5_1(v5, u1);
+
+ SplitIntervalMapT split_map;
+ split_map.add(I1_3D_1).add(I2_4D_1);
+ split_map += I4_5D_1;
+ BOOST_CHECK_EQUAL( split_map.iterative_size(), 4 );
+ IntervalMapT join_map;
+ join_map += split_map;
+ BOOST_CHECK_EQUAL( join_map.iterative_size(), 3 );
+
+ IntervalMapT join_map3;
+ join_map3.add(v1_1).add(v3_1);
+ join_map3 += v5_1;
+ BOOST_CHECK_EQUAL( join_map3.iterative_size(), 3 );
+ SplitIntervalMapT split_map3;
+ split_map3 += join_map3;
+ BOOST_CHECK_EQUAL( split_map3.iterative_size(), 3 );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_subtract_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ std::pair<interval<T>,U> I0_4D_1(I0_4D, u1);
+ std::pair<interval<T>,U> I2_6D_1(I2_6D, u1);
+ std::pair<interval<T>,U> I3_6D_1(I3_6D, u1);
+ std::pair<interval<T>,U> I5_7D_1(I5_7D, u1);
+ std::pair<interval<T>,U> I7_8D_1(I7_8D, u1);
+ std::pair<interval<T>,U> I8_9D_1(I8_9D, u1);
+ std::pair<interval<T>,U> I8_9I_1(I8_9I, u1);
+
+ //JODO INSIGHT: With respect to subtraction all interval_sets are working equivalently:
+ //Never does a subtract operation introduce or preserve interval borders within
+ //the range of the subtracted elements. This is almost trivial.
+ //LAW: y -= x == y -= x.join()
+ SplitIntervalMapT split_map;
+ split_map.add(I0_4D_1).add(I2_6D_1).add(I5_7D_1).add(I7_8D_1).add(I8_9I_1);
+ BOOST_CHECK_EQUAL( split_map.iterative_size(), 7 );
+
+ IntervalMapT join_map;
+ join_map.add(I0_4D_1).add(I2_6D_1).add(I5_7D_1).add(I7_8D_1).add(I8_9I_1);
+ BOOST_CHECK_EQUAL( join_map.iterative_size(), 5 );
+
+ // Make maps to be subtracted
+ SplitIntervalMapT split_sub;
+ split_sub.add(I3_6D_1).add(I8_9D_1);
+
+ IntervalMapT join_sub;
+ join_sub.add(I3_6D_1).add(I8_9D_1);
+
+ //--------------------------------------------------------------------------
+ // Test for split_interval_map
+ SplitIntervalMapT split_diff = split_map;
+ IntervalMapT join_diff = join_map;
+
+ //subtraction combinations
+ split_diff -= split_sub;
+ join_diff -= split_sub;
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 7 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 5 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for interval_map. Reinitialize
+ split_diff = split_map;
+ join_diff = join_map;
+
+ //subtraction combinations
+ split_diff -= join_sub;
+ join_diff -= join_sub;
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 7 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 5 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_erase_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ std::pair<interval<T>,U> I0_4D_1(I0_4D, u1);
+ std::pair<interval<T>,U> I2_6D_1(I2_6D, u1);
+ std::pair<interval<T>,U> I3_6D_1(I3_6D, u1);
+ std::pair<interval<T>,U> I5_7D_1(I5_7D, u1);
+ std::pair<interval<T>,U> I7_8D_1(I7_8D, u1);
+ std::pair<interval<T>,U> I8_9D_1(I8_9D, u1);
+ std::pair<interval<T>,U> I8_9I_1(I8_9I, u1);
+
+ //JODO INSIGHT: With respect to subtraction all interval_sets are working equivalently:
+ //Never does a subtract operation introduce or preserve interval borders within
+ //the range of the subtracted elements. This is almost trivial.
+ //LAW: y -= x == y -= x.join()
+ SplitIntervalMapT split_map;
+ split_map.add(I0_4D_1).add(I2_6D_1).add(I5_7D_1).add(I7_8D_1).add(I8_9I_1);
+ BOOST_CHECK_EQUAL( split_map.iterative_size(), 7 );
+
+ IntervalMapT join_map;
+ join_map.add(I0_4D_1).add(I2_6D_1).add(I5_7D_1).add(I7_8D_1).add(I8_9I_1);
+ BOOST_CHECK_EQUAL( join_map.iterative_size(), 5 );
+
+ // Make sets to be erased
+ SplitIntervalMapT split_sub;
+ split_sub.add(I3_6D_1).add(I8_9D_1);
+
+ IntervalMapT join_sub;
+ join_sub.add(I3_6D_1).add(I8_9D_1);
+
+ //--------------------------------------------------------------------------
+ // Test for split_interval_map
+ SplitIntervalMapT split_diff = split_map;
+ IntervalMapT join_diff = join_map;
+
+ //subtraction combinations
+ erase(split_diff, split_sub);
+ erase(join_diff, split_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 6 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 5 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for interval_map. Reinitialize
+ split_diff = split_map;
+ join_diff = join_map;
+
+ //subtraction combinations
+ erase(split_diff, join_sub);
+ erase(join_diff, join_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 6 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 5 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_erase2_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ std::pair<interval<T>,U> I0_4D_1(I0_4D, u1);
+ std::pair<interval<T>,U> I2_6D_1(I2_6D, u1);
+ std::pair<interval<T>,U> I3_6D_1(I3_6D, u1);
+ std::pair<interval<T>,U> I5_7D_1(I5_7D, u1);
+ std::pair<interval<T>,U> I7_8D_1(I7_8D, u1);
+ std::pair<interval<T>,U> I8_9D_1(I8_9D, u1);
+ std::pair<interval<T>,U> I8_9I_1(I8_9I, u1);
+
+ //JODO INSIGHT: With respect to subtraction all interval_sets are working equivalently:
+ //Never does a subtract operation introduce or preserve interval borders within
+ //the range of the subtracted elements. This is almost trivial.
+ //LAW: y -= x == y -= x.join()
+ SplitIntervalMapT split_map;
+ split_map.add(I0_4D_1).add(I2_6D_1).add(I5_7D_1).add(I7_8D_1).add(I8_9I_1);
+ BOOST_CHECK_EQUAL( split_map.iterative_size(), 7 );
+
+ IntervalMapT join_map;
+ join_map.add(I0_4D_1).add(I2_6D_1).add(I5_7D_1).add(I7_8D_1).add(I8_9I_1);
+ BOOST_CHECK_EQUAL( join_map.iterative_size(), 5 );
+
+ // Make sets to be erased
+ SplitIntervalSetT split_sub;
+ split_sub.add(I3_6D).add(I8_9D);
+
+ IntervalSetT join_sub;
+ join_sub.add(I3_6D).add(I8_9D);
+
+ //--------------------------------------------------------------------------
+ // Test for split_interval_map
+ SplitIntervalMapT split_diff = split_map;
+ IntervalMapT join_diff = join_map;
+
+ //subtraction combinations
+ erase(split_diff, split_sub);
+ erase(join_diff, split_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 4 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for interval_map. Reinitialize
+ split_diff = split_map;
+ join_diff = join_map;
+
+ //subtraction combinations
+ erase(split_diff, join_sub);
+ erase(join_diff, join_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 4 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_insert_erase_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ std::pair<interval<T>,U> I0_4D_1(I0_4D, u1);
+ std::pair<interval<T>,U> I2_6D_1(I2_6D, u1);
+ std::pair<interval<T>,U> I3_6D_1(I3_6D, u1);
+ std::pair<interval<T>,U> I5_7D_1(I5_7D, u1);
+ std::pair<interval<T>,U> I7_8D_1(I7_8D, u1);
+ std::pair<interval<T>,U> I8_9D_1(I8_9D, u1);
+ std::pair<interval<T>,U> I8_9I_1(I8_9I, u1);
+
+ SplitIntervalMapT split_A, split_B, split_all, split_X;
+ IntervalMapT join_A, join_B, join_all, join_X;
+
+ split_all.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1).insert(I7_8D_1).insert(I8_9I_1);
+ split_A.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1);
+ split_B.insert(I7_8D_1).insert(I8_9I_1);
+
+ join_all.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1).insert(I7_8D_1).insert(I8_9I_1);
+ join_A.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1);
+ join_B.insert(I7_8D_1).insert(I8_9I_1);
+
+ //-------------------------------------------------------------------------
+ insert(split_X, split_A);
+ BOOST_CHECK_EQUAL( split_X, split_A );
+ insert(split_X, split_B);
+ BOOST_CHECK_EQUAL( split_X, split_all );
+
+ erase(split_X, split_B);
+ BOOST_CHECK_EQUAL( split_X, split_A );
+ erase(split_X, split_A);
+ BOOST_CHECK_EQUAL( split_X, SplitIntervalMapT() );
+
+ //-------------------------------------------------------------------------
+ insert(join_X, join_A);
+ BOOST_CHECK_EQUAL( join_X, join_A );
+ insert(join_X, join_B);
+ BOOST_CHECK_EQUAL( join_X, join_all );
+
+ erase(join_X, join_B);
+ BOOST_CHECK_EQUAL( join_X, join_A );
+ erase(join_X, join_A);
+ BOOST_CHECK_EQUAL( join_X, IntervalMapT() );
+
+ //-------------------------------------------------------------------------
+ split_X.clear();
+ insert(split_X, join_A);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, split_A), true );
+ insert(split_X, join_B);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, split_all), true );
+
+ erase(split_X, join_B);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, split_A), true );
+ erase(split_X, join_A);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, SplitIntervalMapT()), true );
+
+ //-------------------------------------------------------------------------
+ split_X.clear();
+ insert(join_X, split_A);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, split_A), true );
+ insert(join_X, split_B);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, join_all), true );
+
+ erase(join_X, split_B);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, split_A), true );
+ erase(join_X, split_A);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, IntervalMapT()), true );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_insert_erase2_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ std::pair<interval<T>,U> I0_4D_1(I0_4D, u1);
+ std::pair<interval<T>,U> I2_6D_1(I2_6D, u1);
+ std::pair<interval<T>,U> I3_6D_1(I3_6D, u1);
+ std::pair<interval<T>,U> I5_7D_1(I5_7D, u1);
+ std::pair<interval<T>,U> I7_8D_1(I7_8D, u1);
+ std::pair<interval<T>,U> I8_9D_1(I8_9D, u1);
+ std::pair<interval<T>,U> I8_9I_1(I8_9I, u1);
+
+ SplitIntervalMapT split_A, split_B, split_all, split_X;
+ IntervalMapT join_A, join_B, join_all, join_X;
+ SplitIntervalSetT split_dA, split_dB;
+ IntervalSetT join_dA, join_dB;
+
+ split_all.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1).insert(I7_8D_1).insert(I8_9I_1);
+ split_A.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1);
+ split_B.insert(I7_8D_1).insert(I8_9I_1);
+
+ join_all.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1).insert(I7_8D_1).insert(I8_9I_1);
+ join_A.insert(I0_4D_1).insert(I2_6D_1).insert(I5_7D_1);
+ join_B.insert(I7_8D_1).insert(I8_9I_1);
+
+ split_A.domain(split_dA);
+ split_B.domain(split_dB);
+ join_A.domain(join_dA);
+ join_B.domain(join_dB);
+
+ //-------------------------------------------------------------------------
+ insert(split_X, split_A);
+ BOOST_CHECK_EQUAL( split_X, split_A );
+ insert(split_X, split_B);
+ BOOST_CHECK_EQUAL( split_X, split_all );
+
+ erase(split_X, split_dB);
+ BOOST_CHECK_EQUAL( split_X, split_A );
+ erase(split_X, split_dA);
+ BOOST_CHECK_EQUAL( split_X, SplitIntervalMapT() );
+
+ //-------------------------------------------------------------------------
+ insert(join_X, join_A);
+ BOOST_CHECK_EQUAL( join_X, join_A );
+ insert(join_X, join_B);
+ BOOST_CHECK_EQUAL( join_X, join_all );
+
+ erase(join_X, join_dB);
+ BOOST_CHECK_EQUAL( join_X, join_A );
+ erase(join_X, join_dA);
+ BOOST_CHECK_EQUAL( join_X, IntervalMapT() );
+
+ //-------------------------------------------------------------------------
+ split_X.clear();
+ insert(split_X, join_A);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, split_A), true );
+ insert(split_X, join_B);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, split_all), true );
+
+ erase(split_X, join_dB);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, split_A), true );
+ erase(split_X, join_dA);
+ BOOST_CHECK_EQUAL( is_element_equal(split_X, SplitIntervalMapT()), true );
+
+ //-------------------------------------------------------------------------
+ split_X.clear();
+ insert(join_X, split_A);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, split_A), true );
+ insert(join_X, split_B);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, join_all), true );
+
+ erase(join_X, split_dB);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, split_A), true );
+ erase(join_X, split_dA);
+ BOOST_CHECK_EQUAL( is_element_equal(join_X, IntervalMapT()), true );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_basic_intersect_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+ U u2 = make<U>(2);
+ U u3 = make<U>(3);
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+
+
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I1_8D = rightopen_interval(v1,v8);
+ interval<T> I2_7D = rightopen_interval(v2,v7);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I6_7D = rightopen_interval(v6,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ std::pair<interval<T>,U> I0_3D_1(I0_3D, u1);
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I1_3D_2(I1_3D, u2);
+ std::pair<interval<T>,U> I1_8D_1(I1_8D, u1);
+ std::pair<interval<T>,U> I2_7D_1(I2_7D, u1);
+ std::pair<interval<T>,U> I2_3D_1(I2_3D, u1);
+ std::pair<interval<T>,U> I2_3D_3(I2_3D, u3);
+ std::pair<interval<T>,U> I6_7D_1(I6_7D, u1);
+ std::pair<interval<T>,U> I6_7D_3(I6_7D, u3);
+ std::pair<interval<T>,U> I6_8D_1(I6_8D, u1);
+ std::pair<interval<T>,U> I6_8D_2(I6_8D, u2);
+ std::pair<interval<T>,U> I6_9D_1(I6_9D, u1);
+
+ //--------------------------------------------------------------------------
+ // split_interval_map
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // *= [1 8)
+ //split_AB -> [1 3) [6 8)
+ // *= [2 7)
+ // -> [2 3) [6 7)
+ SplitIntervalMapT split_A, split_B, split_AB, split_ab, split_ab2;
+
+ split_A.add(I0_3D_1).add(I6_9D_1);
+ split_AB = split_A;
+ split_AB *= I1_8D_1;
+ split_ab.add(I1_3D_2).add(I6_8D_2);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ (split_AB *= I1_8D_1) *= I2_7D_1;
+ split_ab2.add(I2_3D_3).add(I6_7D_3);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab2 );
+
+
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // 1 1
+ // *= 1
+ // 1
+ //split_AB -> [1]
+ // 2
+ // += (1 7)
+ // 2
+ // -> [1](1 7)
+ // 2 2
+ split_A.clear();
+ split_A.add(I0_3D_1).add(I6_9D_1);
+ split_AB = split_A;
+ split_AB *= base_pair<T,U>(v1,u1);
+ split_ab.clear();
+ split_ab.add(base_pair<T,U>(v1,u2));
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ //(split_AB *= base_pair<T,U>(v1,u1)) += make_pair(open_interval<T>(v1,v7), u1); //JODO
+ split_AB *= base_pair<T,U>(v1,u1);
+ split_AB += make_pair(open_interval<T>(v1,v7), u2);
+ split_ab2.clear();
+ split_ab2 += make_pair(rightopen_interval<T>(v1,v7), u2);
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_AB, split_ab2), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_basic_intersect2_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+ U u2 = make<U>(2);
+ U u3 = make<U>(3);
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+
+
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I1_8D = rightopen_interval(v1,v8);
+ interval<T> I2_7D = rightopen_interval(v2,v7);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I6_7D = rightopen_interval(v6,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ std::pair<interval<T>,U> I0_3D_1(I0_3D, u1);
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I1_3D_2(I1_3D, u2);
+ std::pair<interval<T>,U> I1_8D_1(I1_8D, u1);
+ std::pair<interval<T>,U> I2_7D_1(I2_7D, u1);
+ std::pair<interval<T>,U> I2_3D_1(I2_3D, u1);
+ std::pair<interval<T>,U> I2_3D_3(I2_3D, u3);
+ std::pair<interval<T>,U> I6_7D_1(I6_7D, u1);
+ std::pair<interval<T>,U> I6_7D_3(I6_7D, u3);
+ std::pair<interval<T>,U> I6_8D_1(I6_8D, u1);
+ std::pair<interval<T>,U> I6_8D_2(I6_8D, u2);
+ std::pair<interval<T>,U> I6_9D_1(I6_9D, u1);
+
+ //--------------------------------------------------------------------------
+ // split_interval_map
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // *= [1 8)
+ //split_AB -> [1 3) [6 8)
+ // *= [2 7)
+ // -> [2 3) [6 7)
+ SplitIntervalMapT split_A, split_B, split_AB, split_ab, split_ab2;
+
+ split_A.add(I0_3D_1).add(I6_9D_1);
+ split_AB = split_A;
+ split_AB *= I1_8D;
+ split_ab.add(I1_3D_1).add(I6_8D_1);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ (split_AB *= I1_8D) *= I2_7D;
+ split_ab2.add(I2_3D_1).add(I6_7D_1);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab2 );
+
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // 1 1
+ // *= 1
+ // 1
+ //split_AB -> [1]
+ // 2
+ // += (1 7)
+ // 2
+ // -> [1](1 7)
+ // 2 2
+ split_A.clear();
+ split_A.add(I0_3D_1).add(I6_9D_1);
+ split_AB = split_A;
+ split_AB *= v1;
+ split_ab.clear();
+ split_ab.add(base_pair<T,U>(v1,u1));
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ //(split_AB *= base_pair<T,U>(v1,u1)) += make_pair(open_interval<T>(v1,v7), u1); //JODO
+ split_AB *= interval<T>(v1);
+ split_AB += make_pair(open_interval<T>(v1,v7), u1);
+ split_ab2.clear();
+ split_ab2 += make_pair(rightopen_interval<T>(v1,v7), u1);
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_AB, split_ab2), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_intersect_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+ U u2 = make<U>(2);
+
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_2D = rightopen_interval(v1,v2);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I5_8D = rightopen_interval(v5,v8);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ std::pair<interval<T>,U> I0_3D_1(I0_3D, u1);
+ std::pair<interval<T>,U> I1_2D_1(I1_2D, u1);
+ std::pair<interval<T>,U> I1_2D_2(I1_2D, u2);
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I1_3D_2(I1_3D, u2);
+ std::pair<interval<T>,U> I2_3D_1(I2_3D, u1);
+ std::pair<interval<T>,U> I2_3D_2(I2_3D, u2);
+ std::pair<interval<T>,U> I2_4D_1(I2_4D, u1);
+ std::pair<interval<T>,U> I5_8D_1(I5_8D, u1);
+ std::pair<interval<T>,U> I6_8D_1(I6_8D, u1);
+ std::pair<interval<T>,U> I6_8D_2(I6_8D, u2);
+ std::pair<interval<T>,U> I6_9D_1(I6_9D, u1);
+
+ //--------------------------------------------------------------------------
+ // split_interval_set
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // 1 1
+ //split_B *= [1 2)[2 4) [5 8)
+ // 1 1 1
+ //split_AB -> [1 2)[2 3) [6 8)
+ // 2 2 2
+ SplitIntervalMapT split_A, split_B, split_AB, split_ab, split_ab_jn;
+ IntervalMapT join_A, join_B, join_AB, join_ab;
+
+ split_A.add(I0_3D_1).add(I6_9D_1);
+ split_B.add(I1_2D_1).add(I2_4D_1).add(I5_8D_1);
+ split_ab.add(I1_2D_2).add(I2_3D_2).add(I6_8D_2);
+ split_ab_jn.add(I1_3D_2).add(I6_8D_2);
+ split_AB = split_A;
+ split_AB *= split_B;
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 3 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ //split_A [0 3) [6 9)
+ // 1 1
+ //join_B *= [1 4) [5 8)
+ // 1 1
+ //split_AB -> [1 3) [6 8)
+ // 2 2
+ split_AB = split_A;
+ join_B = split_B;
+ split_AB *= join_B;
+
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab_jn );
+}
+
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_intersect2_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+ U u2 = make<U>(2);
+
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_2D = rightopen_interval(v1,v2);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I5_8D = rightopen_interval(v5,v8);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ std::pair<interval<T>,U> I0_3D_1(I0_3D, u1);
+ std::pair<interval<T>,U> I1_2D_1(I1_2D, u1);
+ std::pair<interval<T>,U> I1_2D_2(I1_2D, u2);
+ std::pair<interval<T>,U> I1_3D_1(I1_3D, u1);
+ std::pair<interval<T>,U> I1_3D_2(I1_3D, u2);
+ std::pair<interval<T>,U> I2_3D_1(I2_3D, u1);
+ std::pair<interval<T>,U> I2_3D_2(I2_3D, u2);
+ std::pair<interval<T>,U> I2_4D_1(I2_4D, u1);
+ std::pair<interval<T>,U> I5_8D_1(I5_8D, u1);
+ std::pair<interval<T>,U> I6_8D_1(I6_8D, u1);
+ std::pair<interval<T>,U> I6_8D_2(I6_8D, u2);
+ std::pair<interval<T>,U> I6_9D_1(I6_9D, u1);
+
+ //--------------------------------------------------------------------------
+ // split_interval_set
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // 1 1
+ //split_B *= [1 2)[2 4) [5 8)
+ //split_AB -> [1 2)[2 3) [6 8)
+ // 1 1 1
+ SplitIntervalMapT split_A, split_AB, split_ab, split_ab_jn;
+ SplitIntervalSetT split_B;
+ IntervalMapT join_A, join_AB, join_ab;
+ IntervalSetT join_B;
+
+ split_A.add(I0_3D_1).add(I6_9D_1);
+ split_B.add(I1_2D).add(I2_4D).add(I5_8D);
+ split_ab.add(I1_2D_1).add(I2_3D_1).add(I6_8D_1);
+ split_ab_jn.add(I1_3D_1).add(I6_8D_1);
+ split_AB = split_A;
+ split_AB *= split_B;
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 3 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ //split_A [0 3) [6 9)
+ // 1 1
+ //join_B *= [1 4) [5 8)
+ //split_AB -> [1 3) [6 8)
+ // 1 1
+ split_AB = split_A;
+ join_B = split_B;
+ split_AB *= join_B;
+
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab_jn );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_disjoint_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+
+ T v6 = make<T>(6);
+
+
+
+
+ interval<T> I0_2D = rightopen_interval(v0,v2);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I3_4D = rightopen_interval(v3,v4);
+ interval<T> I4_4I = closed_interval(v4,v4);
+ interval<T> C4_6D = open_interval(v4,v6);
+ interval<T> I6_6I = closed_interval(v6,v6);
+
+ std::pair<interval<T>,U> I0_2D_1(I0_2D, u1);
+ std::pair<interval<T>,U> I2_3D_1(I2_3D, u1);
+ std::pair<interval<T>,U> I3_4D_1(I3_4D, u1);
+ std::pair<interval<T>,U> I4_4I_1(I4_4I, u1);
+ std::pair<interval<T>,U> C4_6D_1(C4_6D, u1);
+ std::pair<interval<T>,U> I6_6I_1(I6_6I, u1);
+
+ //--------------------------------------------------------------------------
+ //split_A: [0 2) [4 4] [6 6]
+ //split_B: [2 3)[3 4) (4 6)
+ SplitIntervalMapT split_A, split_B;
+
+ split_A.add(I0_2D_1).add(I4_4I_1).add(I6_6I_1);
+ split_B.add(I2_3D_1).add(I3_4D_1).add(C4_6D_1);
+
+ IntervalMapT join_A(split_A), join_B(split_B);
+
+ BOOST_CHECK_EQUAL( is_disjoint(split_A, split_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(split_A, join_B), true );
+
+ BOOST_CHECK_EQUAL( is_disjoint(join_A, split_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(join_A, join_B), true );
+}
+
+template<class Type>
+struct size_greater_1 : public itl::property<Type>
+{
+ bool operator()(const Type& value)const
+ {
+ return value.first.size() > 1 ;
+ }
+};
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_map_mixed_erase_if_4_integral_types, T, integral_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ typedef split_interval_map<T,U> SplitIntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef split_interval_set<T> SplitIntervalSetT;
+ U u1 = make<U>(1);
+
+ T v0 = make<T>(0);
+
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+
+ T v6 = make<T>(6);
+
+
+
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I3_4D = rightopen_interval(v3,v4);
+ interval<T> I4_4I = closed_interval(v4,v4);
+ interval<T> C4_6D = open_interval(v4,v6);
+ interval<T> I6_6I = closed_interval(v6,v6);
+
+ std::pair<interval<T>,U> I0_3D_1(I0_3D, u1);
+ std::pair<interval<T>,U> I2_3D_1(I2_3D, u1);
+ std::pair<interval<T>,U> I3_4D_1(I3_4D, u1);
+ std::pair<interval<T>,U> I4_4I_1(I4_4I, u1);
+ std::pair<interval<T>,U> C4_6D_1(C4_6D, u1);
+ std::pair<interval<T>,U> I6_6I_1(I6_6I, u1);
+
+ //--------------------------------------------------------------------------
+ //split_A: [0 2) [4 4] [6 6]
+ //split_B: [2 3)[3 4) (4 6)
+ SplitIntervalMapT split_A, split_B;
+
+ split_A.add(I0_3D_1).add(I4_4I_1).add(I6_6I_1);
+ split_B.add(I4_4I_1).add(I6_6I_1);
+
+ split_A.template erase_if<size_greater_1>();
+
+ BOOST_CHECK_EQUAL( split_A, split_B );
+}
Added: sandbox/itl/libs/itl/test/test_interval_map_mixed/vc9_test_interval_map_mixed.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_map_mixed/vc9_test_interval_map_mixed.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_interval_map_mixed"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9F}"
+ RootNamespace="Test_interval_map_mixed"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_interval_map_mixed.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\test_interval_map_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_interval_map_shared.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_map_shared.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,807 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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 __test_itl_interval_map_shared_h_JOFA_081005__
+#define __test_itl_interval_map_shared_h_JOFA_081005__
+
+#include <boost/type_traits/is_same.hpp>
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_fundamentals_4_ordered_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ typedef typename IntervalMapT::size_type size_T;
+ typedef typename IntervalMapT::difference_type diff_T;
+
+ // ordered types is the largest set of instance types.
+ // Because we can not generate values via incrementation for e.g. string,
+ // we are able to test operations only for the most basic values
+ // neutron (0, empty, T() ...) and unon.
+
+ //T v0 = neutron<T>(); //JODO check operator() variant
+ //T v1 = unon<T>();
+ T v0 = neutron<T>::value();
+ T v1 = unon<T>::value();
+ interval<T> I0_0I(v0);
+ interval<T> I1_1I(v1);
+ interval<T> I0_1I(v0,v1);
+ U u1 = unon<U>::value();
+
+ //-------------------------------------------------------------------------
+ //empty set
+ //-------------------------------------------------------------------------
+ BOOST_CHECK_EQUAL(IntervalMapT().empty(), true);
+ BOOST_CHECK_EQUAL(IntervalMapT().cardinality(), neutron<size_T>::value());
+ BOOST_CHECK_EQUAL(IntervalMapT().size(), neutron<size_T>::value());
+ BOOST_CHECK_EQUAL(IntervalMapT().interval_count(), 0);
+ BOOST_CHECK_EQUAL(IntervalMapT().iterative_size(), 0);
+ BOOST_CHECK_EQUAL(IntervalMapT(), IntervalMapT());
+
+ interval<T> mt_interval = neutron<interval<T> >::value();
+ BOOST_CHECK_EQUAL(mt_interval, interval<T>());
+ typename IntervalMapT::value_type mt_u1 = make_pair(mt_interval, u1);
+ IntervalMapT mt_map = neutron<IntervalMapT >::value();
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+ //adding emptieness to emptieness yields emptieness ;)
+ mt_map.add(mt_u1).add(mt_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ mt_map.insert(mt_u1).insert(mt_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ (mt_map += mt_u1) += mt_u1;
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ BOOST_CHECK_EQUAL(enclosure(mt_map), neutron<interval<T> >::value());
+
+ //subtracting emptieness
+ mt_map.subtract(mt_u1).subtract(mt_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+ mt_map.erase(mt_interval).erase(mt_interval);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ (mt_map -= mt_u1) -= mt_u1;
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+ //subtracting elements form emptieness
+ typename IntervalMapT::base_pair_type v0_u1 = make_pair(v0,u1);
+ typename IntervalMapT::base_pair_type v1_u1 = make_pair(v1,u1);
+ //mt_map.subtract(make_pair(v0,u1)).subtract(make_pair(v1,u1));
+ mt_map.subtract(v0_u1).subtract(v1_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ mt_map.erase(v0_u1).erase(v1_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ (mt_map -= v0_u1) -= v1_u1;
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+ //subtracting intervals form emptieness
+ typename IntervalMapT::value_type I0_0I_u1 = make_pair(I0_0I,u1);
+ typename IntervalMapT::value_type I0_1I_u1 = make_pair(I0_1I,u1);
+ typename IntervalMapT::value_type I1_1I_u1 = make_pair(I1_1I,u1);
+ mt_map.subtract(I0_1I_u1).subtract(I1_1I_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ mt_map.erase(I0_1I_u1).erase(I1_1I_u1);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ (mt_map -= I0_1I_u1) -= I1_1I_u1;
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+ mt_map.erase(I0_1I).erase(I1_1I);
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+ //insecting emptieness
+ (mt_map *= mt_u1) *= mt_u1;
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+ (mt_map *= mt_interval) *= mt_interval;
+ BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
+
+
+
+ //-------------------------------------------------------------------------
+ //unary set
+ //-------------------------------------------------------------------------
+ IntervalMapT single_I0_0I_u1_from_element(v0_u1);
+ IntervalMapT single_I0_0I_u1_from_interval(I0_0I_u1);
+ IntervalMapT single_I0_0I_u1(single_I0_0I_u1_from_interval);
+
+ BOOST_CHECK_EQUAL(single_I0_0I_u1_from_element, single_I0_0I_u1_from_interval);
+ BOOST_CHECK_EQUAL(single_I0_0I_u1_from_element, single_I0_0I_u1);
+ BOOST_CHECK_EQUAL(enclosure(single_I0_0I_u1), I0_0I);
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.lower(), I0_0I.lower());
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.upper(), I0_0I.upper());
+
+ IntervalMapT single_I1_1I_u1_from_element(v1_u1);
+ IntervalMapT single_I1_1I_u1_from_interval(I1_1I_u1);
+ IntervalMapT single_I1_1I_u1(single_I1_1I_u1_from_interval);
+
+ BOOST_CHECK_EQUAL(single_I1_1I_u1_from_element, single_I1_1I_u1_from_interval);
+ BOOST_CHECK_EQUAL(single_I1_1I_u1_from_element, single_I1_1I_u1);
+
+ IntervalMapT single_I0_1I_u1_from_interval(I0_1I_u1);
+ IntervalMapT single_I0_1I_u1(single_I0_1I_u1_from_interval);
+
+ BOOST_CHECK_EQUAL(single_I0_1I_u1_from_interval, single_I0_1I_u1);
+ BOOST_CHECK_EQUAL(enclosure(single_I0_1I_u1), I0_1I);
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.lower(), I0_1I.lower());
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.upper(), I0_1I.upper());
+
+ //contains predicate
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.contains(v0), true);
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.contains(v0_u1), true);
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.contains(I0_0I_u1), true);
+
+ BOOST_CHECK_EQUAL(single_I1_1I_u1.contains(v1), true);
+ BOOST_CHECK_EQUAL(single_I1_1I_u1.contains(v1_u1), true);
+ BOOST_CHECK_EQUAL(single_I1_1I_u1.contains(I1_1I_u1), true);
+
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(v0), true);
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(I0_1I_u1), true);
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(v1), true);
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(I1_1I_u1), true);
+
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(single_I0_0I_u1), true);
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(single_I1_1I_u1), true);
+ BOOST_CHECK_EQUAL(single_I0_1I_u1.contains(single_I0_1I_u1), true);
+
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.cardinality(), unon<size_T>::value());
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.size(), unon<size_T>::value());
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.interval_count(), 1);
+ BOOST_CHECK_EQUAL(single_I0_0I_u1.iterative_size(), 1);
+
+}
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_ctor_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+
+ T v4 = make<T>(4);
+ U u2 = make<U>(2);
+ interval<T> I4_4I(v4);
+ typename IntervalMapT::base_pair_type v4_u2(v4,u2);
+ typename IntervalMapT::value_type I4_4I_u2(I4_4I,u2);
+
+ IntervalMapT _I4_4I_u2;
+ BOOST_CHECK_EQUAL( _I4_4I_u2.empty(), true );
+ IntervalMapT _I4_4I_u2_1;
+ IntervalMapT _I4_4I_u2_2;
+ IntervalMapT _I4_4I_u2_3;
+ _I4_4I_u2 += v4_u2;
+ _I4_4I_u2_1 += I4_4I_u2;
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_1 );
+ _I4_4I_u2_2.add(v4_u2);
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_2 );
+ _I4_4I_u2_3.add(I4_4I_u2);
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_3 );
+
+ _I4_4I_u2.clear();
+ _I4_4I_u2.add(I4_4I_u2).add(I4_4I_u2);
+ IntervalMapT _I4_4I_u4(make_pair(I4_4I, make<U>(4)));
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u4 );
+
+ _I4_4I_u2.clear();
+ _I4_4I_u2.insert(I4_4I_u2).insert(I4_4I_u2);
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_1 );
+
+ BOOST_CHECK_EQUAL( _I4_4I_u2.cardinality(), unon<typename IntervalMapT::size_type>::value() );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.size(), unon<typename IntervalMapT::size_type>::value() );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.interval_count(), 1 );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.iterative_size(), 1 );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.lower(), v4 );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.upper(), v4 );
+
+ IntervalMapT _I4_4I_u2_copy(_I4_4I_u2);
+ IntervalMapT _I4_4I_u2_assigned;
+ _I4_4I_u2_assigned = _I4_4I_u2;
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_copy );
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_assigned );
+
+ _I4_4I_u2_assigned.clear();
+ BOOST_CHECK_EQUAL( true, _I4_4I_u2_assigned.empty() );
+
+ _I4_4I_u2_assigned.swap(_I4_4I_u2_copy);
+ BOOST_CHECK_EQUAL( true, _I4_4I_u2_copy.empty() );
+ BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_assigned );
+}
+
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_add_sub_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+
+ T v0 = make<T>(0);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v9 = make<T>(9);
+ U u1 = make<U>(1);
+ interval<T> I5_6I(v5,v6);
+ interval<T> I5_9I(v5,v9);
+ interval<T> I0_9I = closed_interval(v0, v9);
+ typename IntervalMapT::base_pair_type v0_u1 = make_pair(v0, u1);
+ typename IntervalMapT::base_pair_type v9_u1 = make_pair(v9, u1);
+ typename IntervalMapT::value_type I5_6I_u1 = make_pair(I5_6I, u1);
+ typename IntervalMapT::value_type I5_9I_u1 = make_pair(I5_9I, u1);
+ typename IntervalMapT::value_type I0_9I_u1 = make_pair(closed_interval(v0, v9), u1);
+
+ BOOST_CHECK_EQUAL( IntervalMapT(I5_6I_u1).add(v0_u1).add(v9_u1),
+ IntervalMapT().add(v9_u1).add(I5_6I_u1).add(v0_u1) );
+
+ IntervalMapT map_A = IntervalMapT(I5_6I_u1).add(v0_u1).add(v9_u1);
+ IntervalMapT map_B = IntervalMapT().insert(v9_u1).insert(I5_6I_u1).insert(v0_u1);
+ BOOST_CHECK_EQUAL( map_A, map_B );
+ BOOST_CHECK_EQUAL( enclosure(map_A), I0_9I );
+ BOOST_CHECK_EQUAL( map_A.lower(), I0_9I.lower() );
+ BOOST_CHECK_EQUAL( map_A.upper(), I0_9I.upper() );
+ //JODO: LAW !a.empty() => enclosure(a).lower() == a.lower()
+ //JODO: LAW !a.empty() => enclosure(a).upper() == a.upper()
+
+ IntervalMapT map_A1 = map_A, map_B1 = map_B,
+ map_A2 = map_A, map_B2 = map_B;
+
+ map_A1.subtract(I5_6I_u1).subtract(v9_u1);
+ map_B1.erase(v9_u1).erase(I5_6I_u1);
+ BOOST_CHECK_EQUAL( map_A1, map_B1 );
+
+ map_B1 = map_B;
+ map_B2.erase(v9).erase(I5_6I);
+ BOOST_CHECK_EQUAL( map_A1, map_B2 );
+
+ map_A2.subtract(I5_9I_u1);
+ map_B2.erase(I5_9I);
+ BOOST_CHECK_EQUAL( map_A2, map_B2 );
+}
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_distinct_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ typedef typename IntervalMap<T,U>::size_type size_T;
+ typedef typename IntervalMap<T,U>::difference_type diff_T;
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ U u1 = make<U>(1);
+ typename IntervalMapT::base_pair_type v1_u1(v1,u1);
+ typename IntervalMapT::base_pair_type v3_u1(v3,u1);
+ typename IntervalMapT::base_pair_type v5_u1(v5,u1);
+
+ size_T s3 = make<size_T>(3);
+
+ IntervalMapT is_1_3_5;
+ is_1_3_5.add(v1_u1).add(v3_u1).add(v5_u1);
+
+ BOOST_CHECK_EQUAL( is_1_3_5.cardinality(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.size(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.interval_count(), 3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(), 3 );
+}
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_distinct_4_bicremental_continuous_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ typedef typename IntervalMapT::size_type size_T;
+ typedef typename IntervalMapT::difference_type diff_T;
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ U u1 = make<U>(1);
+ typename IntervalMapT::base_pair_type v1_u1(v1,u1);
+ typename IntervalMapT::base_pair_type v3_u1(v3,u1);
+ typename IntervalMapT::base_pair_type v5_u1(v5,u1);
+
+ size_T s3 = make<size_T>(3);
+ diff_T d0 = make<diff_T>(0);
+ diff_T d2 = make<diff_T>(2);
+
+ IntervalMapT is_1_3_5;
+ is_1_3_5.add(v1_u1).add(v3_u1).add(v5_u1);
+
+ BOOST_CHECK_EQUAL( is_1_3_5.cardinality(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.size(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.length(), d0 );
+ BOOST_CHECK_EQUAL( is_1_3_5.interval_count(), 3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(), 3 );
+
+
+ IntervalMapT is_123_5;
+ is_123_5 = is_1_3_5;
+ //OPROM: open problem: Ambiguity resolving value_type and base_value_type for overloaded o= operators.
+ //is_123_5 += make_pair(open_interval<T>(v1,v3),u1); //error C2593: 'operator +=' is ambiguous
+ //is_123_5 += make_pair<interval<T>, U>(open_interval<T>(v1,v3),u1); //error C2593: 'operator +=' is ambiguous
+ //USASO: unsatisfctory solution 1: explicit IntervalMapT::value_type instead of make_pair
+ is_123_5 += typename IntervalMapT::value_type(open_interval<T>(v1,v3),u1);
+ //USASO: unsatisfctory solution 2: not implementing base_value_type version of o=
+
+ BOOST_CHECK_EQUAL( is_123_5.cardinality(), std::numeric_limits<size_T>::infinity() );
+ BOOST_CHECK_EQUAL( is_123_5.size(), std::numeric_limits<size_T>::infinity() );
+ BOOST_CHECK_EQUAL( is_123_5.length(), d2 );
+
+}
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_isolate_4_bicremental_continuous_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ typedef typename IntervalMapT::size_type size_T;
+ typedef typename IntervalMapT::difference_type diff_T;
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v4 = make<T>(4);
+ U u1 = make<U>(1);
+ interval<T> I0_4I = closed_interval(v0,v4);
+ interval<T> C0_2D = open_interval(v0,v2);
+ interval<T> C2_4D = open_interval(v2,v4);
+ typename IntervalMapT::value_type I0_4I_u1(I0_4I,u1);
+ typename IntervalMapT::value_type C0_2D_u1(C0_2D,u1);
+ typename IntervalMapT::value_type C2_4D_u1(C2_4D,u1);
+ // {[0 4]}
+ // - { (0,2) (2,4) }
+ // = {[0] [2] [4]}
+ IntervalMapT iso_map = IntervalMapT(I0_4I_u1);
+ IntervalMapT gap_set;
+ gap_set.add(C0_2D_u1).add(C2_4D_u1);
+ iso_map -= gap_set;
+
+ BOOST_CHECK_EQUAL( iso_map.cardinality(), static_cast<size_T>(3) );
+ BOOST_CHECK_EQUAL( iso_map.iterative_size(), static_cast<std::size_t>(3) );
+
+ IntervalMapT iso_map2;
+ iso_map2.add(I0_4I_u1);
+ iso_map2.subtract(C0_2D_u1).subtract(C2_4D_u1);
+
+ IntervalMapT iso_map3(I0_4I_u1);
+ (iso_map3 -= C0_2D_u1) -= C2_4D_u1;
+
+ IntervalMapT iso_map4;
+ iso_map4.insert(I0_4I_u1);
+ iso_map4.erase(C0_2D_u1).erase(C2_4D_u1);
+
+ BOOST_CHECK_EQUAL( iso_map, iso_map2 );
+ BOOST_CHECK_EQUAL( iso_map, iso_map3 );
+ BOOST_CHECK_EQUAL( iso_map, iso_map4 );
+}
+
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_contains_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ //LAW: x.add(e).contains(e); //false!
+ //LAW: x.insert(e).contains(e); //??
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+ T v11 = make<T>(11);
+ U u1 = make<U>(1);
+
+ typename IntervalMapT::base_pair_type v3_u1(v3,u1);
+ typename IntervalMapT::base_pair_type v9_u1(v9,u1);
+ typename IntervalMapT::base_pair_type v11_u1(v11,u1);
+
+ typename IntervalMapT::value_type I3_7I_u1(interval<T>(v3,v7),u1);
+ IntervalMapT im(v3_u1);
+ BOOST_CHECK_EQUAL( im.contains(v3_u1), true );
+
+ BOOST_CHECK_EQUAL( IntervalMapT().add(v3_u1).contains(v3_u1), true );
+ BOOST_CHECK_EQUAL( IntervalMapT().insert(v3_u1).contains(v3_u1), true );
+ im.clear();
+ BOOST_CHECK_EQUAL( (im += I3_7I_u1).contains(I3_7I_u1), true );
+
+ IntervalMapT im0 = im;
+
+ im.clear();
+ IntervalMapT im2(typename IntervalMapT::value_type(closed_interval(v5,v8),u1));
+ im2.add(v9_u1).add(v11_u1);
+ im += im2;
+ BOOST_CHECK_EQUAL( im.contains(im2), true );
+}
+
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_operators_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ U u1 = make<U>(1);
+ typename IntervalMapT::interval_type I3_5I(closed_interval(v3,v5));
+ typename IntervalMapT::value_type I0_1I_u1(closed_interval(v0,v1),u1);
+ typename IntervalMapT::value_type I3_5I_u1(closed_interval(v3,v5),u1);
+ typename IntervalMapT::value_type I7_8I_u1(closed_interval(v7,v8),u1);
+
+ IntervalMapT left, left2, right, all, section, complement;
+ left.add(I0_1I_u1).add(I3_5I_u1);
+ (right += I3_5I_u1) += I7_8I_u1;
+ is_disjoint(left, right);
+ BOOST_CHECK_EQUAL( is_disjoint(left, right), false );
+
+ (all += left) += right;
+ (section += left) *= right;
+ all -= section;
+ complement += all;
+ //complement.erase(I3_5I);
+ complement.erase(section);
+ BOOST_CHECK_EQUAL( is_disjoint(section, complement), true );
+
+ //JODO: There seems to be no intersection on maps of non set codomain type
+ // that can be implemented via *= propagation. Intersectin on those types
+ // could be dome elementic defining it via intersection on the set of pairs.
+ //if(boost::is_same<T,int>::value)
+ //{
+ // cout << "left: " << left << endl;
+ // cout << "right: " << right << endl;
+ // cout << "section: " << section << endl;
+ // cout << "complem: " << complement << endl;
+ // cout << "all: " << all << endl;
+ // cout << "all2: " << all2 << endl;
+ //}
+
+ //BOOST_CHECK_EQUAL( all.contains(left), true );
+ //BOOST_CHECK_EQUAL( all.contains(right), true );
+ //BOOST_CHECK_EQUAL( all.contains(complement), true );
+
+ //BOOST_CHECK_EQUAL( left.contained_in(all), true );
+ //BOOST_CHECK_EQUAL( right.contained_in(all), true );
+ //BOOST_CHECK_EQUAL( complement.contained_in(all), true );
+ //BOOST_CHECK_EQUAL( section.contained_in(left), true );
+ //BOOST_CHECK_EQUAL( section.contained_in(right), true );
+}
+
+
+// Test for nontrivial intersection of interval maps with intervals and values
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_base_intersect_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ U u1 = make<U>(1);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I1_4D = rightopen_interval(v1,v4);
+ interval<T> I1_8D = rightopen_interval(v1,v8);
+ interval<T> I2_7D = rightopen_interval(v2,v7);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I5_8D = rightopen_interval(v5,v8);
+ interval<T> I6_7D = rightopen_interval(v6,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ typename IntervalMapT::value_type I0_3D_1(I0_3D, u1);
+ typename IntervalMapT::value_type I6_9D_1(I6_9D, u1);
+ typename IntervalMapT::value_type I1_3D_1(I1_3D, u1);
+ typename IntervalMapT::value_type I6_8D_1(I6_8D, u1);
+ typename IntervalMapT::value_type I2_3D_1(I2_3D, u1);
+ typename IntervalMapT::value_type I6_7D_1(I6_7D, u1);
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // *= [1 8)
+ //map_AB -> [1 3) [6 8)
+ // 1 1
+ // *= [2 7)
+ // -> [2 3) [6 7)
+ // 1 1
+ IntervalMap<T,U> map_A, map_AB, map_ab, map_ab2;
+ interval_set<T> set_B;
+ map_A.add(I0_3D_1).add(I6_9D_1);
+ map_AB = map_A;
+ map_AB *= I1_8D;
+ map_ab.add(I1_3D_1).add(I6_8D_1);
+
+ BOOST_CHECK_EQUAL( map_AB, map_ab );
+
+ map_AB = map_A;
+ (map_AB *= I1_8D) *= I2_7D;
+ map_ab2.add(I2_3D_1).add(I6_7D_1);
+
+ BOOST_CHECK_EQUAL( map_AB, map_ab2 );
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // *= [1 4) [5 8)
+ //map_AB -> [1 3) [6 8)
+ // 1 1
+ // *= [2 4) [5 7)
+ // -> [2 3) [6 7)
+ // 1 1
+ map_A.clear();
+ map_A.add(I0_3D_1).add(I6_9D_1);
+ set_B.add(I1_4D).add(I5_8D);
+ map_AB = map_A;
+
+ map_AB *= set_B;
+ map_ab.clear();
+ map_ab.add(I1_3D_1).add(I6_8D_1);
+ BOOST_CHECK_EQUAL( map_AB, map_ab );
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // *= 1
+ //map_AB -> [1]
+ // 1
+
+ //JODO intersection with key-element not yet working
+ //map_A.clear();
+ //map_A.add(I0_3D_1).add(I6_9D_1);
+ //map_AB = map_A;
+ //map_AB *= v1;
+ //map_ab.clear();
+ //map_ab.add(v1);
+
+ //BOOST_CHECK_EQUAL( map_AB, map_ab );
+
+ //if(boost::is_same<T,int>::value)
+ //{
+ // cout << "map_A : " << map_A << endl;
+ // cout << "map_AB: " << map_AB << endl;
+ //}
+}
+
+
+// Test for nontrivial erasure of interval maps with intervals and interval sets
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_base_erase_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ U u1 = make<U>(1);
+
+ interval<T> I0_1D = rightopen_interval(v0,v1);
+ interval<T> I0_2D = rightopen_interval(v0,v2);
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I1_4D = rightopen_interval(v1,v4);
+ interval<T> I1_8D = rightopen_interval(v1,v8);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I2_7D = rightopen_interval(v2,v7);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I5_8D = rightopen_interval(v5,v8);
+ interval<T> I6_7D = rightopen_interval(v6,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+ interval<T> I7_9D = rightopen_interval(v7,v9);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+
+ typename IntervalMapT::value_type I0_1D_1(I0_1D, u1);
+ typename IntervalMapT::value_type I0_3D_1(I0_3D, u1);
+ typename IntervalMapT::value_type I0_2D_1(I0_2D, u1);
+ typename IntervalMapT::value_type I6_9D_1(I6_9D, u1);
+ typename IntervalMapT::value_type I1_3D_1(I1_3D, u1);
+ typename IntervalMapT::value_type I6_8D_1(I6_8D, u1);
+ typename IntervalMapT::value_type I2_3D_1(I2_3D, u1);
+ typename IntervalMapT::value_type I6_7D_1(I6_7D, u1);
+ typename IntervalMapT::value_type I7_9D_1(I7_9D, u1);
+ typename IntervalMapT::value_type I8_9D_1(I8_9D, u1);
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // erase [2 7)
+ //map_A2 -> [0 2) [7 9)
+ // 1 1
+ // erase [1 8)
+ // -> [0 1) [8 9)
+ // 1 1
+ IntervalMap<T,U> map_A, map_A2, map_A3, map_check2, map_check3;
+ interval_set<T> set_B;
+ map_A.add(I0_3D_1).add(I6_9D_1);
+ map_A2 = map_A;
+ map_A2.erase(I2_7D);
+ map_check2.add(I0_2D_1).add(I7_9D_1);
+ BOOST_CHECK_EQUAL( map_A2, map_check2 );
+
+ map_A3 = map_A2;
+ map_A3.erase(I1_8D);
+ map_check3.add(I0_1D_1).add(I8_9D_1);
+ BOOST_CHECK_EQUAL( map_A3, map_check3 );
+
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // erase [2 7)
+ // -> [0 2) [7 9)
+ // 1 1
+ // erase [1 8)
+ // -> [0 1) [8 9)
+ // 1 1
+ map_A3 = map_A;
+ map_A3.erase(I2_7D).erase(I1_8D);
+ BOOST_CHECK_EQUAL( map_A3, map_check3 );
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // -= [2 7)
+ // -> [0 2) [7 9)
+ // 1 1
+ // -= [1 8)
+ // -> [0 1) [8 9)
+ // 1 1
+ map_A3 = map_A;
+ (map_A3 -= I2_7D) -= I1_8D;
+ BOOST_CHECK_EQUAL( map_A3, map_check3 );
+
+ //--------------------------------------------------------------------------
+ //map_A [0 3) [6 9)
+ // 1 1
+ // erase [2 4) [5 7)
+ // -> [0 2) [7 9)
+ // 1 1
+ map_A3 = map_A;
+ set_B.add(I2_4D).add(I5_7D);
+ map_A3 -= set_B;
+ BOOST_CHECK_EQUAL( map_A3, map_check2 );
+}
+
+
+// Test first_collision
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_base_is_disjoint_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ typedef typename IntervalMap<T,U>::interval_set_type IntervalSetT;
+
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ U u1 = make<U>(1);
+
+ interval<T> I0_1D = rightopen_interval(v0,v1);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+
+ typename IntervalMapT::value_type I0_1D_1(I0_1D, u1);
+ typename IntervalMapT::value_type I1_3D_1(I1_3D, u1);
+ typename IntervalMapT::value_type I3_6D_1(I3_6D, u1);
+ typename IntervalMapT::value_type I5_7D_1(I5_7D, u1);
+ typename IntervalMapT::value_type I6_8D_1(I6_8D, u1);
+ typename IntervalMapT::value_type I8_9D_1(I8_9D, u1);
+
+ //--------------------------------------------------------------------------
+ //map_A [1 3) [6 8)
+ // 1 1
+ //map_B [0 1) [3 6) [8 9)
+ // 1 1 1
+ IntervalMapT map_A, map_B;
+ IntervalSetT set_A, set_B;
+
+ map_A.add(I1_3D_1).add(I6_8D_1);
+ map_B.add(I0_1D_1).add(I3_6D_1).add(I8_9D_1);
+ BOOST_CHECK_EQUAL( is_disjoint(map_A, map_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(map_B, map_A), true );
+
+ map_A.domain(set_A);
+ map_B.domain(set_B);
+ BOOST_CHECK_EQUAL( is_disjoint(map_A, set_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(set_B, map_A), true );
+ BOOST_CHECK_EQUAL( is_disjoint(set_A, map_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(map_B, set_A), true );
+
+ map_A += I5_7D_1;
+
+ BOOST_CHECK_EQUAL( is_disjoint(map_A, map_B), false );
+ BOOST_CHECK_EQUAL( is_disjoint(map_B, map_A), false );
+
+ map_A.domain(set_A);
+ map_B.domain(set_B);
+ BOOST_CHECK_EQUAL( is_disjoint(map_A, set_B), false );
+ BOOST_CHECK_EQUAL( is_disjoint(set_B, map_A), false );
+ BOOST_CHECK_EQUAL( is_disjoint(set_A, map_B), false );
+ BOOST_CHECK_EQUAL( is_disjoint(map_B, set_A), false );
+}
+
+
+#endif // __test_itl_interval_map_shared_h_JOFA_080920__
+
Added: sandbox/itl/libs/itl/test/test_interval_set/test_interval_set.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_set/test_interval_set.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,35 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/interval_set.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+// -----------------------------------------------------------------------------
+// test_interval_set_shared are tests that should give identical results for all
+// interval_sets: interval_set, separate_interval_set and split_interval_set.
+#include "../test_interval_set_shared.hpp"
+
+// Due to limited expressiveness of the testing framework, the testcode in files
+// test_interval_set{,_separate,split}_shared.cpp is generated through code
+// replication.
+#include "test_interval_set_shared.cpp"
+
+
Added: sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,44 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_fundamentals_4_ordered_types, T, ordered_types)
+{ interval_set_fundamentals_4_ordered_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_ctor_4_bicremental_types, T, bicremental_types)
+{ interval_set_ctor_4_bicremental_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_add_sub_4_bicremental_types, T, bicremental_types)
+{ interval_set_add_sub_4_bicremental_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_distinct_4_bicremental_types, T, bicremental_types)
+{ interval_set_distinct_4_bicremental_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_distinct_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_set_distinct_4_bicremental_continuous_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_isolate_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_set_isolate_4_bicremental_continuous_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_contains_4_bicremental_types, T, bicremental_types)
+{ interval_set_contains_4_bicremental_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_operators_4_bicremental_types, T, bicremental_types)
+{ interval_set_operators_4_bicremental_types<interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_base_intersect_4_bicremental_types, T, bicremental_types)
+{ interval_set_base_intersect_4_bicremental_types<interval_set, T>();}
+
Added: sandbox/itl/libs/itl/test/test_interval_set/vc9_test_interval_set.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_set/vc9_test_interval_set.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_interval_set"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9C}"
+ RootNamespace="Test_interval_set"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_interval_set.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\test_interval_set_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,752 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl/separate_interval_set.hpp>
+#include <boost/itl/split_interval_set.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_ctor_4_ordered_types, T, ordered_types)
+{
+ T v0 = neutron<T>::value();
+ T v1 = unon<T>::value();
+
+ split_interval_set<T> split_set(v0);
+ separate_interval_set<T> sep_set(split_set);
+ interval_set<T> join_set(sep_set);
+
+ BOOST_CHECK_EQUAL( split_set.lower(), sep_set.lower() );
+ BOOST_CHECK_EQUAL( split_set.lower(), join_set.lower() );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_equal_4_ordered_types, T, ordered_types)
+{
+ T v0 = neutron<T>::value();
+ T v1 = unon<T>::value();
+
+ split_interval_set<T> split_empty, split_single(v0);
+ separate_interval_set<T> sep_empty, sep_single(v0);
+ interval_set<T> join_empty, join_single(v0);
+
+ // mixed ==-equality is a strange thing. Most times is does not
+ // make sense. It is better to allow only for same type == equality.
+ BOOST_CHECK_EQUAL( split_empty == split_empty, true );
+ BOOST_CHECK_EQUAL( sep_empty == sep_empty, true );
+ BOOST_CHECK_EQUAL( join_empty == join_empty, true );
+
+ // There were Problems with operator== and emtpy sets.
+ BOOST_CHECK_EQUAL( split_empty == split_single, false );
+ BOOST_CHECK_EQUAL( sep_empty == sep_single, false );
+ BOOST_CHECK_EQUAL( join_empty == join_single, false );
+
+ BOOST_CHECK_EQUAL( split_single == split_empty, false );
+ BOOST_CHECK_EQUAL( sep_single == sep_empty, false );
+ BOOST_CHECK_EQUAL( join_single == join_empty, false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, split_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, sep_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, join_empty), true );
+
+ BOOST_CHECK_EQUAL( is_element_equal(sep_empty, split_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_empty, sep_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_empty, join_empty), true );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, split_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, sep_empty), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, join_empty), true );
+
+ //--------------------------------------------------------------------------
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, split_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, sep_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(split_empty, join_single), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(sep_empty, split_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_empty, sep_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_empty, join_single), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, split_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, sep_single), false );
+ BOOST_CHECK_EQUAL( is_element_equal(join_empty, join_single), false );
+
+ //--------------------------------------------------------------------------
+ BOOST_CHECK_EQUAL( is_element_equal(split_single, split_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(split_single, sep_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(split_single, join_empty), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(sep_single, split_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_single, sep_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_single, join_empty), false );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_single, split_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(join_single, sep_empty), false );
+ BOOST_CHECK_EQUAL( is_element_equal(join_single, join_empty), false );
+
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_assign_4_ordered_types, T, ordered_types)
+{
+ T v0 = neutron<T>::value();
+ T v1 = unon<T>::value();
+
+ split_interval_set<T> split_set;
+ separate_interval_set<T> sep_set;
+ interval_set<T> join_set;
+ split_set.add(v0);
+ sep_set = split_set;
+ join_set = sep_set;
+
+ BOOST_CHECK_EQUAL( split_set.lower(), sep_set.lower() );
+ BOOST_CHECK_EQUAL( split_set.lower(), join_set.lower() );
+
+ split_interval_set<T> split_self = split_interval_set<T>().add(v0);
+ separate_interval_set<T> sep_self = separate_interval_set<T>().add(v0).add(v1);
+ interval_set<T> join_self = interval_set<T>().add(v1);
+
+ split_self = split_self;
+ sep_self = sep_self;
+ join_self = join_self;
+
+ BOOST_CHECK_EQUAL( split_self, split_self );
+ BOOST_CHECK_EQUAL( sep_self, sep_self );
+ BOOST_CHECK_EQUAL( join_self, join_self );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_ctor_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ split_interval_set<T> split_set;
+ split_set.add(I1_3D).add(I2_4D).add(I4_5D);
+ BOOST_CHECK_EQUAL( split_set.iterative_size(), 4 );
+ separate_interval_set<T> sep_set(split_set);
+ BOOST_CHECK_EQUAL( sep_set.iterative_size(), 4 );
+ interval_set<T> join_set(split_set);
+ BOOST_CHECK_EQUAL( join_set.iterative_size(), 1 );
+
+ separate_interval_set<T> sep_set2;
+ sep_set2.add(I1_3D).add(I2_4D).add(I4_5D);
+ BOOST_CHECK_EQUAL( sep_set2.iterative_size(), 2 );
+ split_interval_set<T> split_set2(sep_set2);
+ BOOST_CHECK_EQUAL( split_set2.iterative_size(), 2 );
+ interval_set<T> join_set2(sep_set2);
+ BOOST_CHECK_EQUAL( join_set2.iterative_size(), 1 );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_assign_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ split_interval_set<T> split_set;
+ split_set.add(I1_3D).add(I2_4D).add(I4_5D);
+ BOOST_CHECK_EQUAL( split_set.iterative_size(), 4 );
+ separate_interval_set<T> sep_set;
+ sep_set = split_set;
+ BOOST_CHECK_EQUAL( sep_set.iterative_size(), 4 );
+ interval_set<T> join_set;
+ join_set = split_set;
+ BOOST_CHECK_EQUAL( join_set.iterative_size(), 1 );
+
+ separate_interval_set<T> sep_set2;
+ sep_set2.add(I1_3D).add(I2_4D).add(I4_5D);
+ BOOST_CHECK_EQUAL( sep_set2.iterative_size(), 2 );
+ split_interval_set<T> split_set2;
+ split_set2 = sep_set2;
+ BOOST_CHECK_EQUAL( split_set2.iterative_size(), 2 );
+ interval_set<T> join_set2;
+ join_set2 = sep_set2;
+ BOOST_CHECK_EQUAL( join_set2.iterative_size(), 1 );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_equal_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ interval_set<T> join_set;
+ join_set.add(I1_3D).add(I2_4D).add(I4_5D);
+ interval_set<T> join_set2 = join_set;
+ BOOST_CHECK_EQUAL( join_set, join_set2 );
+ BOOST_CHECK_EQUAL( is_element_equal(join_set, join_set2), true );
+
+ separate_interval_set<T> sep_set;
+ sep_set.add(I1_3D).add(I2_4D).add(I4_5D);
+
+ separate_interval_set<T> sep_set2 = sep_set;
+ BOOST_CHECK_EQUAL( sep_set, sep_set2 );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_set2, sep_set), true );
+
+ split_interval_set<T> split_set;
+ split_set.add(I1_3D).add(I2_4D).add(I4_5D);
+ split_interval_set<T> split_set2 = split_set;
+ BOOST_CHECK_EQUAL( split_set, split_set2 );
+ BOOST_CHECK_EQUAL( is_element_equal(split_set2, split_set), true );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_set, join_set), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_set, sep_set), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_set, sep_set), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_set, split_set), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_set, join_set), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_set, split_set), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_add_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I4_5D = rightopen_interval(v4,v5);
+
+ split_interval_set<T> split_set;
+ split_set.add(I1_3D).add(I2_4D);
+ split_set += I4_5D;
+ BOOST_CHECK_EQUAL( split_set.iterative_size(), 4 );
+ separate_interval_set<T> sep_set;
+ sep_set += split_set;
+ BOOST_CHECK_EQUAL( sep_set.iterative_size(), 4 );
+ interval_set<T> join_set;
+ join_set += split_set;
+ BOOST_CHECK_EQUAL( join_set.iterative_size(), 1 );
+
+ separate_interval_set<T> sep_set2;
+ sep_set2.add(I1_3D).add(I2_4D);
+ sep_set2 += I4_5D;
+ BOOST_CHECK_EQUAL( sep_set2.iterative_size(), 2 );
+ split_interval_set<T> split_set2;
+ split_set2 += sep_set2;
+ BOOST_CHECK_EQUAL( split_set2.iterative_size(), 2 );
+ interval_set<T> join_set2;
+ join_set2 += sep_set2;
+ BOOST_CHECK_EQUAL( join_set2.iterative_size(), 1 );
+
+ interval_set<T> join_set3;
+ join_set3.add(v1).add(v3);
+ join_set3 += v5;
+ BOOST_CHECK_EQUAL( join_set3.iterative_size(), 3 );
+ split_interval_set<T> split_set3;
+ split_set3 += join_set3;
+ BOOST_CHECK_EQUAL( split_set3.iterative_size(), 3 );
+ separate_interval_set<T> sep_set3;
+ sep_set3 += join_set3;
+ BOOST_CHECK_EQUAL( join_set3.iterative_size(), 3 );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_subtract_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ //JODO INSIGHT: With respect to subtraction all interval_sets are working equivalently:
+ //Never does a subtract operation introduce or preserve interval borders within
+ //the range of the subtracted elements. This is almost trivial.
+ //LAW: y -= x == y -= x.join()
+ split_interval_set<T> split_set;
+ split_set.add(I0_4D).add(I2_6D).add(I5_7D).add(I7_8D).add(I8_9I);
+ BOOST_CHECK_EQUAL( split_set.iterative_size(), 7 );
+
+ separate_interval_set<T> sep_set;
+ sep_set.add(I0_4D).add(I2_6D).add(I5_7D).add(I7_8D).add(I8_9I);
+ BOOST_CHECK_EQUAL( sep_set.iterative_size(), 3 );
+
+ interval_set<T> join_set;
+ join_set.add(I0_4D).add(I2_6D).add(I5_7D).add(I7_8D).add(I8_9I);
+ BOOST_CHECK_EQUAL( join_set.iterative_size(), 1 );
+
+ // Make sets to be subtracted
+ split_interval_set<T> split_sub;
+ split_sub.add(I3_6D).add(I8_9D);
+
+ separate_interval_set<T> sep_sub;
+ sep_sub.add(I3_6D).add(I8_9D);
+
+ interval_set<T> join_sub;
+ join_sub.add(I3_6D).add(I8_9D);
+
+ //--------------------------------------------------------------------------
+ // Test for split_interval_set
+ split_interval_set<T> split_diff = split_set;
+ separate_interval_set<T> sep_diff = sep_set;
+ interval_set<T> join_diff = join_set;
+
+ //subtraction combinations
+ split_diff -= split_sub;
+ sep_diff -= split_sub;
+ join_diff -= split_sub;
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( sep_diff.iterative_size(), 4 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 3 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for separate_interval_set. Reinitialize
+ split_diff = split_set;
+ sep_diff = sep_set;
+ join_diff = join_set;
+
+ //subtraction combinations
+ split_diff -= sep_sub;
+ sep_diff -= sep_sub;
+ join_diff -= sep_sub;
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( sep_diff.iterative_size(), 4 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 3 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, sep_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for interval_set. Reinitialize
+ split_diff = split_set;
+ sep_diff = sep_set;
+ join_diff = join_set;
+
+ //subtraction combinations
+ split_diff -= join_sub;
+ sep_diff -= join_sub;
+ join_diff -= join_sub;
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( sep_diff.iterative_size(), 4 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 3 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_erase_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_4D = rightopen_interval(v0,v4);
+ interval<T> I2_6D = rightopen_interval(v2,v6);
+ interval<T> I3_6D = rightopen_interval(v3,v6);
+ interval<T> I5_7D = rightopen_interval(v5,v7);
+ interval<T> I7_8D = rightopen_interval(v7,v8);
+ interval<T> I8_9D = rightopen_interval(v8,v9);
+ interval<T> I8_9I = closed_interval(v8,v9);
+
+ //JODO INSIGHT: With respect to subtraction all interval_sets are working equivalently:
+ //Never does a subtract operation introduce or preserve interval borders within
+ //the range of the subtracted elements. This is almost trivial.
+ //LAW: y -= x == y -= x.join()
+ split_interval_set<T> split_set;
+ split_set.add(I0_4D).add(I2_6D).add(I5_7D).add(I7_8D).add(I8_9I);
+ BOOST_CHECK_EQUAL( split_set.iterative_size(), 7 );
+
+ separate_interval_set<T> sep_set;
+ sep_set.add(I0_4D).add(I2_6D).add(I5_7D).add(I7_8D).add(I8_9I);
+ BOOST_CHECK_EQUAL( sep_set.iterative_size(), 3 );
+
+ interval_set<T> join_set;
+ join_set.add(I0_4D).add(I2_6D).add(I5_7D).add(I7_8D).add(I8_9I);
+ BOOST_CHECK_EQUAL( join_set.iterative_size(), 1 );
+
+ // Make sets to be subtracted
+ split_interval_set<T> split_sub;
+ split_sub.add(I3_6D).add(I8_9D);
+
+ separate_interval_set<T> sep_sub;
+ sep_sub.add(I3_6D).add(I8_9D);
+
+ interval_set<T> join_sub;
+ join_sub.add(I3_6D).add(I8_9D);
+
+ //--------------------------------------------------------------------------
+ // Test for split_interval_set
+ split_interval_set<T> split_diff = split_set;
+ separate_interval_set<T> sep_diff = sep_set;
+ interval_set<T> join_diff = join_set;
+
+ //subtraction combinations
+ erase(split_diff, split_sub);
+ erase(sep_diff, split_sub);
+ erase(join_diff, split_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( sep_diff.iterative_size(), 4 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 3 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for separate_interval_set. Reinitialize
+ split_diff = split_set;
+ sep_diff = sep_set;
+ join_diff = join_set;
+
+ //subtraction combinations
+ erase(split_diff, sep_sub);
+ erase(sep_diff, sep_sub);
+ erase(join_diff, sep_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( sep_diff.iterative_size(), 4 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 3 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(split_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, sep_diff), true );
+
+ //--------------------------------------------------------------------------
+ // Test for interval_set. Reinitialize
+ split_diff = split_set;
+ sep_diff = sep_set;
+ join_diff = join_set;
+
+ //subtraction combinations
+ erase(split_diff, join_sub);
+ erase(sep_diff, join_sub);
+ erase(join_diff, join_sub);
+
+ BOOST_CHECK_EQUAL( split_diff.iterative_size(), 5 );
+ BOOST_CHECK_EQUAL( sep_diff.iterative_size(), 4 );
+ BOOST_CHECK_EQUAL( join_diff.iterative_size(), 3 );
+
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, split_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, sep_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(sep_diff, join_diff), true );
+ BOOST_CHECK_EQUAL( is_element_equal(join_diff, join_diff), true );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_basic_intersect_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I1_8D = rightopen_interval(v1,v8);
+ interval<T> I2_7D = rightopen_interval(v2,v7);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I6_7D = rightopen_interval(v6,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ //--------------------------------------------------------------------------
+ // split_interval_set
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // *= [1 8)
+ //split_AB -> [1 3) [6 8)
+ // *= [2 7)
+ // -> [2 3) [6 7)
+ split_interval_set<T> split_A, split_B, split_AB, split_ab, split_ab2;
+
+ split_A.add(I0_3D).add(I6_9D);
+ split_AB = split_A;
+ split_AB *= I1_8D;
+ split_ab.add(I1_3D).add(I6_8D);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ (split_AB *= I1_8D) *= I2_7D;
+ split_ab2.add(I2_3D).add(I6_7D);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab2 );
+
+
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // *= 1
+ //split_AB -> [1]
+ // += (1 7)
+ // -> [1](1 7)
+ split_A.add(I0_3D).add(I6_9D);
+ split_AB = split_A;
+ split_AB *= v1;
+ split_ab.clear();
+ split_ab.add(v1);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ (split_AB *= v1) += open_interval<T>(v1,v7);
+ split_ab2.clear();
+ split_ab2 += rightopen_interval<T>(v1,v7);
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_AB, split_ab2), true );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_intersect_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_2D = rightopen_interval(v1,v2);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I2_4D = rightopen_interval(v2,v4);
+ interval<T> I5_8D = rightopen_interval(v5,v8);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ //--------------------------------------------------------------------------
+ // split_interval_set
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ //split_B *= [1 2)[2 4) [5 8)
+ //split_AB -> [1 2)[2 3) [6 8)
+ split_interval_set<T> split_A, split_B, split_AB, split_ab, split_ab_jn;
+ separate_interval_set<T> sep_A, sep_B, sep_AB, sep_ab;
+ interval_set<T> join_A, join_B, join_AB, join_ab;
+
+ split_A.add(I0_3D).add(I6_9D);
+ split_B.add(I1_2D).add(I2_4D).add(I5_8D);
+ split_ab.add(I1_2D).add(I2_3D).add(I6_8D);
+ split_ab_jn.add(I1_3D).add(I6_8D);
+ split_AB = split_A;
+ split_AB *= split_B;
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 3 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ //split_A [0 3) [6 9)
+ //sep_B *= [1 2)[2 4) [5 8)
+ //split_AB -> [1 2)[2 3) [6 8)
+ split_AB = split_A;
+ sep_B = split_B;
+ split_AB *= sep_B;
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 3 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ //split_A [0 3) [6 9)
+ //join_B *= [1 4) [5 8)
+ //split_AB -> [1 3) [6 8)
+ split_AB = split_A;
+ join_B = split_B;
+ split_AB *= join_B;
+
+ BOOST_CHECK_EQUAL( split_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( split_AB, split_ab_jn );
+
+ //--------------------------------------------------------------------------
+ // separate_interval_set
+ //--------------------------------------------------------------------------
+ //sep_A [0 3) [6 9)
+ //sep_B *= [1 2)[2 4) [5 8)
+ //sep_AB -> [1 2)[2 3) [6 8)
+ sep_ab = split_ab;
+ BOOST_CHECK_EQUAL( sep_ab.iterative_size(), 3 );
+
+ sep_AB = split_A;
+ sep_B = split_B;
+ sep_AB *= sep_B;
+
+ BOOST_CHECK_EQUAL( sep_AB.iterative_size(), 3 );
+ BOOST_CHECK_EQUAL( sep_AB, sep_ab );
+
+ //sep_A [0 3) [6 9)
+ //split_B *= [1 2)[2 4) [5 8)
+ //sep_AB -> [1 2)[2 3) [6 8)
+ sep_AB = split_A;
+ sep_AB *= split_B;
+
+ BOOST_CHECK_EQUAL( sep_AB.iterative_size(), 3 );
+ BOOST_CHECK_EQUAL( sep_AB, sep_ab );
+
+ //sep_A [0 3) [6 9)
+ //join_B *= [1 4) [5 8)
+ //sep_AB -> [1 3) [6 8)
+ separate_interval_set<T> sep_ab_jn = split_ab_jn;
+ sep_AB = split_A;
+ join_B = split_B;
+ sep_AB *= join_B;
+
+ BOOST_CHECK_EQUAL( sep_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( sep_AB, sep_ab_jn );
+
+ //--------------------------------------------------------------------------
+ // separate_interval_set
+ //--------------------------------------------------------------------------
+ //join_A [0 3) [6 9)
+ //join_B *= [1 4) [5 8)
+ //join_AB -> [1 3) [6 8)
+ join_ab = split_ab;
+ BOOST_CHECK_EQUAL( join_ab.iterative_size(), 2 );
+
+ join_AB = split_A;
+ join_B = split_B;
+ join_AB *= sep_B;
+
+ BOOST_CHECK_EQUAL( join_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( join_AB, join_ab );
+
+ //join_A [0 3) [6 9)
+ //split_B *= [1 2)[2 4) [5 8)
+ //join_AB -> [1 3) [6 8)
+ join_AB = split_A;
+ join_AB *= split_B;
+
+ BOOST_CHECK_EQUAL( join_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( join_AB, join_ab );
+
+ //join_A [0 3) [6 9)
+ //sep_B *= [1 2)[2 4) [5 8)
+ //join_AB -> [1 3) [6 8)
+ join_AB = split_A;
+ join_AB *= sep_B;
+
+ BOOST_CHECK_EQUAL( join_AB.iterative_size(), 2 );
+ BOOST_CHECK_EQUAL( join_AB, join_ab );
+
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_disjoint_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_2D = rightopen_interval(v0,v2);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I3_4D = rightopen_interval(v3,v4);
+ interval<T> I4_4I = closed_interval(v4,v4);
+ interval<T> C4_6D = open_interval(v4,v6);
+ interval<T> I6_6I = closed_interval(v6,v6);
+
+ //--------------------------------------------------------------------------
+ //split_A: [0 2) [4 4] [6 6]
+ //split_B: [2 3)[3 4) (4 6)
+ split_interval_set<T> split_A, split_B;
+
+ split_A.add(I0_2D).add(I4_4I).add(I6_6I);
+ split_B.add(I2_3D).add(I3_4D).add(C4_6D);
+
+ separate_interval_set<T> sep_A(split_A), sep_B(split_B);
+ interval_set<T> join_A(split_A), join_B(split_B);
+
+ BOOST_CHECK_EQUAL( is_disjoint(split_A, split_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(split_A, sep_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(split_A, join_B), true );
+
+ BOOST_CHECK_EQUAL( is_disjoint(sep_A, split_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(sep_A, sep_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(sep_A, join_B), true );
+
+ BOOST_CHECK_EQUAL( is_disjoint(join_A, split_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(join_A, sep_B), true );
+ BOOST_CHECK_EQUAL( is_disjoint(join_A, join_B), true );
+}
Added: sandbox/itl/libs/itl/test/test_interval_set_mixed/vc9_test_interval_set_mixed.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_set_mixed/vc9_test_interval_set_mixed.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_interval_set_mixed"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B8D3A9F9E}"
+ RootNamespace="Test_interval_set_mixed"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_interval_set_mixed.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\test_interval_set_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_interval_set_shared.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_interval_set_shared.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,503 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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 __test_itl_interval_set_shared_h_JOFA_080920__
+#define __test_itl_interval_set_shared_h_JOFA_080920__
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_fundamentals_4_ordered_types()
+{
+ typedef typename IntervalSet<T>::size_type size_T;
+ typedef typename IntervalSet<T>::difference_type diff_T;
+
+ // ordered types is the largest set of instance types.
+ // Because we can not generate values via incrementation for e.g. string,
+ // we are able to test operations only for the most basic values
+ // neutron (0, empty, T() ...) and unon.
+
+ //T v0 = neutron<T>(); //JODO check operator() variant
+ //T v1 = unon<T>();
+ T v0 = neutron<T>::value();
+ T v1 = unon<T>::value();
+ interval<T> I0_0I(v0);
+ interval<T> I1_1I(v1);
+ interval<T> I0_1I(v0,v1);
+
+ //-------------------------------------------------------------------------
+ //empty set
+ //-------------------------------------------------------------------------
+ BOOST_CHECK_EQUAL(IntervalSet<T>().empty(), true);
+ BOOST_CHECK_EQUAL(IntervalSet<T>().cardinality(), neutron<size_T>::value());
+ BOOST_CHECK_EQUAL(IntervalSet<T>().size(), neutron<size_T>::value());
+ BOOST_CHECK_EQUAL(IntervalSet<T>().interval_count(), 0);
+ BOOST_CHECK_EQUAL(IntervalSet<T>().iterative_size(), 0);
+ BOOST_CHECK_EQUAL(IntervalSet<T>(), IntervalSet<T>());
+
+ interval<T> mt_interval = neutron<interval<T> >::value();
+ BOOST_CHECK_EQUAL(mt_interval, interval<T>());
+ IntervalSet<T> mt_set = neutron<IntervalSet<T> >::value();
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+
+ //adding emptieness to emptieness yields emptieness ;)
+ mt_set.add(mt_interval).add(mt_interval);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ mt_set.insert(mt_interval).insert(mt_interval);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ (mt_set += mt_interval) += mt_interval;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ BOOST_CHECK_EQUAL(enclosure(mt_set), neutron<interval<T> >::value());
+
+ //subtracting emptieness
+ mt_set.subtract(mt_interval).subtract(mt_interval);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ mt_set.erase(mt_interval).erase(mt_interval);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ (mt_set -= mt_interval) -= mt_interval;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+
+ //subtracting elements form emptieness
+ mt_set.subtract(v0).subtract(v1);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ mt_set.erase(v0).erase(v1);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ (mt_set -= v1) -= v0;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+
+ //subtracting intervals form emptieness
+ mt_set.subtract(I0_1I).subtract(I1_1I);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ mt_set.erase(I0_1I).erase(I1_1I);
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ (mt_set -= I1_1I) -= I0_1I;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+
+ //insecting emptieness
+ //mt_set.insect(mt_interval).insect(mt_interval);
+ //BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ (mt_set *= mt_interval) *= mt_interval;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ //insecting emptieness with elements
+ (mt_set *= v1) *= v0;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+ //insecting emptieness with intervals
+ (mt_set *= I1_1I) *= I0_1I;
+ BOOST_CHECK_EQUAL(mt_set, IntervalSet<T>());
+
+ //-------------------------------------------------------------------------
+ //unary set
+ //-------------------------------------------------------------------------
+ IntervalSet<T> single_I0_0I_from_element(v0);
+ IntervalSet<T> single_I0_0I_from_interval(I0_0I);
+ IntervalSet<T> single_I0_0I(single_I0_0I_from_interval);
+
+ BOOST_CHECK_EQUAL(single_I0_0I_from_element, single_I0_0I_from_interval);
+ BOOST_CHECK_EQUAL(single_I0_0I_from_element, single_I0_0I);
+ BOOST_CHECK_EQUAL(single_I0_0I.lower(), I0_0I.lower());
+ BOOST_CHECK_EQUAL(single_I0_0I.upper(), I0_0I.upper());
+
+ IntervalSet<T> single_I1_1I_from_element(v1);
+ IntervalSet<T> single_I1_1I_from_interval(I1_1I);
+ IntervalSet<T> single_I1_1I(single_I1_1I_from_interval);
+
+ BOOST_CHECK_EQUAL(single_I1_1I_from_element, single_I1_1I_from_interval);
+ BOOST_CHECK_EQUAL(single_I1_1I_from_element, single_I1_1I);
+
+ IntervalSet<T> single_I0_1I_from_interval(I0_1I);
+ IntervalSet<T> single_I0_1I(single_I0_1I_from_interval);
+
+ BOOST_CHECK_EQUAL(single_I0_1I_from_interval, single_I0_1I);
+ BOOST_CHECK_EQUAL(enclosure(single_I0_1I), I0_1I);
+ BOOST_CHECK_EQUAL(single_I0_1I.lower(), I0_1I.lower());
+ BOOST_CHECK_EQUAL(single_I0_1I.upper(), I0_1I.upper());
+
+ //contains predicate
+ BOOST_CHECK_EQUAL(single_I0_0I.contains(v0), true);
+ BOOST_CHECK_EQUAL(single_I0_0I.contains(I0_0I), true);
+ BOOST_CHECK_EQUAL(single_I1_1I.contains(v1), true);
+ BOOST_CHECK_EQUAL(single_I1_1I.contains(I1_1I), true);
+
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(v0), true);
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(I0_1I), true);
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(v1), true);
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(I1_1I), true);
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(single_I0_0I), true);
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(single_I1_1I), true);
+ BOOST_CHECK_EQUAL(single_I0_1I.contains(single_I0_1I), true);
+
+ BOOST_CHECK_EQUAL(single_I0_0I.cardinality(), unon<size_T>::value());
+ BOOST_CHECK_EQUAL(single_I0_0I.size(), unon<size_T>::value());
+ BOOST_CHECK_EQUAL(single_I0_0I.interval_count(), 1);
+ BOOST_CHECK_EQUAL(single_I0_0I.iterative_size(), 1);
+}
+
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_ctor_4_bicremental_types()
+{
+ T v4 = make<T>(4);
+ interval<T> I4_4I(v4);
+
+ IntervalSet<T> _I4_4I;
+ BOOST_CHECK_EQUAL( _I4_4I.empty(), true );
+ IntervalSet<T> _I4_4I_1;
+ IntervalSet<T> _I4_4I_2;
+ IntervalSet<T> _I4_4I_3;
+ _I4_4I += v4;
+ _I4_4I_1 += I4_4I;
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_1 );
+ _I4_4I_2.add(v4);
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_2 );
+ _I4_4I_3.add(I4_4I);
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_3 );
+ _I4_4I_1.add(v4).add(I4_4I);
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_1 );
+ _I4_4I_1.insert(v4).insert(I4_4I);
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_1 );
+ (_I4_4I_1 += v4) += I4_4I;
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_1 );
+
+ BOOST_CHECK_EQUAL( _I4_4I.cardinality(), unon<typename IntervalSet<T>::size_type>::value() );
+ BOOST_CHECK_EQUAL( _I4_4I.size(), unon<typename IntervalSet<T>::size_type>::value() );
+ BOOST_CHECK_EQUAL( _I4_4I.interval_count(), 1 );
+ BOOST_CHECK_EQUAL( _I4_4I.iterative_size(), 1 );
+ BOOST_CHECK_EQUAL( _I4_4I.lower(), v4 );
+ BOOST_CHECK_EQUAL( _I4_4I.upper(), v4 );
+
+ IntervalSet<T> _I4_4I_copy(_I4_4I);
+ IntervalSet<T> _I4_4I_assigned;
+ _I4_4I_assigned = _I4_4I;
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_copy );
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_assigned );
+ _I4_4I_assigned.clear();
+ BOOST_CHECK_EQUAL( true, _I4_4I_assigned.empty() );
+
+ _I4_4I_assigned.swap(_I4_4I_copy);
+ BOOST_CHECK_EQUAL( true, _I4_4I_copy.empty() );
+ BOOST_CHECK_EQUAL( _I4_4I, _I4_4I_assigned );
+
+}
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_add_sub_4_bicremental_types()
+{
+ T v0 = make<T>(0);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v9 = make<T>(9);
+ interval<T> I5_6I(v5,v6);
+ interval<T> I5_9I(v5,v9);
+ interval<T> I0_9I = closed_interval(v0, v9);
+
+ BOOST_CHECK_EQUAL( IntervalSet<T>(I5_6I).add(v0).add(v9),
+ IntervalSet<T>().insert(v9).insert(I5_6I).insert(v0) );
+
+ IntervalSet<T> set_A = IntervalSet<T>(I5_6I).add(v0).add(v9);
+ IntervalSet<T> set_B = IntervalSet<T>().insert(v9).insert(I5_6I).insert(v0);
+ BOOST_CHECK_EQUAL( set_A, set_B );
+ BOOST_CHECK_EQUAL( enclosure(set_A), I0_9I );
+ BOOST_CHECK_EQUAL( set_A.lower(), I0_9I.lower() );
+ BOOST_CHECK_EQUAL( set_A.upper(), I0_9I.upper() );
+ //JODO: LAW !a.empty() => enclosure(a).lower() == a.lower()
+ //JODO: LAW !a.empty() => enclosure(a).upper() == a.upper()
+
+ IntervalSet<T> set_A1 = set_A, set_B1 = set_B,
+ set_A2 = set_A, set_B2 = set_B;
+
+ set_A1.subtract(I5_6I).subtract(v9);
+ set_B1.erase(v9).erase(I5_6I);
+ BOOST_CHECK_EQUAL( set_A1, set_B1 );
+
+ set_A2.subtract(I5_9I);
+ set_B2.erase(I5_9I);
+ BOOST_CHECK_EQUAL( set_A1, set_B1 );
+ BOOST_CHECK_EQUAL( set_A1, set_A2 );
+ BOOST_CHECK_EQUAL( set_B1, set_B2 );
+}
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_distinct_4_bicremental_types()
+{
+ typedef typename IntervalSet<T>::size_type size_T;
+ typedef typename IntervalSet<T>::difference_type diff_T;
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+
+ size_T s3 = make<size_T>(3);
+ diff_T d0 = make<diff_T>(0);
+
+ IntervalSet<T> is_1_3_5;
+ is_1_3_5.add(v1).add(v3).add(v5);
+
+ BOOST_CHECK_EQUAL( is_1_3_5.cardinality(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.size(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.interval_count(), 3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(), 3 );
+}
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_distinct_4_bicremental_continuous_types()
+{
+ typedef typename IntervalSet<T>::size_type size_T;
+ typedef typename IntervalSet<T>::difference_type diff_T;
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+
+ size_T s3 = make<size_T>(3);
+ diff_T d0 = make<diff_T>(0);
+ diff_T d2 = make<diff_T>(2);
+ diff_T d3 = make<diff_T>(3);
+
+ IntervalSet<T> is_1_3_5;
+ is_1_3_5.add(v1).add(v3).add(v5);
+
+ BOOST_CHECK_EQUAL( is_1_3_5.cardinality(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.size(), s3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.length(), d0 );
+ BOOST_CHECK_EQUAL( is_1_3_5.interval_count(), 3 );
+ BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(), 3 );
+
+ size_T s4 = make<size_T>(4);
+ diff_T d4 = make<diff_T>(4);
+
+ IntervalSet<T> is_123_5;
+ is_123_5 = is_1_3_5;
+ is_123_5 += open_interval<T>(v1,v3);
+
+ BOOST_CHECK_EQUAL( is_123_5.cardinality(), std::numeric_limits<size_T>::infinity() );
+ BOOST_CHECK_EQUAL( is_123_5.size(), std::numeric_limits<size_T>::infinity() );
+ BOOST_CHECK_EQUAL( is_123_5.length(), d2 );
+}
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_isolate_4_bicremental_continuous_types()
+{
+ typedef typename IntervalSet<T>::size_type size_T;
+ typedef typename IntervalSet<T>::difference_type diff_T;
+
+ T v0 = make<T>(0);
+ T v2 = make<T>(2);
+ T v4 = make<T>(4);
+ interval<T> I0_4I = closed_interval(v0,v4);
+ interval<T> C0_2D = open_interval(v0,v2);
+ interval<T> C2_4D = open_interval(v2,v4);
+ // {[0 4]}
+ // - { (0,2) (2,4) }
+ // = {[0] [2] [4]}
+ IntervalSet<T> iso_set = IntervalSet<T>(I0_4I);
+ IntervalSet<T> gap_set;
+ gap_set.add(C0_2D).add(C2_4D);
+ iso_set -= gap_set;
+
+ BOOST_CHECK_EQUAL( iso_set.cardinality(), static_cast<size_T>(3) );
+ BOOST_CHECK_EQUAL( iso_set.iterative_size(), static_cast<std::size_t>(3) );
+
+ IntervalSet<T> iso_set2;
+ iso_set2.add(I0_4I);
+ iso_set2.subtract(C0_2D).subtract(C2_4D);
+
+ IntervalSet<T> iso_set3(I0_4I);
+ (iso_set3 -= C0_2D) -= C2_4D;
+
+ IntervalSet<T> iso_set4;
+ iso_set4.insert(I0_4I);
+ iso_set4.erase(C0_2D).erase(C2_4D);
+
+ BOOST_CHECK_EQUAL( iso_set, iso_set2 );
+ BOOST_CHECK_EQUAL( iso_set, iso_set3 );
+ BOOST_CHECK_EQUAL( iso_set, iso_set4 );
+}
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_contains_4_bicremental_types()
+{
+ //LAW: x.add(e).contains(e);
+ //LAW: z = x + y => z.contains(x) && z.contains(y);
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+ T v11 = make<T>(11);
+ IntervalSet<T> is(v1);
+ BOOST_CHECK_EQUAL( is.contains(v1), true );
+
+ BOOST_CHECK_EQUAL( IntervalSet<T>().add(make<T>(2)).contains(make<T>(2)), true );
+ BOOST_CHECK_EQUAL( IntervalSet<T>().insert(make<T>(2)).contains(make<T>(2)), true );
+ BOOST_CHECK_EQUAL( (is += interval<T>(v3,v7)).contains(interval<T>(v3,v7)), true );
+
+ IntervalSet<T> is0 = is;
+
+ IntervalSet<T> is2(closed_interval(v5,v8));
+ is2.add(v9).add(v11);
+ is += is2;
+ BOOST_CHECK_EQUAL( is.contains(is2), true );
+
+ is = is0;
+ IntervalSet<T> is3(closed_interval(v5,v8));
+ is3.insert(v9).insert(v11);
+ is += is3;
+ BOOST_CHECK_EQUAL( is.contains(is3), true );
+}
+
+
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_operators_4_bicremental_types()
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v3 = make<T>(3);
+ T v5 = make<T>(5);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ IntervalSet<T> left, left2, right, all, all2, section, complement, naught;
+ left.add(closed_interval(v0,v1)).add(closed_interval(v3,v5));
+ (right += closed_interval(v3,v5)) += closed_interval(v7,v8);
+
+ BOOST_CHECK_EQUAL( is_disjoint(left, right), false );
+
+ (all += left) += right;
+ (section += left) *= right;
+ (complement += all) -= section;
+ (all2 += section) += complement;
+
+ BOOST_CHECK_EQUAL( is_disjoint(section, complement), true );
+ BOOST_CHECK_EQUAL( all, all2 );
+
+ BOOST_CHECK_EQUAL( all.contains(left), true );
+ BOOST_CHECK_EQUAL( all.contains(right), true );
+ BOOST_CHECK_EQUAL( all.contains(complement), true );
+ BOOST_CHECK_EQUAL( left.contains(section), true );
+ BOOST_CHECK_EQUAL( right.contains(section), true );
+
+ BOOST_CHECK_EQUAL( left.contained_in(all), true );
+ BOOST_CHECK_EQUAL( right.contained_in(all), true );
+ BOOST_CHECK_EQUAL( complement.contained_in(all), true );
+ BOOST_CHECK_EQUAL( section.contained_in(left), true );
+ BOOST_CHECK_EQUAL( section.contained_in(right), true );
+}
+
+
+// Test for nontrivial intersection of interval sets with intervals and values
+template <template<class T, template<class>class = interval,
+ template<class>class = std::less,
+ template<class>class = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_base_intersect_4_bicremental_types()
+{
+ T v0 = make<T>(0);
+ T v1 = make<T>(1);
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ T v9 = make<T>(9);
+
+ interval<T> I0_3D = rightopen_interval(v0,v3);
+ interval<T> I1_3D = rightopen_interval(v1,v3);
+ interval<T> I1_8D = rightopen_interval(v1,v8);
+ interval<T> I2_7D = rightopen_interval(v2,v7);
+ interval<T> I2_3D = rightopen_interval(v2,v3);
+ interval<T> I6_7D = rightopen_interval(v6,v7);
+ interval<T> I6_8D = rightopen_interval(v6,v8);
+ interval<T> I6_9D = rightopen_interval(v6,v9);
+
+ //--------------------------------------------------------------------------
+ // IntervalSet
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // *= [1 8)
+ //split_AB -> [1 3) [6 8)
+ // *= [2 7)
+ // -> [2 3) [6 7)
+ IntervalSet<T> split_A, split_B, split_AB, split_ab, split_ab2;
+
+ split_A.add(I0_3D).add(I6_9D);
+ split_AB = split_A;
+ split_AB *= I1_8D;
+ split_ab.add(I1_3D).add(I6_8D);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ (split_AB *= I1_8D) *= I2_7D;
+ split_ab2.add(I2_3D).add(I6_7D);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab2 );
+
+
+ //--------------------------------------------------------------------------
+ //split_A [0 3) [6 9)
+ // *= 1
+ //split_AB -> [1]
+ // += (1 7)
+ // -> [1](1 7)
+ split_A.add(I0_3D).add(I6_9D);
+ split_AB = split_A;
+ split_AB *= v1;
+ split_ab.clear();
+ split_ab.add(v1);
+
+ BOOST_CHECK_EQUAL( split_AB, split_ab );
+
+ split_AB = split_A;
+ (split_AB *= v1) += open_interval<T>(v1,v7);
+ split_ab2.clear();
+ split_ab2 += rightopen_interval<T>(v1,v7);
+
+ BOOST_CHECK_EQUAL( is_element_equal(split_AB, split_ab2), true );
+}
+
+
+#endif // __test_itl_interval_set_shared_h_JOFA_080920__
+
Added: sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_itl_interval/test_itl_interval.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,272 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/interval.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+
+// Most general, largest set of types
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_ctor_4_ordered_types, T, ordered_types)
+{
+ // An empty interval is defined as the closed interval [1,0]
+ BOOST_CHECK_EQUAL(interval<T>().empty(), true);
+ BOOST_CHECK_EQUAL(interval<T>().cardinality(), itl::neutron<typename itl::size<T>::type>::value());
+ BOOST_CHECK_EQUAL(interval<T>().size(), itl::neutron<typename itl::size<T>::type>::value());
+ //JODO STATIC_ASSERTS length fails with std::string
+ //BOOST_CHECK_EQUAL(interval<T>().length(), itl::neutron<itl::typename difference<T>::type>::value());
+ BOOST_CHECK_EQUAL(interval<T>().lower(), itl::unon<T>::value());
+ BOOST_CHECK_EQUAL(interval<T>().upper(), itl::neutron<T>::value());
+
+ BOOST_CHECK_EQUAL(interval<T>(), interval<T>());
+ BOOST_CHECK_EQUAL(interval<T>(), interval<T>(itl::unon<T>::value(), itl::neutron<T>::value()));
+ BOOST_CHECK_EQUAL(interval<T>(), interval<T>(itl::unon<T>::value(), itl::neutron<T>::value(), interval<T>::CLOSED));
+
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_ctor_4_bicremental_types, T, bicremental_types)
+{
+ BOOST_CHECK_EQUAL( T(), pred(succ(T())));
+ BOOST_CHECK_EQUAL( itl::neutron<T>::value(), pred(succ(itl::neutron<T>::value())) );
+ BOOST_CHECK_EQUAL( itl::unon<T>::value(), succ(itl::neutron<T>::value()) );
+ BOOST_CHECK_EQUAL( interval<T>().length(), itl::neutron<typename difference<T>::type>::value() );
+
+ T v4 = make<T>(4);
+ itl::interval<T> I4_4I(v4);
+ BOOST_CHECK_EQUAL( I4_4I.is_closed(), true );
+ BOOST_CHECK_EQUAL( I4_4I.is_leftopen(), false );
+ BOOST_CHECK_EQUAL( I4_4I.is_rightopen(), false );
+ BOOST_CHECK_EQUAL( I4_4I.is_open(), false );
+ BOOST_CHECK_EQUAL( I4_4I.leftbound_closed(), true );
+ BOOST_CHECK_EQUAL( I4_4I.rightbound_closed(), true );
+ BOOST_CHECK_EQUAL( I4_4I.leftbound_open(), false );
+ BOOST_CHECK_EQUAL( I4_4I.rightbound_open(), false );
+
+ BOOST_CHECK_EQUAL( I4_4I.lower(), v4 );
+ BOOST_CHECK_EQUAL( I4_4I.upper(), v4 );
+
+ BOOST_CHECK_EQUAL( I4_4I.contains(v4), true );
+ BOOST_CHECK_EQUAL( I4_4I.contains(I4_4I), true );
+ BOOST_CHECK_EQUAL( I4_4I.contained_in(I4_4I), true );
+ BOOST_CHECK_EQUAL( I4_4I, I4_4I );
+
+ BOOST_CHECK_EQUAL( I4_4I.cardinality(), unon<typename interval<T>::size_type>::value() );
+ BOOST_CHECK_EQUAL( I4_4I.size(), unon<typename interval<T>::size_type>::value() );
+ //BOOST_CHECK_EQUAL( I4_4I.length(), neutron<typename interval<T>::difference_type>::value() );
+
+ itl::interval<T> j_4_4(I4_4I);
+ BOOST_CHECK_EQUAL( I4_4I, j_4_4 );
+ interval<T> k_4_4;
+ k_4_4 = j_4_4;
+ BOOST_CHECK_EQUAL( I4_4I, k_4_4 );
+
+ T v2 = make<T>(2);
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4), interval<T>(v2, v4) );
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4), interval<T>(v2, v4, interval<T>::CLOSED) );
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4), interval<T>(v2, v4, interval<T>::RIGHT_OPEN) );
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4), interval<T>(v2, v4, interval<T>::LEFT_OPEN) );
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4), interval<T>(v2, v4, interval<T>::OPEN) );
+
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4).lower(), v2 );
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4).upper(), v4 );
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4).boundtypes(), interval<T>::CLOSED );
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4).is_closed(), true );
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4).leftbound_closed(), true );
+ BOOST_CHECK_EQUAL( closed_interval<T>(v2, v4).rightbound_closed(), true );
+
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4).lower(), v2 );
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4).upper(), v4 );
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4).boundtypes(), interval<T>::RIGHT_OPEN );
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4).is_rightopen(), true );
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4).leftbound_closed(), true );
+ BOOST_CHECK_EQUAL( rightopen_interval<T>(v2, v4).rightbound_open(), true );
+
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4).lower(), v2 );
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4).upper(), v4 );
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4).boundtypes(), interval<T>::LEFT_OPEN );
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4).is_leftopen(), true );
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4).leftbound_open(), true );
+ BOOST_CHECK_EQUAL( leftopen_interval<T>(v2, v4).rightbound_closed(), true );
+
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4).lower(), v2 );
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4).upper(), v4 );
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4).boundtypes(), interval<T>::OPEN );
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4).is_open(), true );
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4).leftbound_open(), true );
+ BOOST_CHECK_EQUAL( open_interval<T>(v2, v4).rightbound_open(), true );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_ctor_4_integral_types, T, integral_types)
+{
+ BOOST_CHECK_EQUAL(interval<T>().first(), itl::unon<T>::value());
+ BOOST_CHECK_EQUAL(interval<T>().last(), itl::neutron<T>::value());
+ BOOST_CHECK_EQUAL(interval<T>().length(), itl::neutron<typename interval<T>::difference_type>::value());
+
+ BOOST_CHECK_EQUAL(interval<T>(0,0).length(), itl::unon<typename interval<T>::difference_type>::value());
+}
+
+BOOST_AUTO_TEST_CASE(test_itl_interval_ctor_specific)
+{
+ BOOST_CHECK_EQUAL(interval<double>().continuous_length(), 0.0);
+ BOOST_CHECK_EQUAL(interval<double>(5.0,5.0).cardinality(), 1);
+ BOOST_CHECK_EQUAL(interval<std::string>("test","test").cardinality(), 1);
+ BOOST_CHECK_EQUAL(interval<std::string>("best","test").cardinality(), interval<double>(0.0,0.1).cardinality());
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_equal_4_integral_types, T, integral_types)
+{
+ T v2 = make<T>(2);
+ T v3 = make<T>(3);
+ T v7 = make<T>(7);
+ T v8 = make<T>(8);
+ BOOST_CHECK_EQUAL(interval<T>(), interval<T>(v7,v3));
+
+ //I: (I)nside = closed bound
+ //C: left open bound
+ //D: right open bound
+ interval<T> I3_7I = closed_interval<T>(v3,v7);
+ interval<T> I3__8D = rightopen_interval<T>(v3,v8);
+ interval<T> C2__7I = leftopen_interval<T>(v2,v7);
+ interval<T> C2___8D = open_interval<T>(v2,v8);
+
+ BOOST_CHECK_EQUAL( I3_7I , I3_7I );
+ BOOST_CHECK_EQUAL( I3_7I , I3__8D );
+ BOOST_CHECK_EQUAL( I3_7I , C2__7I );
+ BOOST_CHECK_EQUAL( I3_7I , C2___8D );
+
+ BOOST_CHECK_EQUAL( I3__8D, I3__8D );
+ BOOST_CHECK_EQUAL( I3__8D, C2__7I );
+ BOOST_CHECK_EQUAL( I3__8D, C2___8D );
+
+ BOOST_CHECK_EQUAL( C2__7I , C2__7I );
+ BOOST_CHECK_EQUAL( C2__7I , C2___8D );
+
+ BOOST_CHECK_EQUAL( C2___8D, C2___8D );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_equal_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{
+ T v3 = make<T>(3);
+ T v7 = make<T>(7);
+ BOOST_CHECK_EQUAL(interval<T>(), interval<T>(v7,v3));
+
+ //I: (I)nside = closed bound
+ //O: (O)utside = open bound
+ interval<T> I3_7I = closed_interval<T>(v3,v7);
+ interval<T> I3_7D = rightopen_interval<T>(v3,v7);
+ interval<T> C3_7I = leftopen_interval<T>(v3,v7);
+ interval<T> C3_7D = open_interval<T>(v3,v7);
+
+ BOOST_CHECK_EQUAL( I3_7I , I3_7I );
+ BOOST_CHECK_EQUAL( I3_7I == I3_7D, false );
+ BOOST_CHECK_EQUAL( I3_7I == C3_7D, false );
+ BOOST_CHECK_EQUAL( I3_7I == C3_7D, false );
+
+ BOOST_CHECK_EQUAL( I3_7D , I3_7D );
+ BOOST_CHECK_EQUAL( I3_7D == C3_7I, false );
+ BOOST_CHECK_EQUAL( I3_7D == C3_7D, false );
+
+ BOOST_CHECK_EQUAL( C3_7I , C3_7I );
+ BOOST_CHECK_EQUAL( C3_7I == C3_7D, false );
+
+ BOOST_CHECK_EQUAL( C3_7D, C3_7D );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_touches_4_bicremental_types, T, bicremental_types)
+{
+ T v3 = make<T>(3);
+ T v7 = make<T>(7);
+ T v9 = make<T>(9);
+
+ interval<T> I3_7D = rightopen_interval<T>(v3,v7);
+ interval<T> I7_9I = closed_interval<T>(v7,v9);
+ BOOST_CHECK_EQUAL( I3_7D.touches(I7_9I), true );
+
+ interval<T> I3_7I = closed_interval<T>(v3,v7);
+ interval<T> C7_9I = leftopen_interval<T>(v7,v9);
+ BOOST_CHECK_EQUAL( I3_7I.touches(C7_9I), true );
+
+ BOOST_CHECK_EQUAL( I3_7D.touches(C7_9I), false );
+ BOOST_CHECK_EQUAL( I3_7I.touches(I7_9I), false );
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_touches_4_integral_types, T, integral_types)
+{
+ T v3 = make<T>(3);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v9 = make<T>(9);
+
+ interval<T> I3_6I = closed_interval<T>(v3,v6);
+ interval<T> I7_9I = closed_interval<T>(v7,v9);
+ BOOST_CHECK_EQUAL( I3_6I.touches(I7_9I), true );
+
+ interval<T> I3_7D = rightopen_interval<T>(v3,v7);
+ interval<T> C6_9I = leftopen_interval<T>(v6,v9);
+ BOOST_CHECK_EQUAL( I3_7D.touches(C6_9I), true );
+}
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_intersect_4_bicremental_types, T, bicremental_types)
+{
+ T v0 = make<T>(0);
+ T v3 = make<T>(3);
+ T v4 = make<T>(4);
+ T v5 = make<T>(5);
+ T v6 = make<T>(6);
+ T v7 = make<T>(7);
+ T v9 = make<T>(9);
+
+ interval<T> section;
+ interval<T> I3_7D = rightopen_interval<T>(v3,v7);
+
+ interval<T> I0_3D = rightopen_interval<T>(v0,v3);
+ section = I3_7D; section *= I0_3D;
+ BOOST_CHECK_EQUAL( I0_3D.is_disjoint(I3_7D), true );
+ BOOST_CHECK_EQUAL( section.empty(), true );
+ BOOST_CHECK_EQUAL( section, interval<T>() );
+
+ interval<T> I0_5D = rightopen_interval<T>(v0,v5);
+ section = I3_7D; section *= I0_5D;
+ BOOST_CHECK_EQUAL( section, rightopen_interval<T>(v3, v5) );
+
+ interval<T> I0_9D = rightopen_interval<T>(v0,v9);
+ section = I3_7D; section *= I0_9D;
+ BOOST_CHECK_EQUAL( section, I3_7D );
+
+ interval<T> I4_5I = closed_interval<T>(v4,v5);
+ section = I3_7D; section *= I4_5I;
+ BOOST_CHECK_EQUAL( section, I4_5I );
+
+ interval<T> C4_6D = open_interval<T>(v4,v6);
+ section = I3_7D; section *= C4_6D;
+ BOOST_CHECK_EQUAL( section, C4_6D );
+
+ interval<T> C4_9I = leftopen_interval<T>(v4,v9);
+ section = I3_7D; section *= C4_9I;
+ BOOST_CHECK_EQUAL( section, open_interval<T>(v4,v7) );
+
+ interval<T> I7_9I = closed_interval<T>(v7,v9);
+ section = I3_7D; section *= I7_9I;
+ BOOST_CHECK_EQUAL( I3_7D.exclusive_less(I7_9I), true );
+ BOOST_CHECK_EQUAL( I3_7D.is_disjoint(I7_9I), true );
+ BOOST_CHECK_EQUAL( section.empty(), true );
+}
Added: sandbox/itl/libs/itl/test/test_itl_interval/vc9_test_itl_interval.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_itl_interval/vc9_test_itl_interval.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_itl_interval"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F8C}"
+ RootNamespace="Test_itl_interval"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_itl_interval.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,35 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/separate_interval_set.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+// -----------------------------------------------------------------------------
+// test_interval_set_shared are tests that should give identical results for all
+// interval_sets: interval_set, separate_interval_set and split_interval_set.
+#include "../test_interval_set_shared.hpp"
+
+// Due to limited expressiveness of the testing framework, the testcode in files
+// test_interval_set{,_separate,split}_shared.cpp are generated through code
+// replication.
+#include "test_separate_interval_set_shared.cpp"
+
+
Added: sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,43 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_fundamentals_4_ordered_types, T, ordered_types)
+{ interval_set_fundamentals_4_ordered_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_ctor_4_bicremental_types, T, bicremental_types)
+{ interval_set_ctor_4_bicremental_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_add_sub_4_bicremental_types, T, bicremental_types)
+{ interval_set_add_sub_4_bicremental_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_distinct_4_bicremental_types, T, bicremental_types)
+{ interval_set_distinct_4_bicremental_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_distinct_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_set_distinct_4_bicremental_continuous_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_isolate_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_set_isolate_4_bicremental_continuous_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_contains_4_bicremental_types, T, bicremental_types)
+{ interval_set_contains_4_bicremental_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_operators_4_bicremental_types, T, bicremental_types)
+{ interval_set_operators_4_bicremental_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_base_intersect_4_bicremental_types, T, bicremental_types)
+{ interval_set_base_intersect_4_bicremental_types<interval_set, T>();}
Added: sandbox/itl/libs/itl/test/test_separate_interval_set/vc9_test_separate_interval_set.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_separate_interval_set/vc9_test_separate_interval_set.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_separate_interval_set"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D3A9F9C}"
+ RootNamespace="Test_separate_interval_set"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_separate_interval_set.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\separate_interval_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_interval_set_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,35 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::split_interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/split_interval_map.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+// -----------------------------------------------------------------------------
+// test_interval_set_shared are tests that should give identical results for all
+// interval_sets: interval_set, separate_interval_set and split_interval_set.
+#include "../test_interval_map_shared.hpp"
+
+// Due to limited expressiveness of the testing framework, the testcode in files
+// test_interval_map{,_split}_shared.cpp is generated through code
+// replication.
+#include "test_split_interval_map_shared.cpp"
+
+
Added: sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,52 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_fundamentals_4_ordered_types, T, ordered_types)
+{ interval_map_fundamentals_4_ordered_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_ctor_4_bicremental_types, T, bicremental_types)
+{ interval_map_ctor_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_add_sub_4_bicremental_types, T, bicremental_types)
+{ interval_map_add_sub_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_distinct_4_bicremental_types, T, bicremental_types)
+{ interval_map_distinct_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_distinct_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_map_distinct_4_bicremental_continuous_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_isolate_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_map_isolate_4_bicremental_continuous_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_contains_4_bicremental_types, T, bicremental_types)
+{ interval_map_contains_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_operators_4_bicremental_types, T, bicremental_types)
+{ interval_map_operators_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_base_intersect_4_bicremental_types, T, bicremental_types)
+{ interval_map_base_intersect_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_base_erase_4_bicremental_types, T, bicremental_types)
+{ interval_map_base_erase_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_base_is_disjoint_4_bicremental_types, T, bicremental_types)
+{ interval_map_base_is_disjoint_4_bicremental_types<split_interval_map, T, int>();}
+
Added: sandbox/itl/libs/itl/test/test_split_interval_map/vc9_test_split_interval_map.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_split_interval_map/vc9_test_split_interval_map.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_split_interval_map"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D2A9F9E}"
+ RootNamespace="Test_split_interval_map"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_split_interval_map.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\test_interval_map_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,35 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+#define BOOST_TEST_MODULE itl::interval_set unit test
+#include <string>
+#include <boost/mpl/list.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/test_case_template.hpp>
+
+// interval instance types
+#include "../test_type_lists.hpp"
+#include "../test_value_maker.hpp"
+
+#include <boost/itl/split_interval_set.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace unit_test;
+using namespace boost::itl;
+
+// -----------------------------------------------------------------------------
+// test_interval_set_shared are tests that should give identical results for all
+// interval_sets: interval_set, separate_interval_set and split_interval_set.
+#include "../test_interval_set_shared.hpp"
+
+// Due to limited expressiveness of the testing framework, the testcode in files
+// test_interval_set{,_separate,split}_shared.cpp are generated through code
+// replication.
+#include "test_split_interval_set_shared.cpp"
+
+
Added: sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,44 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: 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)
++----------------------------------------------------------------------------*/
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_fundamentals_4_ordered_types, T, ordered_types)
+{ interval_set_fundamentals_4_ordered_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_ctor_4_bicremental_types, T, bicremental_types)
+{ interval_set_ctor_4_bicremental_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_add_sub_4_bicremental_types, T, bicremental_types)
+{ interval_set_add_sub_4_bicremental_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_distinct_4_bicremental_types, T, bicremental_types)
+{ interval_set_distinct_4_bicremental_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_distinct_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_set_distinct_4_bicremental_continuous_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_isolate_4_bicremental_continuous_types, T, bicremental_continuous_types)
+{ interval_set_isolate_4_bicremental_continuous_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_contains_4_bicremental_types, T, bicremental_types)
+{ interval_set_contains_4_bicremental_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_operators_4_bicremental_types, T, bicremental_types)
+{ interval_set_operators_4_bicremental_types<split_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_base_intersect_4_bicremental_types, T, bicremental_types)
+{ interval_set_base_intersect_4_bicremental_types<split_interval_set, T>();}
+
Added: sandbox/itl/libs/itl/test/test_split_interval_set/vc9_test_split_interval_set.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_split_interval_set/vc9_test_split_interval_set.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_test_split_interval_set"
+ ProjectGUID="{EE61B7EF-EC45-4165-8B49-FD5B7D4A9F9C}"
+ RootNamespace="Test_split_interval_set"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib; ../../../../stage/lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\test_split_interval_set.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\itl\split_interval_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_interval_set_shared.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\test_type_lists.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl/test/test_type_lists.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_type_lists.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,63 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_test_type_lists_JOFA_080916_H__
+#define __itl_test_type_lists_JOFA_080916_H__
+
+#include <boost/mpl/list.hpp>
+
+// interval instance types
+#include <boost/itl/gregorian.hpp>
+#include <boost/itl/ptime.hpp>
+#include <boost/itl/rational.hpp>
+
+#include <boost/itl/interval.hpp>
+
+typedef ::boost::mpl::list<
+ unsigned short, unsigned int, unsigned long
+ ,short, int, long
+ ,float, double
+ ,boost::rational<int>
+ ,boost::posix_time::ptime
+// ,boost::gregorian::date
+> bicremental_types;
+
+typedef ::boost::mpl::list<
+ float, double
+ ,boost::rational<int>
+> bicremental_continuous_types;
+
+typedef ::boost::mpl::list<
+ unsigned short, unsigned int, unsigned long
+ ,short, int, long
+> integral_types;
+
+typedef ::boost::mpl::list<
+ unsigned short, unsigned int, unsigned long
+ ,short, int, long
+ ,boost::posix_time::ptime
+// ,boost::gregorian::date
+> discrete_types;
+
+typedef ::boost::mpl::list<
+ float, double
+ ,boost::rational<int>
+ ,std::string
+> continuous_types;
+
+typedef ::boost::mpl::list<
+ unsigned short, unsigned int, unsigned long
+ ,short, int, long
+ ,float, double
+ ,boost::rational<int>
+ ,std::string
+ ,boost::posix_time::ptime
+// ,boost::gregorian::date
+> ordered_types;
+
+#endif
+
Added: sandbox/itl/libs/itl/test/test_value_maker.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl/test/test_value_maker.hpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,32 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 2008-2008: Joachim Faulhaber
++-----------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++----------------------------------------------------------------------------*/
+#ifndef __itl_test_value_maker_JOFA_080916_H__
+#define __itl_test_value_maker_JOFA_080916_H__
+
+#include <boost/itl/type_traits/neutron.hpp>
+
+namespace boost{ namespace itl
+{
+template <class BicrementableT>
+BicrementableT make(int n)
+{
+ BicrementableT value = neutron<BicrementableT>::value();
+ if(n>=0)
+ for(int i=0; i<n; i++)
+ ++value;
+ else
+ for(int i=0; i>n; i--)
+ --value;
+
+ return value;
+}
+
+}} // namespace boost itl
+
+#endif
+
Added: sandbox/itl/libs/itl_xt/example/amount_cube/amount_cube.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/example/amount_cube/amount_cube.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,265 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+
+#include <limits>
+#include <boost/itl_xt/statvardesct.hpp>
+#include <boost/itl_xt/var_tuple_order.hpp>
+#include <boost/itl_xt/tuple_computer.hpp>
+
+#include <sstream>
+
+using namespace std;
+using namespace boost::itl;
+
+/** Example amount_cube.cpp \file amount_cube.cpp
+
+ The template class TupelComputerT is a general class for computing aggregations
+ on values that are associated to elements of a cartesian product. Stated more
+ simply TupelComputerT allows to count values associated to tupels.
+
+ Basically a TupelComputer is a map associating a tupel (t1, ..., tn) to a
+ value v:
+ (t1, ..., tn) -> v
+
+ The values v can be amounts like integers, but also sets, an more complex
+ classes, provided an operator += for aggregation is defined on them.
+
+ A TupelComputerT can be conceived as an n-dimensional cube.
+ Instances of TupelComputers can be found in many fields. General crosstable
+ prcedures in statistical systems, pivot tables in excel, online analytic
+ processing tools (OLAP-cubes) and functionalities of data warehouse systems
+ mirror an apply the concepts that TupelConputerT tries to offer as a c++
+ template class.
+
+ The most basic example of a TupelComputerT is the one that associates integers.
+ We call it AmountTupelComputer or AmountCube.
+
+ A TupelComputer counts on insert. That is, it applies the += operation on
+ associated values whenever the memberfunction 'insert' is called and an
+ appropriate tupel is in the cube.
+
+ An AmountTupelComputer counts frequencies of tupels if the inserted associated
+ value is always 1.
+
+ This is the most basic instance of a TupelComputerT. It is demonstrated in this
+ sampe file.
+
+ \include amount_cube/amount_cube.cpp
+*/
+
+/* Consider a hospital administration that want's to count their patients
+ according to the attributes sex, age, and diagnosis ... */
+enum sex { female=0, male=1 };
+enum diagnosis { anorexia=0, stroke=1 };
+
+// These are the components of the tupel (indendent variables) that are to
+// be counted ...
+enum PatientVarsET { sex, age, diagnosis, PatientVarsET_size };
+
+// ... which makes up tupels of 3 elements
+typedef var_tuple<PatientVarsET_size> PatientInfoTD;
+typedef amount_tuple_computer<PatientVarsET_size, int> AmountCubeTD;
+
+// This macro helps the notation a little
+#define TRIPEL(tp,x0,x1,x2) tp[0]=x0; tp[1]=x1; tp[2]=x2
+
+
+void evaluate_by_tupel_insertion(AmountCubeTD& cube)
+{
+ /* So, counting of cases is done just by inserting tupels of attributes with
+ an associated 1. Equal tupel are summed up. So we expect a total of
+ 2 for 17 year old annorectic females. All other tupels are obviously unique. */
+ PatientInfoTD marys_data; TRIPEL(marys_data, female, 17, anorexia); cube.insert(marys_data, 1);
+ PatientInfoTD sallys_data; TRIPEL(sallys_data, female, 17, anorexia); cube.insert(sallys_data, 1);
+ PatientInfoTD peters_data; TRIPEL(peters_data, male, 36, anorexia); cube.insert(peters_data, 1);
+ PatientInfoTD anns_data; TRIPEL(anns_data, female, 34, stroke); cube.insert(anns_data, 1);
+ PatientInfoTD pauls_data; TRIPEL(pauls_data, male, 72, stroke); cube.insert(pauls_data, 1);
+ PatientInfoTD franks_data; TRIPEL(franks_data, male, 82, stroke); cube.insert(franks_data, 1);
+}
+
+/* Shows frequencies of attribute tupels for patients. Sums up frequencies for
+ equal attribute combinations (tupels) */
+void accumulate_identical_tupel()
+{
+ /* Every TupelComputer need an order for their tupel. In the most simple case
+ we take the default order provided by the default constructor */
+ var_tuple_order<PatientInfoTD> defaultOrder;
+ AmountCubeTD amountCube(defaultOrder);
+
+ // Inserting an thus computing frquencies
+ evaluate_by_tupel_insertion(amountCube);
+ // Show result
+ cout << "accumulate_identical_tupel(): (female, 17, annorexia)->2 all other tupels->1" << endl;
+ cout << amountCube.as_string() << endl;
+ cout << "----------------------------------------------------------------------------" << endl;
+}
+
+
+/* We do not want to count each age separately but to evaluate frequencies
+ for groups of ages. So we define: */
+enum AgeGroupsET { young=0, old=1 };
+
+/* Modifying the tupel order we can indeed change the computation. Class
+ GroupByAge shows how a grouping on age can be introduced to the computing
+ of a TupelComputer. */
+class GroupByAge : public group_order<PatientVarsET_size>
+{
+public:
+ GroupByAge() : m_var(age) {}
+
+ /// Strict weak standard ordering for the grouped component.
+ bool operator() (const PatientInfoTD& lhs, const PatientInfoTD& rhs)const
+ { return ageGroup(lhs) < ageGroup(rhs); }
+
+ /// Get number of tupel component which is grouped
+ VarEnumTD getVarIndex()const { return m_var; }
+
+ /// Equivalence introduced by the grouping
+ bool areEquivalent(const PatientInfoTD& lhs, const PatientInfoTD& rhs)const
+ { return ageGroup(lhs) == ageGroup(rhs); }
+
+ /// That is the way we group ages (quite radical)
+ AgeGroupsET ageGroup(const PatientInfoTD& info)const {return info[age] <= 35 ? young : old; }
+
+private:
+ PatientVarsET m_var; // Tupel component which is grouped
+};
+
+
+
+void accumulate_for_grouped_age()
+{
+ // Now we can modify the tupel order
+ var_tuple_order<PatientInfoTD> groupedAgeOrder;
+
+ // Grouping for age is introduced that way
+ GroupByAge ageGrouper;
+ groupedAgeOrder.setGroupOrder(&ageGrouper);
+ AmountCubeTD amountCube(groupedAgeOrder);
+
+ /* The same data collection now yield a different result. As desired countig
+ of ages is now grouped for two rough age groups */
+ evaluate_by_tupel_insertion(amountCube);
+
+ cout << "accumulate_for_grouped_age():" << endl;
+ cout << "(fem,yng,anrx)->2 (fem,yng,strk)->1 (mle,old,anrx)->1 (mle,old,strk)->2" << endl;
+ cout << amountCube.as_string() << endl;
+ cout << "----------------------------------------------------------------------------" << endl;
+}
+
+/* We can compute partial sums by switching components off the tupel.
+ Components to be counted are defined by a PermutationT Object.
+ A PermutationT is a selection that permutes the iteration order as well. */
+void accumulate_for_sex()
+{
+ var_tuple_order<PatientInfoTD> groupedAgeOrder;
+
+ GroupByAge ageGrouper;
+ groupedAgeOrder.setGroupOrder(&ageGrouper);
+ var_permutation<PatientVarsET_size> perm;
+ // Count component 'sex' only
+ perm.add(sex);
+ groupedAgeOrder.setPermutation(perm);
+
+ AmountCubeTD amountCube(groupedAgeOrder);
+
+ evaluate_by_tupel_insertion(amountCube);
+
+ cout << "accumulate_for_sex(): (female,-,-)->3 (male,-,-)->3 " << endl;
+ cout << amountCube.as_string() << endl;
+ cout << "----------------------------------------------------------------------------" << endl;
+}
+
+void accumulate_except_for_sex()
+{
+ var_tuple_order<PatientInfoTD> groupedAgeOrder;
+
+ GroupByAge ageGrouper;
+ groupedAgeOrder.setGroupOrder(&ageGrouper);
+ var_permutation<PatientVarsET_size> perm;
+ // Count component age(grouped) and diagnosis but not sex
+ perm.add(age).add(diagnosis);
+ groupedAgeOrder.setPermutation(perm);
+
+ AmountCubeTD amountCube(groupedAgeOrder);
+
+ evaluate_by_tupel_insertion(amountCube);
+
+ cout << "accumulate_except_for_sex():" << endl;
+ cout << "(-,yng,anrx)->2 (-,yng,strk)->1 (-,old,anrx)->1 (-,old,strk)->2" << endl;
+ cout << amountCube.as_string() << endl;
+ cout << "----------------------------------------------------------------------------" << endl;
+}
+
+void accumulate_the_total()
+{
+ var_tuple_order<PatientInfoTD> groupedAgeOrder;
+
+ GroupByAge ageGrouper;
+ groupedAgeOrder.setGroupOrder(&ageGrouper);
+ var_permutation<PatientVarsET_size> perm;
+ // The empty PermutationT yields the grand total
+ groupedAgeOrder.setPermutation(perm);
+
+ AmountCubeTD amountCube(groupedAgeOrder);
+
+ evaluate_by_tupel_insertion(amountCube);
+
+ cout << "accumulate_the_total():(-,-,-)->6" << endl;
+ cout << amountCube.as_string() << endl;
+ cout << "----------------------------------------------------------------------------" << endl;
+}
+
+
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample amount_cube.cpp <<\n";
+ cout << "-------------------------------------------------------\n";
+ cout << "Note that there is always a representing value for a tupel component\n";
+ cout << "even if the component is grouped or switched off.\n";
+ cout << "-------------------------------------------------------\n";
+ accumulate_identical_tupel();
+ accumulate_for_grouped_age();
+ accumulate_for_sex();
+ accumulate_except_for_sex();
+ accumulate_the_total();
+ return 0;
+}
+
+// Program output
+
+// >> Interval Template Library: Sample amount_cube.cpp <<
+// -------------------------------------------------------
+// Note that there is always a representing value for a tupel component
+// even if the component is grouped or switched off.
+// -------------------------------------------------------
+// accumulate_identical_tupel(): (female, 17, annorexia)->2 all other tupels->1
+// ((0,17,0)->2)((0,34,1)->1)((1,36,0)->1)((1,72,1)->1)((1,82,1)->1)
+// ----------------------------------------------------------------------------
+// accumulate_for_grouped_age():
+// (fem,yng,anrx)->2 (fem,yng,strk)->1 (mle,old,anrx)->1 (mle,old,strk)->2
+// ((0,17,0)->2)((0,34,1)->1)((1,36,0)->1)((1,72,1)->2)
+// ----------------------------------------------------------------------------
+// accumulate_for_sex(): (female,-,-)->3 (male,-,-)->3
+// ((0,17,0)->3)((1,36,0)->3)
+// ----------------------------------------------------------------------------
+// accumulate_except_for_sex():
+// (-,yng,anrx)->2 (-,yng,strk)->1 (-,old,anrx)->1 (-,old,strk)->2
+// ((0,17,0)->2)((0,34,1)->1)((1,36,0)->1)((1,72,1)->2)
+// ----------------------------------------------------------------------------
+// accumulate_the_total():(-,-,-)->6
+// ((0,17,0)->6)
+// ----------------------------------------------------------------------------
+
+
Added: sandbox/itl/libs/itl_xt/example/amount_cube/vc9_amount_cube.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/example/amount_cube/vc9_amount_cube.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_amount_cube"
+ ProjectGUID="{5B6AE5B3-FAF3-4D98-A6F9-C8889C62A0E5}"
+ RootNamespace="vc9_amount_cube"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/$(ProjectName)/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\amount_cube.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl_xt/example/history/history.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/example/history/history.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,241 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+ 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)
++----------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <iostream>
+#include <boost/itl/type_traits/to_string.hpp>
+#include <boost/itl/split_interval_map.hpp>
+#include "../toytime.h"
+
+using namespace std;
+using namespace boost::itl;
+
+/** Example history.cpp \file history.cpp
+
+History demonstrates further possibilities of an interval map
+(interval_map or split_interval_map). For a more basic example see party.cpp.
+
+Here we show the mechanics of a product_history which is split_interval_map that
+maps intervals to products of attributes that change over time.
+
+Using product_histories, we can monitor a set of attributes in a history:
+
+Monday 22:00: A person is taken to a hospital with a head injury. So a suspicion
+of cranial fraction is filed.
+
+Monday 22:05: In a first examination at the emergency ward an alcoholic
+intoxication is diagnosed.
+
+Monday 22:15: The person is moved to the radiology to examine the headinjury.
+There he has to wait for 15 minutes in the hall.
+
+Monday 22:30: Using x-ray, cranial fraction can be excluded.
+
+Monday 22:50: The person is moved to ward A for treatment. The head injury is
+finally diagnosed as laceration.
+
+Tuesday 07:00: The person falls into an acute delirium due to deprivation of
+alcohol.
+
+This history of events could be formalized like that:
+\code
+[mon:22:00, mon:22:05) -> { DIAG->{susp.cran.frac.}, WARD->{emergency ward} }
+[mon:22:05, mon:22:15) -> { DIAG->{susp.cran.frac., alc.intox.}, WARD->{emergency ward} }
+[mon:22:15, mon:22:30) -> { DIAG->{susp.cran.frac., alc.intox.} }
+[mon:22:30, mon:22:50) -> { DIAG->{alc.intox.}, WARD->{radiology} }
+[mon:22:50, tue:07:00) -> { DIAG->{laceration, alc.intox.}, WARD->{ward A} }
+[tue:07:00, tue:07:20) -> { DIAG->{laceration, acute delirium}, WARD->{ward A} }
+\endcode
+
+Now suppose the episodes of that history are recorded separately for diagnoses and
+ward. A situation that is often found if data are stored in a well designed database.
+
+\code
+Diagnosis:
+[mon:22:00, mon:22:30) -> susp.cran.frac.
+[mon:22:05, mon:07:00) -> alc.intox.
+[mon:22:50, mon:07:20) -> laceration
+[mon:07:00, mon:07:20) -> acute delirium
+
+Stays:
+[mon:22:00, mon:22:15) -> emergency ward
+(unregistered gap)
+[mon:22:30, mon:22:50) -> radiology
+[mon:22:50, mon:07:20) -> ward A
+\endcode
+
+A product_history allows to compute the history of events by simply adding all
+separate episode data to a history object.
+
+\include history/history.cpp
+*/
+
+
+
+#include <boost/itl_xt/typed_episode.hpp>
+#include <boost/itl_xt/episode_product.hpp>
+#include <boost/itl_xt/product_history.hpp>
+
+
+/* To use a product_history object, we need an TypeDomain-class, specifying
+ an enumeration type and a common value type for all episodes of a given
+ problem domain to work on.
+*/
+class HospitalTypeDomain
+{
+public:
+ /* All episode classes for the hospital sample share a common value type ValueBaseTD
+ which is std::string in this toy example. Use any class of your problem domain
+ for real word instances. */
+ typedef std::string ValueBaseTD ;
+
+ // For derived episode classes, we define an enumeration
+ enum domainET { diagnosis, ward };
+ typedef enum domainET DomainET;
+
+ // string representation of the episode types
+ static std::string as_string(DomainET val)
+ {
+ switch(val)
+ {
+ case diagnosis: return std::string("DIAG");
+ case ward: return std::string("WARD");
+ default: return std::string("Unknown");
+ }
+ }
+};
+
+
+/* Base class for all episodes of the sample hospital problem domain.
+ An episode is an object that has an interval and a value. */
+class HospitalEpisodes : public typed_episode<Time, HospitalTypeDomain>
+{
+public:
+ // The domain type of intervals used by HospitalEpisodes is (toy)Time
+ typedef Time ItvDomTD;
+ // Type of the intervals used by HospitalEpisodes
+ typedef boost::itl::interval<Time> IntervalTD;
+
+public:
+ // Construct an episode from interval and value
+ HospitalEpisodes(const IntervalTD& itv, const std::string& val):
+ m_itv(itv), m_value(val)
+ {}
+
+ // Every episode has an interval
+ virtual IntervalTD interval()const { return m_itv; }
+
+ void setValue(const HospitalTypeDomain::ValueBaseTD& val) { m_value = val; }
+
+ virtual const HospitalTypeDomain::ValueBaseTD* value()const { return &m_value; }
+
+ // Equality of values
+ virtual bool isValueEqual(const ordered_type<HospitalTypeDomain>* x2)const
+ { return m_value==dynamic_cast<const HospitalEpisodes*>(x2)->m_value; }
+
+ // String representation
+ virtual std::string as_string()const { return m_value; }
+
+private:
+ // For sake of simplicity the value of the example episodes is text
+ HospitalTypeDomain::ValueBaseTD m_value;
+ IntervalTD m_itv;
+};
+
+// ----------------------------------------------------------------------------
+// Now specific episode-classes for diagnoses and wards are implemented
+// ----------------------------------------------------------------------------
+
+// Diagnoses: Begin, end and kind of desease
+class DiagnosisEpisode : public HospitalEpisodes
+{
+public:
+ DiagnosisEpisode(Time begin, Time end, const std::string& val)
+ : HospitalEpisodes(rightopen_interval(begin,end),val){}
+
+ HospitalTypeDomain::DomainET type()const { return HospitalTypeDomain::diagnosis; }
+};
+
+// Wards: Begin, end and Number of Ward a patient stayed at
+class WardEpisode : public HospitalEpisodes
+{
+public:
+ WardEpisode(Time begin, Time end, const std::string& val)
+ : HospitalEpisodes(rightopen_interval(begin,end),val){}
+
+ HospitalTypeDomain::DomainET type()const { return HospitalTypeDomain::ward; }
+};
+
+// ----------------------------------------------------------------------------
+/* Having defined hospital episodes, we can build a history class for
+ by instatiation of the product_history template class. */
+class HospitalProductHistory : public product_history<Time, HospitalTypeDomain>
+{
+public:
+ typedef product_history<Time, HospitalTypeDomain> BaseTypeTD;
+ typedef episode_product<Time, HospitalTypeDomain> ValueTypeTD;
+ typedef BaseTypeTD::IntervalTD IntervalTD;
+ typedef BaseTypeTD::DomainTD DomainTD;
+};
+
+// We may call a single entry in that history a hospital event.
+typedef HospitalProductHistory::ValueTypeTD HospitalEventTD;
+
+void medical_file()
+{
+ DiagnosisEpisode susp_cran_frac(Time(monday, 22,00), Time(monday, 22,30), "susp.cran.frac.");
+ DiagnosisEpisode alc_intox (Time(monday, 22,05), Time(tuesday, 7,00), "alc.intox.");
+ DiagnosisEpisode laceration (Time(monday, 22,50), Time(tuesday, 7,20), "laceration");
+ DiagnosisEpisode acute_delirium(Time(tuesday, 7,00), Time(tuesday, 7,20), "acute_delirium");
+
+ WardEpisode emergency_ward(Time(monday, 22,00), Time(monday, 22,15), "emergency_ward");
+ WardEpisode radiology (Time(monday, 22,30), Time(monday, 22,50), "radiology");
+ WardEpisode ward_A (Time(monday, 22,50), Time(tuesday, 7,20), "ward_A");
+
+ HospitalProductHistory history;
+
+ history += &susp_cran_frac;
+ history += &alc_intox;
+ history += &laceration;
+ history += ´_delirium;
+
+ history += &emergency_ward;
+ history += &radiology;
+ history += &ward_A;
+
+ HospitalProductHistory::iterator it = history.begin();
+ while(it != history.end())
+ {
+ interval<Time> when = (*it).first;
+ HospitalEventTD what = (*it).second;
+
+ cout << when.as_string() << ": " << what.as_string() << endl;
+ ++it;
+ }
+}
+
+int main()
+{
+ cout << ">> Interval Template Library: Sample history.cpp <<\n";
+ cout << "---------------------------------------------------\n";
+ medical_file();
+ return 0;
+}
+
+// Program output:
+
+// >> Interval Template Library: Sample history.cpp <<
+// ---------------------------------------------------
+// [mon:22:00,mon:22:05): DIAG{susp.cran.frac.}, WARD{emergency_ward}
+// [mon:22:05,mon:22:15): DIAG{alc.intox. susp.cran.frac.}, WARD{emergency_ward}
+// [mon:22:15,mon:22:30): DIAG{alc.intox. susp.cran.frac.}
+// [mon:22:30,mon:22:50): DIAG{alc.intox.}, WARD{radiology}
+// [mon:22:50,tue:07:00): DIAG{laceration alc.intox.}, WARD{ward_A}
+// [tue:07:00,tue:07:20): DIAG{acute_delirium laceration}, WARD{ward_A}
Added: sandbox/itl/libs/itl_xt/example/history/vc9_history.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/example/history/vc9_history.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_history"
+ ProjectGUID="{DD506ECC-2DE5-4C26-B810-B85A61BAA7EC}"
+ RootNamespace="vc9_history"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release/"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release/"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\history.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl_xt/example/toytime.h
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/example/toytime.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,75 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+namespace boost{namespace itl
+{
+
+/** Time is a toy-class to demonstrate a class that conforms the requirements of
+ a template parameter for class IntervalT.
+
+ In real world applications you may want to use the integer representation of a
+ time variable. That way intervals and their containers are working most efficiently.
+*/
+
+enum {sunday=0, monday, tuesday, wednesday, thursday, friday, saturday};
+static const char* daynames[] = {"sun", "mon", "tue", "wed", "thu", "fri", "sat"};
+
+class Time
+{
+public:
+ Time(): m_time(0) {}
+ Time(int hours, int minutes): m_time(60*hours+minutes) {}
+ Time(int day, int hours, int minutes): m_time((24*60)*day+60*hours+minutes) {}
+ int getDay()const { return m_time/(24*60); }
+ int getHours()const { return (m_time%(24*60))/60; }
+ int getMinutes()const { return (m_time%(24*60))%60; }
+ int asInt()const { return m_time; }
+ std::string getDayString()const { return daynames[getDay()]; }
+
+ std::string as_string()const
+ {
+ const int MAX_TIMESTING_LEN = 256;
+ char repr[MAX_TIMESTING_LEN];
+ sprintf(repr, "%3s:%02d:%02d", getDayString().c_str(), getHours(), getMinutes());
+ return std::string(repr);
+ }
+
+ Time& operator ++ () { m_time++; return *this; }
+ Time& operator -- () { m_time--; return *this; }
+
+private:
+ int m_time;
+};
+
+
+bool operator < (const Time& x1, const Time& x2) { return x1.asInt() < x2.asInt(); }
+bool operator == (const Time& x1, const Time& x2) { return x1.asInt() == x2.asInt(); }
+bool operator <= (const Time& x1, const Time& x2) { return x1.asInt() <= x2.asInt(); }
+
+}} // namespace itl boost
+
Added: sandbox/itl/libs/itl_xt/test/auto_itv_test/auto_itv_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/test/auto_itv_test/auto_itv_test.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,162 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------+
+auto_itv_test.cpp provides automated tests:
+A geneator generates instances of interval container. For each instance
+properties are checked, e. g. symmetric difference on ItvSets:
+(x + y) - (x * y) == (x - y) + (y - x)
+As you can see, within a law like that a great deal of operations are
+applied and tested.
+
+The test procedures allow for specifying the number of tests to be performed
+and the maximum size of generated interval containers. The error file collects
+information on the erroneous testcases if there are any.
++----------------------------------------------------------------------------*/
+#include <iostream>
+
+#include <boost/itl/split_interval_set.hpp>
+#include <boost/itl/split_interval_map.hpp>
+#include "../itvmaptester.h"
+#include "../itvsettester.h"
+
+using namespace std;
+using namespace boost::itl;
+
+// -------------------------------------------------
+void autoPropertyTest_ItvSet_int()
+{
+ try
+ {
+ int nTries=0, maxSamSize=0;
+ char errFile[256];
+
+ cout << "Property test for interval_set<int>: " << endl;
+ cout << "how many ? >> ";
+ cin >> nTries;
+ cout << "max sample ? >> ";
+ cin >> maxSamSize;
+ cout << "errfile ? >> ";
+ cin >> errFile ;
+
+ typedef ItvSetTesterT< interval_set<int> > TesterT;
+ TesterT::domain_generator_type* domain_gentor
+ = new TesterT::domain_generator_type();
+ domain_gentor->setValueRange(0, 100);
+ domain_gentor->setMaxIntervalLength(50);
+
+ TesterT cntTester;
+ cntTester.set_domain_generator(domain_gentor);
+ cntTester.setRangeOfSampleSize(0, maxSamSize);
+
+ cntTester.testInsertionIndependence(nTries);
+ cntTester.testJoinIndependence(nTries);
+ cntTester.testInsertReversibility(nTries, errFile);
+ cntTester.testSymmetricDifference(nTries, errFile);
+
+ cout << ">> auto tests completed\n";
+ }
+ catch (exception e)
+ {
+ cout << "autoPropertyTest_ItvSet_int(): exception caught\n";
+ cout << e.what() << endl;
+ }
+ catch (...)
+ {
+ cout << "autoPropertyTest_ItvSet_int(): unknown exception caught\n";
+ }
+}
+
+// -------------------------------------------------
+void autoPropertyTest_SplitItvMap_double_int()
+{
+ try
+ {
+ int nTries=0, maxSamSize=0;
+ char errFile[256];
+
+ cout << "Property test for split_interval_map<double,int>: " << endl;
+ cout << "how many ? >> ";
+ cin >> nTries;
+ cout << "max sample ? >> ";
+ cin >> maxSamSize;
+ cout << "errfile ? >> ";
+ cin >> errFile ;
+
+
+ typedef ItvMapTesterT< split_interval_map<double,int> > TesterT;
+ TesterT::domain_generator_type* domain_gentor
+ = new TesterT::domain_generator_type();
+ TesterT::codomain_generator_type* codomain_gentor
+ = new TesterT::codomain_generator_type();
+
+
+ domain_gentor->setValueRange(0.0, 1.0);
+ domain_gentor->setMaxIntervalLength(1.0);
+ codomain_gentor->setRange(1,5);
+
+ TesterT cntTester;
+ cntTester.set_domain_generator(domain_gentor);
+ cntTester.set_codomain_generator(codomain_gentor);
+
+ cntTester.setRangeOfSampleSize(0, maxSamSize);
+
+ cntTester.testInsertReversibility2(nTries, errFile);
+ cntTester.testErasureAsIntersectionComputability(nTries, errFile);
+
+ cout << ">> auto tests completed\n";
+ }
+ catch (exception e)
+ {
+ printf("autoPropertyTest_SplitItvMap_double_int(): exception caught\n");
+ printf("%s\n", e.what());
+ }
+ catch (...)
+ {
+ printf("autoPropertyTest_SplitItvMap_double_int(): unknown exception caught\n");
+ }
+}
+
+
+
+int main()
+{
+ // Select a test by (re)moving the comment tokens!
+
+ cout << ">> Interval Template Library: Test auto_itv_test.cpp <<\n";
+ cout << "-------------------------------------------------------\n";
+ // Test programmed properties on a sample of generated interval_set<int>
+ //autoPropertyTest_ItvSet_int();
+ autoPropertyTest_SplitItvMap_double_int();
+
+ // Test programmed properties on a sample of generated split_interval_map<double,int>
+ // autoPropertyTest_SplitItvMap_double_int();
+
+ return 0;
+}
+
Added: sandbox/itl/libs/itl_xt/test/auto_itv_test/vc9_auto_itv_test.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/test/auto_itv_test/vc9_auto_itv_test.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,238 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_auto_itv_test"
+ ProjectGUID="{EF64A2C7-DE78-46C2-953F-C4685A5D2A97}"
+ RootNamespace="auto_itv_test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0; ../../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/debug/$(ProjectName).exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../../../bin/release/$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\auto_itv_test.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\src\itl\interval_base_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\interval_base_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\interval_set.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\interval.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\itvmaptester.h"
+ >
+ </File>
+ <File
+ RelativePath="..\itvsettester.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\split_interval_map.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\itl\split_interval_set.hpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/itl_xt/test/itvmaptester.h
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/test/itvmaptester.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,553 @@
+/* ------------------------------------------------------------------
+class ItvMapTesterT
+--------------------------------------------------------------------*/
+#ifndef __ITVMAPTESTER_H_JOFA_990226__
+#define __ITVMAPTESTER_H_JOFA_990226__
+
+#include <boost/itl_xt/itvgentor.hpp>
+#include <boost/itl_xt/mapgentor.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class ItvMapTV>
+class ItvMapTesterT
+{
+public:
+ typedef typename ItvMapTV::domain_type domain_type;
+ typedef typename ItvMapTV::codomain_type codomain_type;
+ typedef typename ItvMapTV::interval_set_type interval_set_type;
+ typedef ItvGentorT<domain_type> domain_generator_type;
+ typedef NumberGentorT<codomain_type> codomain_generator_type;
+
+ void set_domain_generator(domain_generator_type* gentor)
+ { m_ContainerGentor.setDomainGentor(gentor); }
+
+ void set_codomain_generator(codomain_generator_type* gentor)
+ { m_ContainerGentor.setCodomainGentor(gentor); }
+
+ void setRangeOfSampleSize(int lwb, int upb)
+ { m_ContainerGentor.setRangeOfSampleSize(lwb,upb); }
+
+ // The value of a Map is independent of the insertion sequence
+ bool valueIsInsertionIndependent(ItvMapTV& y, ItvMapTV& y_perm);
+ bool testInsertionIndependence(int nTries);
+
+ // The value of a Map is invariant wrt. join-normalization
+ bool valueIsJoinIndependent(ItvMapTV& y, ItvMapTV& y_join);
+ bool testJoinIndependence(int nTries);
+
+ // The value of a Map is invariant wrt. join-normalization after insert-permutation
+ bool valueIsInsertAndJoinIndependent(ItvMapTV& y, ItvMapTV& y_perm, ItvMapTV& y_permJoin);
+ bool testInsertAndJoinIndependence(int nTries);
+
+ //LAW: x + y - join(perm(y)) == x;
+ bool isInsertReversible1
+ (ItvMapTV& x, ItvMapTV& y, ItvMapTV& y_perm, ItvMapTV& y_permJoin,
+ ItvMapTV& x_plus_y, ItvMapTV& x2);
+ bool testInsertReversibility1(int nTries, char* errFile);
+
+ void debugInsertReversibility1(const ItvMapTV& x, const ItvMapTV& y, const ItvMapTV y_perm);
+
+ //LAW: x + join(perm(y)) - y == x;
+ bool isInsertReversible2
+ (ItvMapTV& x, ItvMapTV& y, ItvMapTV& y_perm, ItvMapTV& y_permJoin,
+ ItvMapTV& x_plus_y_pj, ItvMapTV& x2);
+ bool testInsertReversibility2(int nTries, char* errFile);
+
+ void debugInsertReversibility2(const ItvMapTV& x, const ItvMapTV& y, const ItvMapTV y_perm);
+
+ //LAW: x -~ y == x * (dom(x) - y)
+ // operator -~ steht fuer erase
+ // x.erase(y) hat das gleiche Ergebnis wie der Schnitt von x mit x.domain() - y
+ bool hasErasureAsIntersectionComputability(ItvMapTV& x, interval_set_type& y,
+ interval_set_type& xDom_minus_y, ItvMapTV& x_resid, ItvMapTV& x_sect);
+
+ bool testErasureAsIntersectionComputability(int nTries, char* errFile);
+
+private:
+ MapGentorT<ItvMapTV> m_ContainerGentor;
+};
+
+
+// ----------------------------------------------------------------------------
+// LAW: InsertionIndependency<ItvMapTV>
+// LAW: x == perm(x)
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::valueIsInsertionIndependent(ItvMapTV& y, ItvMapTV& y_perm)
+{
+ ItvMapTV x, x_perm;
+ m_ContainerGentor.some(x);
+ m_ContainerGentor.last_permuted(x_perm);
+
+ if(! x.isEqual(x_perm) ) {
+ y = x; y_perm = x_perm;
+ return false;
+ }
+ else return true;
+}
+
+
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::testInsertionIndependence(int nTries)
+{
+ bool correct=true;
+ ItvMapTV y, y_perm;
+ ItvMapTV min_y, min_y_perm;
+
+ for(int i=0; i<nTries; i++)
+ if(!valueIsInsertionIndependent(y, y_perm))
+ {
+ if(true==correct) { min_y = y; min_y_perm = y_perm; correct=false; }
+ else if( y.interval_count() < min_y.interval_count() ) {
+ min_y = y; min_y_perm = y_perm;
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertionIndependence violated" << std::endl;
+ }
+
+ return correct;
+}
+
+
+// ----------------------------------------------------------------------------
+// LAW: JoinIndependency<ItvMapTV>
+// LAW: x == join(x)
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::valueIsJoinIndependent(ItvMapTV& y, ItvMapTV& y_join)
+{
+ ItvMapTV x, x_perm, x_join;
+ m_ContainerGentor.some(x);
+ x_join = x;
+ x_join.join();
+
+ if(! x.isEqual(x_join) ) { y = x; y_join = x_join; return false; }
+ else return true;
+}
+
+
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::testJoinIndependence(int nTries)
+{
+ bool correct=true;
+ ItvMapTV y, y_join;
+ ItvMapTV min_y, min_y_join;
+
+ for(int i=0; i<nTries; i++)
+ if(!valueIsJoinIndependent(y, y_join))
+ {
+ if(true==correct) {
+ min_y = y; min_y_join = y_join;
+ correct=false;
+ std::cout << "y.sz=" << y.interval_count() << " try=" << i << std::endl;
+ }
+ else if( y.interval_count() < min_y.interval_count() ) {
+ min_y = y; min_y_join = y_join;
+ std::cout << "y.sz=" << y.interval_count() << " try=" << i << std::endl;
+ }
+ }
+
+ if(!correct) {
+ std::cout << "JoinIndependence violated ---------------------------" << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_join:" << min_y_join.as_string().c_str() << std::endl;
+ }
+
+ return correct;
+}
+
+// ----------------------------------------------------------------------------
+// LAW: InsertAndJoinIndependency<IntSetTV>
+// LAW: x == join(perm(x))
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::valueIsInsertAndJoinIndependent(ItvMapTV& y, ItvMapTV& y_perm, ItvMapTV& y_permJoin)
+{
+ ItvMapTV x, x_perm, x_permJoin;
+ m_ContainerGentor.some(x);
+ m_ContainerGentor.last_permuted(x_perm);
+ x_permJoin = x_perm;
+ x_permJoin.join();
+
+ if(! x.isEqual(x_permJoin) ) {
+ y = x; y_perm = x_perm; y_permJoin = x_permJoin;
+ return false;
+ }
+ else return true;
+}
+
+
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::testInsertAndJoinIndependence(int nTries)
+{
+ bool correct=true;
+ ItvMapTV y, y_perm, y_permJoin;
+ ItvMapTV min_y, min_y_perm, min_y_permJoin;
+
+ for(int i=0; i<nTries; i++)
+ {
+ if(!valueIsInsertAndJoinIndependent(y, y_perm, y_permJoin))
+ {
+ if(true==correct) {
+ min_y = y; min_y_perm = y_perm; min_y_permJoin = y_permJoin;
+ correct=false;
+ std::cout << "y.sz=" << y.interval_count() << " try=" << i << std::endl;
+ }
+ else if( y.interval_count() < min_y.interval_count() ) {
+ min_y = y; min_y_perm = y_perm; min_y_permJoin = y_permJoin;
+ std::cout << "y.sz=" << y.interval_count() << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertAndJoinIndependence violated ---------------------------" << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pjoin:" << min_y_permJoin.as_string().c_str() << std::endl;
+ }
+
+ return correct;
+}
+
+
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::isInsertReversible1
+(
+ ItvMapTV& x, ItvMapTV& y,
+ ItvMapTV& y_perm, ItvMapTV& y_permJoin,
+ ItvMapTV& x_plus_y, ItvMapTV& x2
+)
+{
+ // x + y - join(perm(y)) == x;
+
+ ItvMapTV xx, yy, yy_perm, yy_permJoin, xx_plus_yy, xx2;
+
+ m_ContainerGentor.some(xx);
+ m_ContainerGentor.some(yy);
+ m_ContainerGentor.last_permuted(yy_perm);
+ yy_permJoin = yy_perm;
+ yy_permJoin.join();
+
+ xx2 = xx;
+ xx2 += yy;
+ xx_plus_yy = xx2;
+ xx2 -= yy_permJoin;
+
+ if(! xx.isEqual(xx2) ) {
+ x = xx; y = yy; y_perm = yy_perm; y_permJoin = yy_permJoin;
+ x_plus_y = xx_plus_yy; x2 = xx2 ;
+ return false;
+ }
+ else return true;
+}
+
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::testInsertReversibility1(int nTries, char* errFile)
+{
+ // x + join(perm(y)) - y == x;
+
+ bool correct=true;
+ ItvMapTV x, y, y_perm, y_permJoin, x_plus_y, x2;
+ ItvMapTV min_x, min_y, min_y_perm, min_y_permJoin, min_x_plus_y, min_x2;
+ int caseSize, min_caseSize;
+
+ for(int i=0; i<nTries; i++)
+ {
+ if(!isInsertReversible1(x, y, y_perm, y_permJoin, x_plus_y, x2))
+ {
+ caseSize = x.interval_count() + y.interval_count();
+ if(true==correct) {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y = x_plus_y; min_x2 = x2;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << x.interval_count() << " y.sz=" << y.interval_count()
+ << " try=" << i << std::endl;
+ correct=false;
+ }
+ else if ( caseSize < min_caseSize )
+ {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y = x_plus_y; min_x2 = x2;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << x.interval_count() << " y.sz=" << y.interval_count()
+ << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertReversibility1: x + y - join(perm(y)) == x =: x2 violated --------" << std::endl;
+ std::cout << "x :" << min_x.as_string().c_str() << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pJnt :" << min_y_permJoin.as_string().c_str() << std::endl;
+ std::cout << "x+y :" << min_x_plus_y.as_string().c_str() << std::endl;
+ std::cout << "x2 :" << min_x2.as_string().c_str() << std::endl;
+
+ FILE* fp;
+ fp = fopen(errFile,"w");
+ fprintf(fp, "x: %s\n", min_x.as_string().c_str());
+ fprintf(fp, "y: %s\n", min_y.as_string().c_str());
+ fprintf(fp, "y_perm: %s\n", min_y_perm.as_string().c_str());
+ fprintf(fp, "y_pJnt: %s\n", min_y_permJoin.as_string().c_str());
+ fprintf(fp, "x+y: %s\n", min_x_plus_y.as_string().c_str());
+ fprintf(fp, "x2: %s\n", min_x2.as_string().c_str());
+
+ min_x.isEqual(min_x2);
+ debugInsertReversibility1(min_x, min_y, min_y_perm);
+ }
+ else
+ {
+ std::cout << "InsertReversibility1("<<nTries<<") OK "
+ << " x + y - join(perm(y)) == x =: x2" << std::endl;
+ }
+
+ return correct;
+}
+
+
+template <class ItvMapTV>
+void ItvMapTesterT<ItvMapTV>::debugInsertReversibility1
+ (const ItvMapTV& x, const ItvMapTV& y, const ItvMapTV y_perm)
+{
+ ItvMapTV x2 = x, y_pj = y_perm;
+ y_pj.join();
+
+ x2 += y_pj;
+ x2 -= y;
+}
+
+
+
+//-----------------------------------------------------------------------------
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::isInsertReversible2
+(
+ ItvMapTV& x, ItvMapTV& y,
+ ItvMapTV& y_perm, ItvMapTV& y_permJoin,
+ ItvMapTV& x_plus_y_pj, ItvMapTV& x2
+)
+{
+ // x + join(perm(y)) - y == x;
+
+ ItvMapTV xx, yy, yy_perm, yy_permJoin, xx_plus_yy_pj, xx2;
+
+ m_ContainerGentor.some(xx);
+ m_ContainerGentor.some(yy);
+ m_ContainerGentor.last_permuted(yy_perm);
+ yy_permJoin = yy_perm;
+ yy_permJoin.join();
+
+ xx2 = xx;
+ xx2 += yy_permJoin;
+ xx_plus_yy_pj = xx2;
+ xx2 -= yy;
+ xx2.join();
+
+ if(! is_element_equal(xx, xx2) ) {
+ x = xx; y = yy; y_perm = yy_perm; y_permJoin = yy_permJoin;
+ x_plus_y_pj = xx_plus_yy_pj; x2 = xx2 ;
+ return false;
+ }
+ else return true;
+}
+
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::testInsertReversibility2(int nTries, char* errFile)
+{
+ // x + join(perm(y)) - y == x;
+
+ bool correct=true;
+ ItvMapTV x, y, y_perm, y_permJoin, x_plus_y_pj, x2;
+ ItvMapTV min_x, min_y, min_y_perm, min_y_permJoin, min_x_plus_y_pj, min_x2;
+ size_t caseSize, min_caseSize;
+
+ for(int i=0; i<nTries; i++) {
+ if(!isInsertReversible2(x, y, y_perm, y_permJoin, x_plus_y_pj, x2))
+ {
+ caseSize = x.interval_count() + y.interval_count();
+ if(true==correct) {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y_pj = x_plus_y_pj;
+ min_x2 = x2;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ correct=false;
+ }
+ else if ( caseSize < min_caseSize )
+ {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y_pj = x_plus_y_pj; min_x2 = x2;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertReversibility2: (x + join(perm(y)) - y).join() == x =: x2 violated --------" << std::endl;
+ std::cout << "x :" << min_x.as_string().c_str() << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pJnt :" << min_y_permJoin.as_string().c_str() << std::endl;
+ std::cout << "x+y_pJnt:" << min_x_plus_y_pj.as_string().c_str() << std::endl;
+ std::cout << "x2 :" << min_x2.as_string().c_str() << std::endl;
+
+
+ FILE* fp;
+ fp = fopen(errFile,"w");
+ fprintf(fp, "x: %s\n", min_x.as_string().c_str());
+ fprintf(fp, "y: %s\n", min_y.as_string().c_str());
+ fprintf(fp, "y_perm: %s\n", min_y_perm.as_string().c_str());
+ fprintf(fp, "y_pJnt: %s\n", min_y_permJoin.as_string().c_str());
+ fprintf(fp, "x+y: %s\n", min_x_plus_y_pj.as_string().c_str());
+ fprintf(fp, "x2: %s\n", min_x2.as_string().c_str());
+
+ debugInsertReversibility2(min_x, min_y, min_y_perm);
+ }
+ else
+ {
+ std::cout << "InsertReversibility2("<<nTries<<") OK "
+ << " x + join(perm(y)) - y == x =: x2" << std::endl;
+ }
+
+ return correct;
+}
+
+
+template <class ItvMapTV>
+void ItvMapTesterT<ItvMapTV>::debugInsertReversibility2(const ItvMapTV& x, const ItvMapTV& y, const ItvMapTV y_perm)
+{
+ ItvMapTV x2 = x, y_pj = y_perm;
+ y_pj.join();
+
+ x2 += y_pj;
+ x2 -= y;
+}
+
+
+
+//LAW: x -~ y == x * (dom(x) - y)
+// operator -~ steht fuer erase
+// x.erase(y) hat das gleiche Ergebnis wie der Schnitt von x mit x.domain() - y
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::hasErasureAsIntersectionComputability(ItvMapTV& x, interval_set_type& y,
+ interval_set_type& xDom_minus_y, ItvMapTV& x_resid, ItvMapTV& x_sect)
+{
+ ItvMapTV xx, erasure, rhs;
+
+ m_ContainerGentor.some(xx);
+ m_ContainerGentor.some(erasure);
+
+ interval_set_type erasureDomain;
+ erasure.domain(erasureDomain);
+
+ ItvMapTV xxResid = xx;
+ xxResid -= erasureDomain;
+
+ interval_set_type xxDomain;
+ xx.domain(xxDomain);
+
+ interval_set_type erasureComplement;
+ erasureComplement = xxDomain;
+ erasureComplement -= erasureDomain;
+
+ ItvMapTV xxSect;
+ //xx.intersect(xxSect, erasureComplement);
+ xx.intersect(xxSect, erasureComplement);
+
+ if(! is_element_equal(xxResid, xxSect) ) {
+ x = xx; y = erasureDomain; xDom_minus_y = erasureComplement;
+ x_resid = xxResid; x_sect = xxSect;
+ return false;
+ }
+ else return true;
+}
+
+
+
+template <class ItvMapTV>
+bool ItvMapTesterT<ItvMapTV>::testErasureAsIntersectionComputability(int nTries, char* errFile)
+{
+ bool correct=true;
+ ItvMapTV x, x_resid, x_section;
+ interval_set_type y, xDom_minus_y;
+
+ ItvMapTV min_x, min_x_resid, min_x_section;
+ interval_set_type min_y, min_xDom_minus_y;
+
+ int caseSize, min_caseSize;
+
+ for(int i=0; i<nTries; i++) {
+ if(!hasErasureAsIntersectionComputability(x, y, xDom_minus_y, x_resid, x_section))
+ {
+ caseSize = static_cast<int>(x.interval_count() + y.interval_count());
+ if(true==correct) {
+ min_x = x; min_y = y;
+ min_xDom_minus_y = xDom_minus_y;
+ min_x_resid = x_resid; min_x_section = x_section;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ correct=false;
+ }
+ else if ( caseSize < min_caseSize )
+ {
+ min_x = x; min_y = y;
+ min_xDom_minus_y = xDom_minus_y;
+ min_x_resid = x_resid; min_x_section = x_section;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "ErasureAsIntersectionComputability: x -~ y == x * (dom(x)-y) violated --------" << std::endl;
+ std::cout << "x :" << min_x.as_string().c_str() << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+
+
+ FILE* fp;
+ fp = fopen(errFile,"w");
+ fprintf(fp, "x: %s\n", min_x.as_string().c_str());
+ fprintf(fp, "y: %s\n", min_y.as_string().c_str());
+
+ //debugInsertReversibility2(min_x, min_y, min_y_perm);
+ }
+ else
+ {
+ std::cout << "ErasureAsIntersectionComputability("<<nTries<<") OK "
+ << " x -~ y == x * (dom(x)-y)" << std::endl;
+ }
+
+ return correct;
+}
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/libs/itl_xt/test/itvsettester.h
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/itl_xt/test/itvsettester.h 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,618 @@
+/*----------------------------------------------------------------------------+
+Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
++-----------------------------------------------------------------------------+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
++----------------------------------------------------------------------------*/
+
+/* ------------------------------------------------------------------
+class ItvSetTesterT
+--------------------------------------------------------------------*/
+#ifndef __ITVSETTESTER_H_JOFA_990230__
+#define __ITVSETTESTER_H_JOFA_990230__
+
+#include <boost/itl_xt/setgentor.hpp>
+
+namespace boost{namespace itl
+{
+
+template <class ItvSetTV>
+class ItvSetTesterT
+{
+public:
+ typedef typename ItvSetTV::value_type value_type;
+ typedef typename ItvSetTV::domain_type domain_type;
+ typedef ItvGentorT<domain_type> domain_generator_type;
+
+ void set_domain_generator(domain_generator_type* gentor)
+ { m_ContainerGentor.setDomainGentor(gentor); }
+
+ //void setDomainRange(domain_type lwb, domain_type upb, domain_type itvLen)
+ //{ m_DomainGentor.setValueRange(lwb,upb); m_DomainGentor.setMaxIntervalLength(itvLen); }
+
+ void setRangeOfSampleSize(int lwb, int upb)
+ { m_ContainerGentor.setRangeOfSampleSize(lwb,upb); }
+
+ //void init() {
+ // m_ContainerGentor.setDomainGentor(&m_DomainGentor);
+ //}
+
+ // The value of a Set is independent of the insertion sequence
+ bool valueIsInsertionIndependent(ItvSetTV& y, ItvSetTV& y_perm);
+ bool testInsertionIndependence(int nTries);
+
+ // The value of a Map is invariant wrt. join-normalization
+ bool valueIsJoinIndependent(ItvSetTV& y, ItvSetTV& y_join);
+ bool testJoinIndependence(int nTries);
+
+ // The value of a Map is invariant wrt. join-normalization after insert-permutation
+ bool valueIsInsertAndJoinIndependent(ItvSetTV& y, ItvSetTV& y_perm, ItvSetTV& y_permJoin);
+ bool testInsertAndJoinIndependence(int nTries);
+
+ // x + y - join(perm(y)) == x - y;
+ bool isInsertReversible
+ (ItvSetTV& x, ItvSetTV& y, ItvSetTV& y_perm, ItvSetTV& y_permJoin,
+ ItvSetTV& x_plus_y, ItvSetTV& lhs, ItvSetTV& rhs);
+ bool testInsertReversibility(int nTries, char* errFile);
+
+ // x + y - join(perm(y)) == x;
+ bool isInsertReversible1
+ (ItvSetTV& x, ItvSetTV& y, ItvSetTV& y_perm, ItvSetTV& y_permJoin,
+ ItvSetTV& x_plus_y, ItvSetTV& x2);
+ bool testInsertReversibility1(int nTries, char* errFile);
+
+ void debugInsertReversibility1(const ItvSetTV& x, const ItvSetTV& y, const ItvSetTV y_perm);
+
+ /*
+ // x + join(perm(y)) - y == x;
+ bool isInsertReversible2
+ (ItvSetTV& x, ItvSetTV& y, ItvSetTV& y_perm, ItvSetTV& y_permJoin,
+ ItvSetTV& x_plus_y_pj, ItvSetTV& x2);
+ bool testInsertReversibility2(int nTries, char* errFile);
+
+ void debugInsertReversibility2(const ItvSetTV& x, const ItvSetTV& y, const ItvSetTV y_perm);
+ */
+
+ bool hasSymmetricDifference
+ ( ItvSetTV& x, ItvSetTV& y,
+ ItvSetTV& x_uni_y, ItvSetTV& x_sec_y,
+ ItvSetTV& x_sub_y, ItvSetTV& y_sub_x );
+
+ bool testSymmetricDifference(int nTries, char* errFile);
+
+
+private:
+ ItvGentorT<domain_type> m_DomainGentor;
+ SetGentorT<ItvSetTV> m_ContainerGentor;
+
+};
+
+
+// ----------------------------------------------------------------------------
+// LAW: InsertionIndependency<ItvSetTV>
+// LAW: x == perm(x)
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::valueIsInsertionIndependent(ItvSetTV& y, ItvSetTV& y_perm)
+{
+ ItvSetTV x, x_perm;
+ m_ContainerGentor.some(x);
+ m_ContainerGentor.last_permuted(x_perm);
+
+ if(!(x == x_perm) ) {
+ y = x; y_perm = x_perm;
+ return false;
+ }
+ else return true;
+}
+
+
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::testInsertionIndependence(int nTries)
+{
+ bool correct=true;
+ ItvSetTV y, y_perm;
+ ItvSetTV min_y, min_y_perm;
+
+ for(int i=0; i<nTries; i++)
+ if(!valueIsInsertionIndependent(y, y_perm))
+ {
+ if(true==correct) { min_y = y; min_y_perm = y_perm; correct=false; }
+ else if( y.interval_count() < min_y.interval_count() ) {
+ min_y = y; min_y_perm = y_perm;
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertionIndependence violated" << std::endl;
+ }
+
+ return correct;
+}
+
+
+// ----------------------------------------------------------------------------
+// LAW: JoinIndependency<ItvSetTV>
+// LAW: x == join(x)
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::valueIsJoinIndependent(ItvSetTV& y, ItvSetTV& y_join)
+{
+ ItvSetTV x, x_perm, x_join;
+ m_ContainerGentor.some(x);
+ x_join = x;
+ x_join.join();
+
+ if(!(x == x_join) ) { y = x; y_join = x_join; return false; }
+ else return true;
+}
+
+
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::testJoinIndependence(int nTries)
+{
+ bool correct=true;
+ ItvSetTV y, y_join;
+ ItvSetTV min_y, min_y_join;
+
+ for(int i=0; i<nTries; i++)
+ if(!valueIsJoinIndependent(y, y_join))
+ {
+ if(true==correct) {
+ min_y = y; min_y_join = y_join;
+ correct=false;
+ std::cout << "y.sz=" << static_cast<unsigned int>(y.interval_count()) << " try=" << i << std::endl;
+ }
+ else if( y.interval_count() < min_y.interval_count() ) {
+ min_y = y; min_y_join = y_join;
+ std::cout << "y.sz=" << static_cast<unsigned int>(y.interval_count()) << " try=" << i << std::endl;
+ }
+ }
+
+ if(!correct) {
+ std::cout << "JoinIndependence violated ---------------------------" << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_join:" << min_y_join.as_string().c_str() << std::endl;
+ }
+
+ return correct;
+}
+
+// ----------------------------------------------------------------------------
+// LAW: InsertAndJoinIndependency<IntSetTV>
+// LAW: x == join(perm(x))
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::valueIsInsertAndJoinIndependent(ItvSetTV& y, ItvSetTV& y_perm, ItvSetTV& y_permJoin)
+{
+ ItvSetTV x, x_perm, x_permJoin;
+ m_ContainerGentor.some(x);
+ m_ContainerGentor.last_permuted(x_perm);
+ x_permJoin = x_perm;
+ x_permJoin.join();
+
+ if(! x.isEqual(x_permJoin) ) {
+ y = x; y_perm = x_perm; y_permJoin = x_permJoin;
+ return false;
+ }
+ else return true;
+}
+
+
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::testInsertAndJoinIndependence(int nTries)
+{
+ bool correct=true;
+ ItvSetTV y, y_perm, y_permJoin;
+ ItvSetTV min_y, min_y_perm, min_y_permJoin;
+
+ for(int i=0; i<nTries; i++)
+ {
+ if(!valueIsInsertAndJoinIndependent(y, y_perm, y_permJoin))
+ {
+ if(true==correct) {
+ min_y = y; min_y_perm = y_perm; min_y_permJoin = y_permJoin;
+ correct=false;
+ std::cout << "y.sz=" << y.interval_count() << " try=" << i << std::endl;
+ }
+ else if( y.interval_count() < min_y.interval_count() ) {
+ min_y = y; min_y_perm = y_perm; min_y_permJoin = y_permJoin;
+ std::cout << "y.sz=" << y.interval_count() << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertAndJoinIndependence violated ---------------------------" << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pjoin:" << min_y_permJoin.as_string().c_str() << std::endl;
+ }
+
+ return correct;
+}
+
+
+
+
+// ----------------------------------------------------------------------------
+// LAW: InsertReversability<ItvSetTV>
+// LAW: x + y - perm(join(y)) = x - y
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::isInsertReversible
+(
+ ItvSetTV& x, ItvSetTV& y,
+ ItvSetTV& y_perm, ItvSetTV& y_permJoin,
+ ItvSetTV& x_plus_y, ItvSetTV& ls, ItvSetTV& rs
+)
+{
+ ItvSetTV xx, yy, yy_perm, yy_permJoin, xx_plus_yy, lhs, rhs;
+
+ m_ContainerGentor.some(xx);
+ m_ContainerGentor.some(yy);
+ m_ContainerGentor.last_permuted(yy_perm);
+ yy_permJoin = yy_perm;
+ yy_permJoin.join();
+
+ lhs = xx;
+ lhs += yy;
+ xx_plus_yy = lhs;
+ lhs -= yy_permJoin; // left hand side
+
+ rhs = xx;
+ rhs -= yy; // right hand side
+
+ if( !(lhs == rhs) ) {
+ x = xx; y = yy; y_perm = yy_perm; y_permJoin = yy_permJoin;
+ x_plus_y = xx_plus_yy; ls = lhs ; rs = rhs;
+ return false;
+ }
+ else return true;
+}
+
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::testInsertReversibility(int nTries, char* errFile)
+{
+ bool correct=true;
+ ItvSetTV x, y, y_perm, y_permJoin, x_plus_y, lhs, rhs;
+ ItvSetTV min_x, min_y, min_y_perm, min_y_permJoin, min_x_plus_y, min_lhs, min_rhs;
+ int caseSize, min_caseSize;
+
+ for(int i=0; i<nTries; i++)
+ {
+ if(!isInsertReversible(x, y, y_perm, y_permJoin, x_plus_y, lhs, rhs))
+ {
+ caseSize = static_cast<unsigned int>(x.interval_count() + y.interval_count());
+ if(true==correct) {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y = x_plus_y;
+ min_lhs = lhs; min_rhs = rhs;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ correct=false;
+ }
+ else if ( caseSize < min_caseSize )
+ {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y = x_plus_y;
+ min_lhs = lhs; min_rhs = rhs;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertReversibility: x + y - join(perm(y)) == x - y violated --------" << std::endl;
+ std::cout << "x :" << min_x.as_string().c_str() << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pJnt :" << min_y_permJoin.as_string().c_str() << std::endl;
+ std::cout << "x+y :" << min_x_plus_y.as_string().c_str() << std::endl;
+ std::cout << "lhs :" << min_lhs.as_string().c_str() << std::endl;
+ std::cout << "rhs :" << min_rhs.as_string().c_str() << std::endl;
+
+ FILE* fp;
+ fp = fopen(errFile,"w");
+ //fopen_s(&fp,errFile,"w");
+ fprintf(fp, "x: %s\n", min_x.as_string().c_str());
+ fprintf(fp, "y: %s\n", min_y.as_string().c_str());
+ fprintf(fp, "y_perm: %s\n", min_y_perm.as_string().c_str());
+ fprintf(fp, "y_pJnt: %s\n", min_y_permJoin.as_string().c_str());
+ fprintf(fp, "x+y: %s\n", min_x_plus_y.as_string().c_str());
+ fprintf(fp, "lhs: %s\n", min_lhs.as_string().c_str());
+ fprintf(fp, "rhs: %s\n", min_rhs.as_string().c_str());
+
+ // min_lhs.isEqual(min_rhs);
+ // debugInsertReversibility1(min_x, min_y, min_y_perm);
+ }
+ else
+ {
+ std::cout << "InsertReversibility("<<nTries<<") OK "
+ << " x + y - join(perm(y)) == x - y" << std::endl;
+ }
+
+ return correct;
+}
+
+
+
+
+// ----------------------------------------------------------------------------
+// Modify testconditions. x + y - perm(join(y)) != x !!
+// only y - perm(join(y)) = {} can be tested
+
+// LAW: InsertReversability<ItvSetTV>
+// LAW: y - perm(join(y)) = {}
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::isInsertReversible1
+(
+ ItvSetTV& x, ItvSetTV& y,
+ ItvSetTV& y_perm, ItvSetTV& y_permJoin,
+ ItvSetTV& x_plus_y, ItvSetTV& x2
+)
+{
+ // x + y - join(perm(y)) == x;
+
+ ItvSetTV xx, yy, yy_perm, yy_permJoin, xx_plus_yy, xx2;
+
+ m_ContainerGentor.some(xx);
+ m_ContainerGentor.some(yy);
+ m_ContainerGentor.last_permuted(yy_perm);
+ yy_permJoin = yy_perm;
+ yy_permJoin.join();
+
+ xx2 = xx;
+ xx2 += yy;
+ xx_plus_yy = xx2;
+ xx2 -= yy_permJoin;
+
+ if(! xx.isEqual(xx2) ) {
+ x = xx; y = yy; y_perm = yy_perm; y_permJoin = yy_permJoin;
+ x_plus_y = xx_plus_yy; x2 = xx2 ;
+ return false;
+ }
+ else return true;
+}
+
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::testInsertReversibility1(int nTries, char* errFile)
+{
+ // x + join(perm(y)) - y == x;
+
+ bool correct=true;
+ ItvSetTV x, y, y_perm, y_permJoin, x_plus_y, x2;
+ ItvSetTV min_x, min_y, min_y_perm, min_y_permJoin, min_x_plus_y, min_x2;
+ int caseSize, min_caseSize;
+
+ for(int i=0; i<nTries; i++)
+ {
+ if(!isInsertReversible1(x, y, y_perm, y_permJoin, x_plus_y, x2))
+ {
+ caseSize = x.interval_count() + y.interval_count();
+ if(true==correct) {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y = x_plus_y; min_x2 = x2;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << x.interval_count() << " y.sz=" << y.interval_count()
+ << " try=" << i << std::endl;
+ correct=false;
+ }
+ else if ( caseSize < min_caseSize )
+ {
+ min_x = x; min_y = y; min_y_perm = y_perm;
+ min_y_permJoin = y_permJoin; min_x_plus_y = x_plus_y; min_x2 = x2;
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << x.interval_count() << " y.sz=" << y.interval_count()
+ << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "InsertReversibility1: x + y - join(perm(y)) == x =: x2 violated --------" << std::endl;
+ std::cout << "x :" << min_x.as_string().c_str() << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pJnt :" << min_y_permJoin.as_string().c_str() << std::endl;
+ std::cout << "x+y :" << min_x_plus_y.as_string().c_str() << std::endl;
+ std::cout << "x2 :" << min_x2.as_string().c_str() << std::endl;
+
+ FILE* fp;
+ fp = fopen(errFile,"w");
+ fprintf(fp, "x: %s\n", min_x.as_string().c_str());
+ fprintf(fp, "y: %s\n", min_y.as_string().c_str());
+ fprintf(fp, "y_perm: %s\n", min_y_perm.as_string().c_str());
+ fprintf(fp, "y_pJnt: %s\n", min_y_permJoin.as_string().c_str());
+ fprintf(fp, "x+y: %s\n", min_x_plus_y.as_string().c_str());
+ fprintf(fp, "x2: %s\n", min_x2.as_string().c_str());
+
+ min_x.isEqual(min_x2);
+ debugInsertReversibility1(min_x, min_y, min_y_perm);
+ }
+ else
+ {
+ std::cout << "InsertReversibility1("<<nTries<<") OK "
+ << " x + y - join(perm(y)) == x =: x2" << std::endl;
+ }
+
+ return correct;
+}
+
+
+template <class ItvSetTV>
+void ItvSetTesterT<ItvSetTV>::debugInsertReversibility1
+ (const ItvSetTV& x, const ItvSetTV& y, const ItvSetTV y_perm)
+{
+ ItvSetTV x2 = x, y_pj = y_perm;
+ y_pj.join();
+
+ x2 += y_pj;
+ x2 -= y;
+}
+
+
+
+
+// ------------------------------------------------------------------------------
+// Test symmetric difference:
+
+// LAW: SymmetricDifference<IntSetTV>
+// LAW: (x + y) - (x * y) == (x - y) + (y - x)
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::hasSymmetricDifference
+(
+ ItvSetTV& x, ItvSetTV& y,
+ ItvSetTV& x_uni_y, ItvSetTV& x_sec_y,
+ ItvSetTV& x_sub_y, ItvSetTV& y_sub_x
+)
+{
+ // (x + y) - (x * y) == (x - y) + (y - x)
+
+ ItvSetTV xx, yy, xx_uni_yy, xx_sec_yy, xx_sub_yy, yy_sub_xx, lhs, rhs;
+
+ m_ContainerGentor.some(xx);
+ m_ContainerGentor.some(yy);
+
+ // lefthand side -------------------
+ xx_uni_yy = xx;
+ xx_uni_yy += yy;
+
+ xx_sec_yy = xx;
+ xx_sec_yy *= yy;
+
+ lhs = xx_uni_yy;
+ lhs -= xx_sec_yy;
+
+ // right hand side -----------------
+ xx_sub_yy = xx;
+ xx_sub_yy -= yy;
+
+ yy_sub_xx = yy;
+ yy_sub_xx -= xx;
+
+ rhs = xx_sub_yy;
+ rhs += yy_sub_xx;
+ // ---------------------------------
+
+ if(! (lhs==rhs) ) {
+ x = xx; y = yy; x_uni_y = xx_uni_yy; x_sec_y = xx_sec_yy;
+ x_sub_y = xx_sub_yy; y_sub_x = yy_sub_xx ;
+ return false;
+ }
+ else return true;
+}
+
+
+template <class ItvSetTV>
+bool ItvSetTesterT<ItvSetTV>::testSymmetricDifference(int nTries, char* errFile)
+{
+ // (x + y) - (x * y) == (x - y) + (y - x)
+
+ bool correct=true;
+ ItvSetTV x, y, x_uni_y, x_sec_y, x_sub_y, y_sub_x;
+ ItvSetTV min_x, min_y, min_x_uni_y, min_x_sec_y, min_x_sub_y, min_y_sub_x;
+
+ int caseSize, min_caseSize;
+
+ for(int i=0; i<nTries; i++)
+ {
+ if(!hasSymmetricDifference(x, y, x_uni_y, x_sec_y, x_sub_y, y_sub_x))
+ {
+ // collect results to find the smallest invalid case
+ caseSize = static_cast<unsigned int>(x.interval_count() + y.interval_count());
+ if(true==correct) {
+ min_x = x; min_y = y;
+ /*
+ more results
+ */
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ correct=false;
+ }
+ else if ( caseSize < min_caseSize )
+ {
+ min_x = x; min_y = y;
+ /*
+ more results
+ */
+ min_caseSize = caseSize;
+ std::cout << "x.sz=" << static_cast<unsigned int>(x.interval_count())
+ << " y.sz=" << static_cast<unsigned int>(y.interval_count())
+ << " try=" << i << std::endl;
+ }
+ }
+ }
+
+ if(!correct) {
+ std::cout << "SymmetricDifference: (x + y) - (x * y) == (x - y) + (y - x) violated --------" << std::endl;
+ std::cout << "x :" << min_x.as_string().c_str() << std::endl;
+ std::cout << "y :" << min_y.as_string().c_str() << std::endl;
+ /*
+ std::cout << "y_perm :" << min_y_perm.as_string().c_str() << std::endl;
+ std::cout << "y_pJnt :" << min_y_permJoin.as_string().c_str() << std::endl;
+ std::cout << "x+y :" << min_x_plus_y.as_string().c_str() << std::endl;
+ std::cout << "x2 :" << min_x2.as_string().c_str() << std::endl;
+ */
+
+ FILE* fp;
+ fp = fopen(errFile,"w");
+ //fopen_s(&fp,errFile,"w");
+ fprintf(fp, "x: %s\n", min_x.as_string().c_str());
+ fprintf(fp, "y: %s\n", min_y.as_string().c_str());
+ /*
+ fprintf(fp, "y_perm: %s\n", min_y_perm.as_string().c_str());
+ fprintf(fp, "y_pJnt: %s\n", min_y_permJoin.as_string().c_str());
+ fprintf(fp, "x+y: %s\n", min_x_plus_y.as_string().c_str());
+ fprintf(fp, "x2: %s\n", min_x2.as_string().c_str());
+
+ min_x.isEqual(min_x2);
+ debugInsertReversibility1(min_x, min_y, min_y_perm);
+ */
+ }
+ else
+ {
+ std::cout << "SymmetricDifference("<<nTries<<") OK "
+ << " (x + y) - (x * y) == (x - y) + (y - x)" << std::endl;
+ }
+
+ return correct;
+}
+
+}} // namespace itl boost
+
+#endif
+
+
Added: sandbox/itl/libs/validate/example/labatea/labatea.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/validate/example/labatea/labatea.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,71 @@
+/*----------------------------------------------------------------------------+
+A Law Based Test Automaton 'LaBatea'
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#include <iostream>
+#include <stdio.h>
+#include <boost/validate/loki_xt/Tuple.h>
+#include <boost/itl/set.hpp>
+#include <boost/itl/map.hpp>
+#include <boost/validate/lawvalidater.h>
+#include <boost/validate/laws/monoid.h>
+#include <boost/validate/gentor/gentorprofile.h>
+#include <boost/validate/gentor/rangegentor.h>
+#include <boost/validate/realmvalidater.h>
+#include <boost/itl/interval_set.hpp>
+#include <boost/itl_xt/numbergentor.hpp>
+#include <boost/itl_xt/setgentor.hpp>
+#include <boost/itl/functors.hpp>
+
+using namespace std;
+using namespace Loki;
+using namespace boost::itl;
+
+
+void test_Validater()
+{
+ //GentorProfileSgl::it()->set_range_int(-10, 10);
+ //GentorProfileSgl::it()->set_range_double(-10.0, 10.0);
+ //GentorProfileSgl::it()->set_range_ContainerSize(0, 20);
+ //GentorProfileSgl::it()->set_range_interval_int(-20, 20);
+ //GentorProfileSgl::it()->set_maxIntervalLength(5);
+
+
+ //typedef BinaryPushout<itl::split_interval_map<int,double>, itl::map<int,double>, Interval::Atomize, inplace_plus>
+ // Map_Atomize_Union_DiagramT;
+ //LawValidater<Map_Atomize_Union_DiagramT, RandomGentor> map_atomize_plus_pushout;
+ //map_atomize_plus_pushout.setTrialsCount(1000);
+ //map_atomize_plus_pushout.run();
+
+ //typedef BinaryPushout<itl::map<int,double>, itl::split_interval_map<int,double>, Interval::Cluster, inplace_star>
+ // Map_Cluster_Intersect_DiagramT;
+ //LawValidater<Map_Cluster_Intersect_DiagramT, RandomGentor> map_cluster_star_pushout;
+ //map_cluster_star_pushout.setTrialsCount(1000);
+ //map_cluster_star_pushout.run();
+}
+
+
+void test_realmvalidater()
+{
+ RealmValidater validater;
+ cout <<
+ ">> ------------------------------------------------------ <<\n"
+ ">> -------- Law based test automaton 'LaBatea' ---------- <<\n"
+ ">> Output will be generated in a few seconds\n"
+ ">> terminate by typing <CTRL>C\n"
+ ">> ------------------------------------------------------ <<\n";
+ validater.validate();
+};
+
+
+int main()
+{
+ //test_Validater();
+ test_realmvalidater();
+ return 0;
+}
Added: sandbox/itl/libs/validate/example/labatea/vc9_labatea.vcproj
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/validate/example/labatea/vc9_labatea.vcproj 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="vc9_labatea"
+ ProjectGUID="{BF42574F-66E2-42DD-90D9-3A8FCE6F4719}"
+ RootNamespace="vc9_labatea"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../../../bin/debug"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/debug"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../../../bin/release"
+ IntermediateDirectory="../../../../bin/obj/$(ProjectName)/release"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ ExceptionHandling="1"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ LinkTimeCodeGeneration="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Quelldateien"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\src\gentor\gentorprofile.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\labatea\labatea.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Headerdateien"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\..\boost\validate\law.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\lawvalidater.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\lawviolations.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\laws\monoid.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\laws\order.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\laws\pushouts.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\realmvalidater.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\laws\set_laws.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\validate\typevalidater.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Ressourcendateien"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/itl/libs/validate/src/gentor/gentorprofile.cpp
==============================================================================
--- (empty file)
+++ sandbox/itl/libs/validate/src/gentor/gentorprofile.cpp 2008-11-04 13:46:18 EST (Tue, 04 Nov 2008)
@@ -0,0 +1,66 @@
+/*----------------------------------------------------------------------------+
+Interval Template Library
+Author: Joachim Faulhaber
+Copyright (c) 2007-2008: 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)
++----------------------------------------------------------------------------*/
+#include <boost/validate/gentor/gentorprofile.h>
+
+using namespace boost::itl;
+
+GentorProfileSgl* GentorProfileSgl::s_instance = NULL;
+
+GentorProfileSgl* GentorProfileSgl::it()
+{
+ if(s_instance==NULL) {
+ s_instance = new GentorProfileSgl;
+ }
+ return s_instance;
+}
+
+GentorProfileSgl::GentorProfileSgl(){}
+
+
+
+GentorProfile::GentorProfile()
+{
+ //---------------------------------
+ //standard values
+ set_range_int(-10, 10);
+ set_range_double(0.0, 1.0);
+ set_range_ContainerSize(0,10);
+
+ set_range_interval_int(-10, 10);
+ set_maxIntervalLength(8);
+
+ set_range_element_ContainerSize(0,5);
+
+ //---------------------------------
+ //small values
+ //set_range_int(0, 10);
+ //set_range_double(0.0, 1.0);
+ //set_range_ContainerSize(0,4);
+
+ //set_range_interval_int(0, 10);
+ //set_maxIntervalLength(5);
+ //set_range_element_ContainerSize(0,4);
+
+ //---------------------------------
+ //current values
+ //set_range_int(-5, 5);
+ //set_range_double(0.0, 1.0);
+ //set_range_ContainerSize(0,6);
+
+ //set_range_interval_int(-5, 5);
+ //set_maxIntervalLength(6);
+
+ //set_range_element_ContainerSize(0,4);
+}
+
+// -------------------------------------
+// (Algebra, Law, Type) -> (testsCount)
+// (set, ipAddCommut, itl::set) -> 150
+
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