File indexing completed on 2025-01-30 09:43:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_ICL_DETAIL_INTERVAL_MORPHISM_HPP_JOFA_080315
0009 #define BOOST_ICL_DETAIL_INTERVAL_MORPHISM_HPP_JOFA_080315
0010
0011 #include <boost/icl/detail/notate.hpp>
0012 #include <boost/icl/concept/interval_set_value.hpp>
0013 #include <boost/icl/concept/element_set_value.hpp>
0014 #include <boost/icl/concept/set_value.hpp>
0015 #include <boost/icl/concept/map_value.hpp>
0016 #include <boost/icl/associative_interval_container.hpp>
0017 #include <boost/icl/associative_element_container.hpp>
0018
0019 namespace boost{namespace icl
0020 {
0021 namespace segmental
0022 {
0023 template <typename ElementContainerT, typename IntervalContainerT>
0024 void atomize(ElementContainerT& result, const IntervalContainerT& src)
0025 {
0026 ICL_const_FORALL(typename IntervalContainerT, itv_, src)
0027 {
0028 const typename IntervalContainerT::key_type& itv = icl::key_value<IntervalContainerT>(itv_);
0029 typename IntervalContainerT::codomain_type coval = icl::co_value<IntervalContainerT>(itv_);
0030
0031 for(typename IntervalContainerT::domain_type element = first(itv); element <= last(itv); ++element)
0032 icl::insert(result, icl::make_value<ElementContainerT>(element, coval));
0033 }
0034 }
0035
0036 template <typename IntervalContainerT, typename ElementContainerT>
0037 void cluster(IntervalContainerT& result, const ElementContainerT& src)
0038 {
0039 typedef typename IntervalContainerT::key_type key_type;
0040 ICL_const_FORALL(typename ElementContainerT, element_, src)
0041 {
0042 const typename ElementContainerT::key_type& key
0043 = key_value<ElementContainerT>(element_);
0044 const typename codomain_type_of<ElementContainerT>::type& coval
0045 = co_value<ElementContainerT>(element_);
0046
0047 result += icl::make_value<IntervalContainerT>(key_type(key), coval);
0048 }
0049 }
0050
0051 template <typename AtomizedType, typename ClusteredType>
0052 struct atomizer
0053 {
0054 void operator()(AtomizedType& atomized, const ClusteredType& clustered)
0055 {
0056 segmental::atomize(atomized, clustered);
0057 }
0058 };
0059
0060 template <typename ClusteredType, typename AtomizedType>
0061 struct clusterer
0062 {
0063 void operator()(ClusteredType& clustered, const AtomizedType& atomized)
0064 {
0065 segmental::cluster(clustered, atomized);
0066 }
0067 };
0068
0069 template <typename JointType, typename SplitType>
0070 struct joiner
0071 {
0072 void operator()(JointType& joint, SplitType& split)
0073 {
0074 icl::join(split);
0075 ICL_FORALL(typename SplitType, split_, split)
0076 joint.insert(*split_);
0077 }
0078 };
0079
0080 template <typename AbsorberType, typename EnricherType>
0081 struct identity_absorber
0082 {
0083 void operator()(AbsorberType& absorber, EnricherType& enricher)
0084 {
0085 icl::absorb_identities(enricher);
0086 ICL_FORALL(typename EnricherType, enricher_, enricher)
0087 absorber.insert(*enricher_);
0088 }
0089 };
0090
0091 }
0092
0093
0094 template<>
0095 inline std::string binary_template_to_string<segmental::atomizer>::apply() { return "@"; }
0096 template<>
0097 inline std::string binary_template_to_string<segmental::clusterer>::apply() { return "&"; }
0098 template<>
0099 inline std::string binary_template_to_string<segmental::joiner>::apply() { return "j"; }
0100 template<>
0101 inline std::string binary_template_to_string<segmental::identity_absorber>::apply() { return "a0"; }
0102 }}
0103
0104 #endif
0105
0106
0107