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