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"
17 #include "flower-debug.hh"
21 Interval_t<T>::print () const
28 _Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
30 if (a.left == b.left && a.right == b.right)
33 if (a.left <= b.left && a.right >= b.right)
36 if (a.left >= b.left && a.right <= b.right)
44 Interval_t<T>::contains_b (Interval_t<T> const& a) const
46 int c_i= _Interval__compare (*this, a);
54 Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
56 int i = _Interval__compare (a,b);
64 Interval_t<T>::set_empty()
66 left = (T) infinity();
67 right = (T) -infinity();
72 Interval_t<T>::length() const
82 Interval_t<T>::unite (Interval_t<T> h)
91 smallest Interval which includes *this and #h#
96 Interval_t<T>::intersect (Interval_t<T> h)
98 #if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
99 left = h.left >? left;
100 right = h.right <?right;
102 left = max (h.left, left);
103 right = min (h.right, right);
109 intersect (Interval_t<T> x, Interval_t<T> const &y)
117 Interval_t<T>::str() const
123 return s + T_to_str (left) + String ("," ) + T_to_str (right ) + String ("]" );
128 Interval_t<T>::elt_b (T r)
130 return r >= left && r <= right;
134 #define INTERVAL__INSTANTIATE(T) struct Interval_t<T>;\
135 template int Interval__compare(const Interval_t<T>&,Interval_t<T> const&)
137 #endif // INTERVAL_TCC