1 #ifndef theplu_yat_utility_segment
2 #define theplu_yat_utility_segment
25 #include "yat_assert.h"
46 template<
typename T,
class Compare = std::less<T> >
66 : begin_(begin), end_(end) {}
71 T&
begin(
void) {
return begin_; }
76 const T&
begin(
void)
const {
return begin_; }
81 T&
end(
void) {
return end_; }
86 const T&
end(
void)
const {
return end_; }
112 template<
typename T,
class Compare>
118 || comp(lhs.
end(), rhs.
end()) || comp(rhs.
end(), lhs.
end());
131 template<
typename T,
class Compare>
154 template<
typename T,
class Compare>
159 YAT_ASSERT(!c(lhs.
end(), lhs.
begin()));
160 YAT_ASSERT(!c(rhs.
end(), rhs.
begin()));
179 template<
typename T,
class Compare>
183 if (compare(lhs, rhs))
185 if (compare(rhs, lhs))
198 template<
typename T,
class Compare>
203 if (comp(element, segment.
begin()))
205 if (comp(element, segment.
end()))
217 template<
typename T,
class Compare>
221 return -compare_3way(element, segment);
233 template<
typename T,
class Compare>
243 std::min(a.
end(), b.
end(), comp),
251 template<
typename T,
class Compare>
253 public std::binary_function<Segment<T,Compare>, Segment<T,Compare>, bool>
260 {
return compare(lhs, rhs); }
const T & begin(void) const
Definition: Segment.h:76
T & end(void)
Definition: Segment.h:81
T value_type
Definition: Segment.h:53
const T & end(void) const
Definition: Segment.h:86
T max(const T &a, const T &b, const T &c)
Definition: stl_utility.h:697
Segment(void)
default constructor
Definition: Segment.h:58
functor using compare
Definition: Segment.h:252
int compare_3way(const T &element, const Segment< T, Compare > &segment)
Definition: Segment.h:199
a class for a Segment or Interval
Definition: Segment.h:47
bool operator==(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Definition: Segment.h:132
Segment< T, Compare > intersection(const Segment< T, Compare > &a, const Segment< T, Compare > &b)
Definition: Segment.h:234
int compare_3way(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Definition: Segment.h:180
bool operator()(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs) const
Definition: Segment.h:258
bool operator!=(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Inequality operator.
Definition: Segment.h:113
bool compare(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Definition: Segment.h:155
Segment(const T &begin, const T &end)
Constructor.
Definition: Segment.h:65
T & begin(void)
Definition: Segment.h:71
int compare_3way(const Segment< T, Compare > &segment, const T &element)
Definition: Segment.h:218