]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/interval.tcc
* The grand 2005-2006 replace.
[lilypond.git] / flower / include / interval.tcc
index b67f18165d312f85e0e7b90e01efcecdbf390cbd..ec760db5fc245f7757547cbb865219014f1ad983 100644 (file)
@@ -3,21 +3,24 @@
 
   source file of the Flower Library
 
-  (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #ifndef INTERVAL_TCC
 #define INTERVAL_TCC
 
 #include <cassert>
-#include <cmath>
+
+// MacOS 10.3 problems:
+// #include <cmath>
+using namespace std;
 
 #include "interval.hh"
 #include "string.hh"
 
 template<class T>
 int
-_Interval__compare (const Interval_t<T>&a, Interval_t<T> const &b)
+_Interval__compare (const Interval_t<T> &a, Interval_t<T> const &b)
 {
   if (a.elem (LEFT) == b.elem (LEFT) && a.elem (RIGHT) == b.elem (RIGHT))
     return 0;
@@ -89,32 +92,17 @@ template<class T>
 void
 Interval_t<T>::unite (Interval_t<T> h)
 {
-  elem_ref (LEFT) = h.elem (LEFT) <? elem (LEFT);
-  elem_ref (RIGHT) = h.elem (RIGHT) >? elem (RIGHT);
+  elem_ref (LEFT) = min (h.elem (LEFT), elem (LEFT));
+  elem_ref (RIGHT) = max (h.elem (RIGHT), elem (RIGHT));
 }
 
 template<class T>
 void
 Interval_t<T>::intersect (Interval_t<T> h)
 {
-#if defined (__GNUG__) && !defined (__STRICT_ANSI__)
-  elem_ref (LEFT) = h.elem (LEFT) >? elem (LEFT);
-  elem_ref (RIGHT) = h.elem (RIGHT) <? elem (RIGHT);
-#else
   elem_ref (LEFT) = max (h.elem (LEFT), elem (LEFT));
   elem_ref (RIGHT) = min (h.elem (RIGHT), elem (RIGHT));
-#endif
-}
-
-#if 0 //this is called intersection
-template<class T>
-Interval_t<T>
-intersect (Interval_t<T> x, Interval_t<T> const &y)
-{
-  x.intersect (y);
-  return x;
 }
-#endif
 
 template<class T>
 String
@@ -130,12 +118,12 @@ Interval_t<T>::to_string () const
 
 template<class T>
 bool
-Interval_t<T>::contains (T r)
+Interval_t<T>::contains (T r) const
 {
   return r >= elem (LEFT) && r <= elem (RIGHT);
 }
 
 #define INTERVAL__INSTANTIATE(T) struct Interval_t<T>;                 \
-  template int Interval__compare (const Interval_t<T>&, Interval_t<T> const &)
+  template int Interval__compare (const Interval_t<T> &, Interval_t<T> const &)
 
 #endif // INTERVAL_TCC