2 interval.tcc -- implement Interval_t
4 source file of the Flower Library
6 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
15 #include "interval.hh"
21 _Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
23 if (a.left == b.left && a.right == b.right)
26 if (a.left <= b.left && a.right >= b.right)
29 if (a.left >= b.left && a.right <= b.right)
37 Interval_t<T>::contains_b (Interval_t<T> const& a)const
39 int c_i= _Interval__compare (*this, a);
47 Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
49 int i = _Interval__compare (a,b);
57 Interval_t<T>::set_empty()
59 left = (T) infinity();
60 right = (T) -infinity();
65 Interval_t<T>::length() const {
66 assert (right >= left);
72 Interval_t<T>::unite (Interval_t<T> h)
81 smallest Interval which includes *this and #h#
86 Interval_t<T>::intersect (Interval_t<T> h)
88 #if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
89 left = h.left >? left;
90 right = h.right <?right;
92 left = max (h.left, left);
93 right = min (h.right, right);
99 intersect (Interval_t<T> x, Interval_t<T> const &y)
107 Interval_t<T>::str() const
113 return s + String (left) + String ("," ) + String (right ) + String ("]" );
118 Interval_t<T>::elt_b (T r)
120 return r >= left && r <= right;
124 #define INTERVAL__INSTANTIATE(T) struct Interval_t<T>;\
125 template int Interval__compare(const Interval_t<T>&,Interval_t<T> const&)
127 #endif // INTERVAL_TCC