123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- #ifndef BOOST_ICL_INTERVAL_SET_HPP_JOFA_990223
- #define BOOST_ICL_INTERVAL_SET_HPP_JOFA_990223
- #include <boost/assert.hpp>
- #include <boost/icl/type_traits/is_interval_joiner.hpp>
- #include <boost/icl/interval_base_set.hpp>
- namespace boost{namespace icl
- {
- template
- <
- typename DomainT,
- ICL_COMPARE Compare = ICL_COMPARE_INSTANCE(ICL_COMPARE_DEFAULT, DomainT),
- ICL_INTERVAL(ICL_COMPARE) Interval = ICL_INTERVAL_INSTANCE(ICL_INTERVAL_DEFAULT, DomainT, Compare),
- ICL_ALLOC Alloc = std::allocator
- >
- class interval_set:
- public interval_base_set<interval_set<DomainT,Compare,Interval,Alloc>,
- DomainT,Compare,Interval,Alloc>
- {
- public:
- typedef interval_set<DomainT,Compare,Interval,Alloc> type;
-
- typedef interval_base_set<type,DomainT,Compare,Interval,Alloc> base_type;
- typedef type overloadable_type;
- typedef type joint_type;
- typedef type key_object_type;
-
- typedef DomainT domain_type;
-
- typedef DomainT codomain_type;
-
- typedef DomainT element_type;
-
- typedef ICL_INTERVAL_TYPE(Interval,DomainT,Compare) interval_type;
-
- typedef interval_type segment_type;
-
- typedef ICL_COMPARE_DOMAIN(Compare,DomainT) domain_compare;
-
- typedef exclusive_less_than<interval_type> interval_compare;
-
- typedef exclusive_less_than<interval_type> key_compare;
-
- typedef Alloc<interval_type> allocator_type;
-
- typedef Alloc<DomainT> domain_allocator_type;
-
- typedef typename base_type::atomized_type atomized_type;
-
- typedef typename base_type::ImplSetT ImplSetT;
-
- typedef typename ImplSetT::key_type key_type;
-
- typedef typename ImplSetT::value_type data_type;
-
- typedef typename ImplSetT::value_type value_type;
-
- typedef typename ImplSetT::iterator iterator;
-
- typedef typename ImplSetT::const_iterator const_iterator;
- enum { fineness = 1 };
- public:
-
-
-
-
- interval_set(): base_type() {}
-
- interval_set(const interval_set& src): base_type(src) {}
-
- template<class SubType>
- explicit interval_set
- (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- {
- this->assign(src);
- }
-
- explicit interval_set(const domain_type& value): base_type()
- { this->add(interval_type(value)); }
-
- explicit interval_set(const interval_type& itv): base_type()
- {
- this->add(itv);
- }
-
- template<class SubType>
- void assign(const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- {
- typedef interval_base_set<SubType,DomainT,Compare,Interval,Alloc> base_set_type;
- this->clear();
-
- iterator prior_ = this->_set.end();
- ICL_const_FORALL(typename base_set_type, it_, src)
- prior_ = this->add(prior_, *it_);
- }
-
- template<class SubType>
- interval_set& operator =
- (const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& src)
- {
- this->assign(src);
- return *this;
- }
- # ifndef BOOST_ICL_NO_CXX11_RVALUE_REFERENCES
-
-
-
-
- interval_set(interval_set&& src)
- : base_type(boost::move(src))
- {}
-
- interval_set& operator = (interval_set src)
- {
- base_type::operator=(boost::move(src));
- return *this;
- }
-
- # else
-
- interval_set& operator = (const interval_set& src)
- {
- base_type::operator=(src);
- return *this;
- }
- # endif
- private:
-
- friend class
- interval_base_set <interval_set<DomainT,Compare,Interval,Alloc>,
- DomainT,Compare,Interval,Alloc>;
- iterator handle_inserted(iterator it_)
- {
- return segmental::join_neighbours(*this, it_);
- }
- iterator add_over(const interval_type& addend, iterator last_)
- {
- iterator joined_ = segmental::join_under(*this, addend, last_);
- return segmental::join_neighbours(*this, joined_);
- }
- iterator add_over(const interval_type& addend)
- {
- iterator joined_ = segmental::join_under(*this, addend);
- return segmental::join_neighbours(*this, joined_);
- }
- } ;
- template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
- struct is_set<icl::interval_set<DomainT,Compare,Interval,Alloc> >
- {
- typedef is_set<icl::interval_set<DomainT,Compare,Interval,Alloc> > type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
- struct is_interval_container<icl::interval_set<DomainT,Compare,Interval,Alloc> >
- {
- typedef is_interval_container<icl::interval_set<DomainT,Compare,Interval,Alloc> > type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
- struct is_interval_joiner<icl::interval_set<DomainT,Compare,Interval,Alloc> >
- {
- typedef is_interval_joiner<icl::interval_set<DomainT,Compare,Interval,Alloc> > type;
- BOOST_STATIC_CONSTANT(bool, value = true);
- };
- template <class DomainT, ICL_COMPARE Compare, ICL_INTERVAL(ICL_COMPARE) Interval, ICL_ALLOC Alloc>
- struct type_to_string<icl::interval_set<DomainT,Compare,Interval,Alloc> >
- {
- static std::string apply()
- { return "itv_set<"+ type_to_string<DomainT>::apply() +">"; }
- };
- }}
- #endif
|