]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/interval.cc
Run `make grand-replace'.
[lilypond.git] / flower / interval.cc
index 46b4fc7e1603f2bb7346f5af0d6ec3e857eb5404..fcfa18dbd7fcdedba4bc490278e0090fd9734783 100644 (file)
@@ -1,93 +1,42 @@
-#include <assert.h> 
-#include <math.h>
-#include "interval.hh"
-#include "string.hh"
-
-
-
-template<class T>
-int
-Interval__compare(const Interval_t<T>&a,Interval_t<T> const&b)
-{
-    if (a.left == b.left && a.right == b.right)
-       return 0;
-    
-    if (a.left <= b.left && a.right >= b.right)
-       return 1;
-
-    if (a.left >= b.left && a.right <= b.right)
-       return -1;
-
-    assert(false);             // not comparable
+/*
+  interval.cc -- instantiate Interval_t<Real>
 
-    return 0;
-}
+  source file of the Flower Library
 
-const Real INFTY = HUGE;
+  (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
 
-template<class T>
-void
-Interval_t<T>::set_empty() {
-    left = INFTY;
-    right = -INFTY;
-}
+#include "interval.hh"
 
-template<class T>
-T
-Interval_t<T>::length() const {
-    assert(right >= left);
-    return right-left;
-}
+#include "interval.tcc"
 
-template<class T>
-void
-Interval_t<T>::unite(Interval_t<T> h)
+template<>
+Real
+Interval_t<Real>::infinity ()
 {
-    if (h.left<left)
-       left = h.left;
-    if (h.right>right)
-       right = h.right;
+  return HUGE_VAL;
 }
 
-/**
-  smallest Interval which includes *this and #h#
- */
-
-template<class T>
-void
-Interval_t<T>::intersect(Interval_t<T> h)
+template<>
+string
+Interval_t<Real>::T_to_string (Real r)
 {
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-    left = h.left >? left;
-    right = h.right <?right;
-#else
-    left = max(h.left, left);
-    right = min(h.right, right);
-#endif
+  return ::to_string (r);
 }
 
-template<class T>
-Interval_t<T>
-intersect(Interval_t<T> x, Interval_t<T> const &y)
+template<>
+int
+Interval_t<int>::infinity ()
 {
-    x.intersect(y);
-    return x;
+  return INT_MAX;
 }
 
-template<class T>
-String
-Interval_t<T>::str() const
+template<>
+string
+Interval_t<int>::T_to_string (int i)
 {
-    if (empty())
-       return "[empty]";
-    String s("[");
-    return s + left + "," + right +"]";
+  return ::to_string (i);
 }
 
-template<class T>
-bool
-Interval_t<T>::elt_q(T r)
-{
-    return r >= left && r <= right;
-}
+template INTERVAL__INSTANTIATE (int);
+template INTERVAL__INSTANTIATE (Real);