1 #ifndef theplu_yat_utility_segment 2 #define theplu_yat_utility_segment 27 #include "yat_assert.h" 48 template<
typename T,
class Compare = std::less<T> >
83 T&
begin(
void) {
return begin_; }
88 const T&
begin(
void)
const {
return begin_; }
93 T&
end(
void) {
return end_; }
98 const T&
end(
void)
const {
return end_; }
136 template<
typename T,
class Compare>
142 || comp(lhs.
end(), rhs.
end()) || comp(rhs.
end(), lhs.
end());
155 template<
typename T,
class Compare>
178 template<
typename T,
class Compare>
183 YAT_ASSERT(!c(lhs.
end(), lhs.
begin()));
184 YAT_ASSERT(!c(rhs.
end(), rhs.
begin()));
203 template<
typename T,
class Compare>
207 if (compare(lhs, rhs))
209 if (compare(rhs, lhs))
222 template<
typename T,
class Compare>
227 if (comp(element, segment.
begin()))
229 if (comp(element, segment.
end()))
241 template<
typename T,
class Compare>
245 return -compare_3way(element, segment);
257 template<
typename T,
class Compare>
267 std::min(a.
end(), b.
end(), comp),
286 template<
typename T,
class Compare>
304 template<
typename T,
class Compare>
321 template<
typename T,
class Compare>
325 return !compare(lhs, rhs) && !compare(rhs, lhs);
332 template<
typename T,
class Compare>
334 public std::binary_function<Segment<T,Compare>, Segment<T,Compare>, bool>
341 {
return compare(lhs, rhs); }
bool includes(const yat::utility::Segment< T, Compare > &lhs, const yat::utility::Segment< T, Compare > &rhs)
Definition: Segment.h:305
The Department of Theoretical Physics namespace as we define it.
T & end(void)
Definition: Segment.h:93
T value_type
Definition: Segment.h:55
Definition: stl_utility.h:64
Segment< T, Compare > set_union(const Segment< T, Compare > &a, const Segment< T, Compare > &b)
union of two segments
Definition: Segment.h:287
Segment< T > make_segment(T first, T last)
Definition: Segment.h:116
T max(const T &a, const T &b, const T &c)
Definition: stl_utility.h:699
bool operator()(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs) const
Definition: Segment.h:339
Segment(void)
default constructor
Definition: Segment.h:60
functor using compare
Definition: Segment.h:333
int compare_3way(const T &element, const Segment< T, Compare > &segment)
Definition: Segment.h:223
Segment(T &&begin, T &&end)
Constructor.
Definition: Segment.h:77
a class for a Segment or Interval
Definition: Segment.h:49
bool operator==(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Definition: Segment.h:156
const T & end(void) const
Definition: Segment.h:98
Segment< T, Compare > intersection(const Segment< T, Compare > &a, const Segment< T, Compare > &b)
Definition: Segment.h:258
int compare_3way(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Definition: Segment.h:204
const T & begin(void) const
Definition: Segment.h:88
bool operator!=(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Inequality operator.
Definition: Segment.h:137
bool compare(const Segment< T, Compare > &lhs, const Segment< T, Compare > &rhs)
Definition: Segment.h:179
Segment(const T &begin, const T &end)
Constructor.
Definition: Segment.h:67
T & begin(void)
Definition: Segment.h:83
bool overlap(const yat::utility::Segment< T, Compare > &lhs, const yat::utility::Segment< T, Compare > &rhs)
Definition: Segment.h:322
int compare_3way(const Segment< T, Compare > &segment, const T &element)
Definition: Segment.h:242