2 interval.hh -- part of flowerlib
4 (c) 1996 Han-Wen Nienhuys
22 T
center() { return (left
+ right
) / T(2);}
36 T
& operator[](int j
) {
39 T
operator[](int j
) const {
40 return ((Interval_t
<T
> *)this)->idx(j
);
42 T
&max() { return right
;}
43 T
max()const { return right
;}
44 T
min()const{ return left
; }
45 T
&min(){ return left
; }
46 void unite(Interval_t
<T
> h
);
49 *this and h are comparable
51 void intersect(Interval_t
<T
> h
);
55 bool empty() const { return left
> right
; }
59 Interval_t(T m
, T M
) {
63 Interval_t
<T
> &operator += (T r
) {
72 this represents the closed interval [left,right].
73 No invariants. T must be a totally ordered ring
78 int Interval__compare(const Interval_t
<T
>&,Interval_t
<T
> const&);
80 inclusion ordering. Crash if not comparable.
83 /****************************************************************
85 ****************************************************************/
89 template_instantiate_compare(Interval_t
<T
>&, Interval__compare
, template<class T
>);
94 intersection(Interval_t
<T
> a
, Interval_t
<T
> const&b
)
104 Interval_t
<T
> operator +(T a
,Interval_t
<T
> i
)
112 Interval_t
<T
> operator +(Interval_t
<T
> i
,T a
){
116 typedef Interval_t
<Real
> Interval
;
119 #define Interval__instantiate(T) template struct Interval_t<T>;\
120 template int Interval__compare(const Interval_t<T>&,Interval_t<T> const&)
123 #endif // INTERVAL_HH