1 #ifndef theplu_yat_utility_segment_tree
2 #define theplu_yat_utility_segment_tree
27 #include "yat_assert.h"
44 template<
class Container,
class Compare,
class Value2Key>
78 typedef typename Container::pointer
pointer;
242 if (first!=
begin()) {
244 if (compare(*first, segment))
248 while (last!=
end() && !compare(segment, *last))
250 YAT_ASSERT(last==
end() || compare(segment, *last));
251 return std::make_pair(first, last);
259 template<
class Container,
class Compare,
class Value2Key>
260 typename SegmentTree<Container, Compare, Value2Key>::size_type
263 if (find(element)==end())
269 template<
class Container,
class Compare,
class Value2Key>
276 if (iter==end() || comp(vt, Value2Key()(*iter).begin()))
282 template<
class Container,
class Compare,
class Value2Key>
288 if (iter==end() || comp(vt, Value2Key()(*iter).begin()))
294 template<
typename T,
class Compare,
class Value2Key>
295 std::pair<typename SegmentTree<T, Compare, Value2Key>::iterator,
bool>
298 return container_.insert(segment);
302 template<
typename T,
class Compare,
class Value2Key>
307 iterator result = container_.lower_bound(segment);
309 YAT_ASSERT(result==end()
310 || !compare(Value2Key()(*result),segment));
315 template<
typename T,
class Compare,
class Value2Key>
322 YAT_ASSERT(result==end()
323 || !compare(Value2Key()(*result),segment));
328 template<
typename T,
class Compare,
class Value2Key>
333 iterator result = container_.upper_bound(segment);
336 if (result==end() || comp(element, value2key(*result).begin()))
340 YAT_ASSERT(result==end() || compare(segment, value2key(*result)));
345 template<
typename T,
class Compare,
class Value2Key>
353 if (result==end() || comp(element, value2key(*result).begin()))
357 YAT_ASSERT(result==end() || compare(segment, value2key(*result)));
iterator upper_bound(const element_type &element)
Definition: SegmentTree.h:330
iterator begin(void)
Definition: SegmentTree.h:110
Container::iterator iterator
iterator
Definition: SegmentTree.h:88
iterator find(const element_type &element)
Definition: SegmentTree.h:284
void erase(iterator first, iterator last)
erase values in range [first, last)
Definition: SegmentTree.h:142
Container::value_type value_type
value type is same as Container 's value_type.
Definition: SegmentTree.h:61
Container::key_compare key_compare
key compare
Definition: SegmentTree.h:71
key_type::value_type element_type
element type is same as key_type 's value_type.
Definition: SegmentTree.h:68
size_type count(const element_type &element) const
Definition: SegmentTree.h:261
iterator end(void)
Definition: SegmentTree.h:135
value_compare value_comp(void) const
Definition: SegmentTree.h:228
Container::pointer pointer
pointer
Definition: SegmentTree.h:78
std::pair< iterator, bool > insert(const value_type &value)
insert value
Definition: SegmentTree.h:296
void erase(iterator pos)
Definition: SegmentTree.h:149
Container::const_reference const_reference
const reference
Definition: SegmentTree.h:82
Container::difference_type difference_type
difference_type
Definition: SegmentTree.h:86
void clear(void)
erases all values
Definition: SegmentTree.h:115
iterator lower_bound(const element_type &element)
similar to lower_bound in std::set and std::map
Definition: SegmentTree.h:304
Container::const_iterator const_iterator
const_iterator
Definition: SegmentTree.h:90
Container::reference reference
reference
Definition: SegmentTree.h:80
const_iterator begin(void) const
Definition: SegmentTree.h:105
SegmentTree(void)
creates a SegmentTree with no segments
Definition: SegmentTree.h:95
bool empty(void) const
Definition: SegmentTree.h:125
a class for a Segment or Interval
Definition: Segment.h:47
virtual ~SegmentTree(void)
Destructor.
Definition: SegmentTree.h:100
Container::key_type key_type
key type is same as Container 's key_type.
Definition: SegmentTree.h:53
size_type size(void) const
Definition: SegmentTree.h:208
Container::value_compare value_compare
value compare
Definition: SegmentTree.h:73
Base Class for SegmentSet and SegmentMap.
Definition: SegmentTree.h:45
Container::size_type size_type
size_type
Definition: SegmentTree.h:84
std::pair< iterator, iterator > overlap_range(const key_type &segment)
Definition: SegmentTree.h:239
Compare element_compare
element compare
Definition: SegmentTree.h:75
key_compare key_comp(void) const
Definition: SegmentTree.h:184
Container container_
underlying container
Definition: SegmentTree.h:232
const_iterator end(void) const
Definition: SegmentTree.h:130