1 #ifndef theplu_yat_utility_segment_set
2 #define theplu_yat_utility_segment_set
28 #include "SegmentTree.h"
30 #include "yat_assert.h"
46 template<
typename T,
class Compare = std::less<T> >
49 SegmentCompare<T, Compare> >,
51 Identity<const Segment<T, Compare>&> >
67 std::pair<typename me::iterator, typename me::iterator> p =
85 std::pair<typename me::iterator, typename me::iterator> p(hint, hint);
91 if (hint!=this->
end() && compare(*hint, segment))
94 if (p.first!=this->begin()) {
98 if (compare(segment, *p.first))
101 while (p.first!=this->begin() && !compare(*p.first, segment))
103 YAT_ASSERT(p.first==this->begin() || compare(*p.first, segment));
104 YAT_ASSERT(p.first!=this->end());
105 if (compare(*p.first, segment))
110 while (p.second!=this->end() && !compare(segment, *p.second))
124 template<
typename Iterator>
128 for ( ; first!=last; ++first) {
144 YAT_ASSERT(p.first==this->end() || !compare(*p.first, segment));
145 YAT_ASSERT(p.second==this->end() || compare(segment, *p.second));
146 if (p.first==p.second) {
147 return this->
container_.insert(p.first, segment);
158 YAT_ASSERT(last==this->
end() || compare(segment, *last));
159 YAT_ASSERT(last!=this->
begin());
161 YAT_ASSERT(compare_3way(segment, *last)==0);
164 segment2(std::min(p.first->begin(), segment.begin(), comp),
165 std::max(last->end(), segment.end(), comp));
168 return this->
container_.insert(p.second, segment2);
SegmentSet(void)
creates a set with no segments
Definition: SegmentSet.h:58
std::set< Segment< T, Compare >, SegmentCompare< T, Compare > >::iterator iterator
iterator
Definition: SegmentTree.h:88
std::set< Segment< T, Compare >, SegmentCompare< T, Compare > >::value_type value_type
value type is same as Container 's value_type.
Definition: SegmentTree.h:61
me::iterator insert_merge(typename me::iterator hint, const typename me::value_type &segment)
insert with a hint
Definition: SegmentSet.h:82
me::const_iterator insert_merge(const typename me::value_type &segment)
Definition: SegmentSet.h:65
T max(const T &a, const T &b, const T &c)
Definition: stl_utility.h:697
std::set< Segment< T, Compare >, SegmentCompare< T, Compare > >::const_iterator const_iterator
const_iterator
Definition: SegmentTree.h:90
const_iterator begin(void) const
Definition: SegmentTree.h:105
a set of Segments
Definition: SegmentSet.h:47
void insert_merge(Iterator first, Iterator last)
Definition: SegmentSet.h:125
Base Class for SegmentSet and SegmentMap.
Definition: SegmentTree.h:45
std::pair< iterator, iterator > overlap_range(const key_type &segment)
Definition: SegmentTree.h:239
std::set< Segment< T, Compare >, SegmentCompare< T, Compare > > container_
underlying container
Definition: SegmentTree.h:232
const_iterator end(void) const
Definition: SegmentTree.h:130