File indexing completed on 2025-01-18 09:38:23
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_ICL_SEPARATE_INTERVAL_SET_HPP_JOFA_080608
0009 #define BOOST_ICL_SEPARATE_INTERVAL_SET_HPP_JOFA_080608
0010
0011 #include <boost/assert.hpp>
0012 #include <boost/icl/type_traits/is_interval_separator.hpp>
0013 #include <boost/icl/interval_base_set.hpp>
0014 #include <boost/icl/interval_set.hpp>
0015
0016 namespace boost{namespace icl
0017 {
0018
0019
0020 template
0021 <
0022 typename DomainT,
0023 ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT),
0024 ICL_INTERVAL(ICL_COMPARE) Interval = ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, DomainT, Compare),
0025 ICL_ALLOC Alloc = std::allocator
0026 >
0027 class separate_interval_set:
0028 public interval_base_set<separate_interval_set<DomainT,Compare,Interval,Alloc>,
0029 DomainT,Compare,Interval,Alloc>
0030 {
0031 public:
0032 typedef separate_interval_set<DomainT,Compare,Interval,Alloc> type;
0033
0034 typedef interval_base_set<type,DomainT,Compare,Interval,Alloc> base_type;
0035
0036 typedef type overloadable_type;
0037 typedef type key_object_type;
0038
0039 typedef interval_set<DomainT,Compare,Interval,Alloc> joint_type;
0040
0041
0042 typedef DomainT domain_type;
0043
0044 typedef DomainT codomain_type;
0045
0046
0047 typedef DomainT element_type;
0048
0049 typedef ICL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
0050
0051 typedef interval_type segment_type;
0052
0053
0054 typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
0055
0056 typedef exclusive_less_than<interval_type> interval_compare;
0057
0058
0059 typedef exclusive_less_than<interval_type> key_compare;
0060
0061
0062 typedef Alloc<interval_type> allocator_type;
0063
0064
0065 typedef Alloc<DomainT> domain_allocator_type;
0066
0067
0068 typedef typename base_type::atomized_type atomized_type;
0069
0070
0071 typedef typename base_type::ImplSetT ImplSetT;
0072
0073
0074 typedef typename ImplSetT::key_type key_type;
0075
0076 typedef typename ImplSetT::value_type data_type;
0077
0078 typedef typename ImplSetT::value_type value_type;
0079
0080
0081 typedef typename ImplSetT::iterator iterator;
0082
0083 typedef typename ImplSetT::const_iterator const_iterator;
0084
0085 enum { fineness = 2 };
0086
0087 public:
0088
0089
0090
0091
0092 separate_interval_set(): base_type() {}
0093
0094 separate_interval_set(const separate_interval_set& src): base_type(src) {}
0095
0096
0097 template<class SubType>
0098 separate_interval_set
0099 (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
0100 {
0101 this->assign(src);
0102 }
0103
0104
0105 explicit separate_interval_set(const domain_type& elem): base_type() { this->add(elem); }
0106
0107 explicit separate_interval_set(const interval_type& itv): base_type() { this->add(itv); }
0108
0109
0110 template<class SubType>
0111 void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
0112 {
0113 this->clear();
0114 this->_set.insert(src.begin(), src.end());
0115 }
0116
0117
0118 template<class SubType>
0119 separate_interval_set& operator =
0120 (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
0121 {
0122 this->assign(src);
0123 return *this;
0124 }
0125
0126 # ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
0127
0128
0129
0130
0131
0132 separate_interval_set(separate_interval_set&& src)
0133 : base_type(boost::move(src))
0134 {}
0135
0136
0137 separate_interval_set& operator = (separate_interval_set src)
0138 {
0139 base_type::operator=(boost::move(src));
0140 return *this;
0141 }
0142
0143 # else
0144
0145
0146 separate_interval_set& operator = (const separate_interval_set& src)
0147 {
0148 base_type::operator=(src);
0149 return *this;
0150 }
0151
0152 # endif
0153
0154 private:
0155
0156 friend class
0157 interval_base_set<separate_interval_set<DomainT,Compare,Interval,Alloc>,
0158 DomainT,Compare,Interval,Alloc>;
0159
0160 iterator handle_inserted(iterator inserted_)
0161 {
0162 return inserted_;
0163 }
0164
0165 iterator add_over(const interval_type& addend, iterator last_)
0166 {
0167 return segmental::join_under(*this, addend, last_);
0168 }
0169
0170 iterator add_over(const interval_type& addend)
0171 {
0172 return segmental::join_under(*this, addend);
0173 }
0174
0175 } ;
0176
0177
0178
0179
0180
0181
0182 template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
0183 struct is_set<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> >
0184 {
0185 typedef is_set<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> > type;
0186 BOOST_STATIC_CONSTANT(bool, value = true);
0187 };
0188
0189 template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
0190 struct is_interval_container<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> >
0191 {
0192 typedef is_interval_container<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> > type;
0193 BOOST_STATIC_CONSTANT(bool, value = true);
0194 };
0195
0196 template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
0197 struct is_interval_separator<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> >
0198 {
0199 typedef is_interval_separator<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> > type;
0200 BOOST_STATIC_CONSTANT(bool, value = true);
0201 };
0202
0203
0204
0205
0206 template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
0207 struct type_to_string<icl::separate_interval_set<DomainT,Compare,Interval,Alloc> >
0208 {
0209 static std::string apply()
0210 { return "se_itv_set<"+ type_to_string<DomainT>::apply() +">"; }
0211 };
0212
0213 }}
0214
0215 #endif
0216
0217