annotate DEPENDENCIES/generic/include/boost/icl/detail/interval_morphism.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*-----------------------------------------------------------------------------+
Chris@16 2 Copyright (c) 2008-2009: Joachim Faulhaber
Chris@16 3 +------------------------------------------------------------------------------+
Chris@16 4 Distributed under the Boost Software License, Version 1.0.
Chris@16 5 (See accompanying file LICENCE.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 +-----------------------------------------------------------------------------*/
Chris@16 8 #ifndef BOOST_ICL_DETAIL_INTERVAL_MORPHISM_HPP_JOFA_080315
Chris@16 9 #define BOOST_ICL_DETAIL_INTERVAL_MORPHISM_HPP_JOFA_080315
Chris@16 10
Chris@16 11 #include <boost/icl/detail/notate.hpp>
Chris@16 12 #include <boost/icl/concept/interval_set_value.hpp>
Chris@16 13 #include <boost/icl/concept/element_set_value.hpp>
Chris@16 14 #include <boost/icl/concept/set_value.hpp>
Chris@16 15 #include <boost/icl/concept/map_value.hpp>
Chris@16 16 #include <boost/icl/associative_interval_container.hpp>
Chris@16 17 #include <boost/icl/associative_element_container.hpp>
Chris@16 18
Chris@16 19 namespace boost{namespace icl
Chris@16 20 {
Chris@16 21 namespace segmental
Chris@16 22 {
Chris@16 23 template <typename ElementContainerT, typename IntervalContainerT>
Chris@16 24 void atomize(ElementContainerT& result, const IntervalContainerT& src)
Chris@16 25 {
Chris@16 26 ICL_const_FORALL(typename IntervalContainerT, itv_, src)
Chris@16 27 {
Chris@16 28 const typename IntervalContainerT::key_type& itv = icl::key_value<IntervalContainerT>(itv_);
Chris@16 29 typename IntervalContainerT::codomain_type coval = icl::co_value<IntervalContainerT>(itv_);
Chris@16 30
Chris@16 31 for(typename IntervalContainerT::domain_type element = first(itv); element <= last(itv); ++element)
Chris@16 32 icl::insert(result, icl::make_value<ElementContainerT>(element, coval));
Chris@16 33 }
Chris@16 34 }
Chris@16 35
Chris@16 36 template <typename IntervalContainerT, typename ElementContainerT>
Chris@16 37 void cluster(IntervalContainerT& result, const ElementContainerT& src)
Chris@16 38 {
Chris@16 39 typedef typename IntervalContainerT::key_type key_type;
Chris@16 40 ICL_const_FORALL(typename ElementContainerT, element_, src)
Chris@16 41 {
Chris@16 42 const typename ElementContainerT::key_type& key
Chris@16 43 = key_value<ElementContainerT>(element_);
Chris@16 44 const typename codomain_type_of<ElementContainerT>::type& coval
Chris@16 45 = co_value<ElementContainerT>(element_);
Chris@16 46
Chris@16 47 result += icl::make_value<IntervalContainerT>(key_type(key), coval);
Chris@16 48 }
Chris@16 49 }
Chris@16 50
Chris@16 51 template <typename AtomizedType, typename ClusteredType>
Chris@16 52 struct atomizer
Chris@16 53 {
Chris@16 54 void operator()(AtomizedType& atomized, const ClusteredType& clustered)
Chris@16 55 {
Chris@16 56 segmental::atomize(atomized, clustered);
Chris@16 57 }
Chris@16 58 };
Chris@16 59
Chris@16 60 template <typename ClusteredType, typename AtomizedType>
Chris@16 61 struct clusterer
Chris@16 62 {
Chris@16 63 void operator()(ClusteredType& clustered, const AtomizedType& atomized)
Chris@16 64 {
Chris@16 65 segmental::cluster(clustered, atomized);
Chris@16 66 }
Chris@16 67 };
Chris@16 68
Chris@16 69 template <typename JointType, typename SplitType>
Chris@16 70 struct joiner
Chris@16 71 {
Chris@16 72 void operator()(JointType& joint, SplitType& split)
Chris@16 73 {
Chris@16 74 icl::join(split);
Chris@16 75 ICL_FORALL(typename SplitType, split_, split)
Chris@16 76 joint.insert(*split_);
Chris@16 77 }
Chris@16 78 };
Chris@16 79
Chris@16 80 template <typename AbsorberType, typename EnricherType>
Chris@16 81 struct identity_absorber
Chris@16 82 {
Chris@16 83 void operator()(AbsorberType& absorber, EnricherType& enricher)
Chris@16 84 {
Chris@16 85 icl::absorb_identities(enricher);
Chris@16 86 ICL_FORALL(typename EnricherType, enricher_, enricher)
Chris@16 87 absorber.insert(*enricher_);
Chris@16 88 }
Chris@16 89 };
Chris@16 90
Chris@16 91 } // namespace Interval
Chris@16 92
Chris@16 93
Chris@16 94 template<>
Chris@16 95 inline std::string binary_template_to_string<segmental::atomizer>::apply() { return "@"; }
Chris@16 96 template<>
Chris@16 97 inline std::string binary_template_to_string<segmental::clusterer>::apply() { return "&"; }
Chris@16 98 template<>
Chris@16 99 inline std::string binary_template_to_string<segmental::joiner>::apply() { return "j"; }
Chris@16 100 template<>
Chris@16 101 inline std::string binary_template_to_string<segmental::identity_absorber>::apply() { return "a0"; }
Chris@16 102 }} // namespace boost icl
Chris@16 103
Chris@16 104 #endif // BOOST_ICL_DETAIL_INTERVAL_MORPHISM_HPP_JOFA_080315
Chris@16 105
Chris@16 106
Chris@16 107