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