]> git.donarmstrong.com Git - lilypond.git/commitdiff
flower-1.0.12
authorfred <fred>
Fri, 6 Dec 1996 21:44:18 +0000 (21:44 +0000)
committerfred <fred>
Fri, 6 Dec 1996 21:44:18 +0000 (21:44 +0000)
flower/fproto.hh
flower/interval.cc
flower/interval.hh

index 672a992dc99701baf3508104f32e5a2558b0dd52..43452af7b8a9794a0c41943b4f2a11c43d356369 100644 (file)
@@ -29,6 +29,7 @@ struct Getopt_long ;
 struct Matrix ;
 struct StringData ;
 struct String_handle ;
+struct String;
 struct virtual_smat ;
 struct Vector  ;
 class Text_stream;
index b307f4c634f5974ecf0fa12eddce38817f314218..6cc2a7916e9d51e1e4e0758730de40c52ac87a1f 100644 (file)
@@ -1,6 +1,8 @@
 #include <assert.h> 
-#include "interval.hh"
 #include <math.h>
+#include "interval.hh"
+#include "string.hh"
+
 
 const Real INFTY = HUGE;
 
@@ -15,4 +17,34 @@ Interval::length() const {
     assert(max >= min);
     return max-min;
 }
+void
+Interval::unite(Interval h)
+{
+    if (h.min<min)
+       min = h.min;
+    if (h.max>max)
+       max = h.max;
+}
+void
+Interval::intersect(Interval h)
+{
+    min = MAX(h.min, min);
+    max = MIN(h.max, max);
+}
 
+Interval
+intersect(Interval x, Interval const &y)
+{
+    x.intersect(y);
+    return x;
+}
+    
+
+Interval::operator String() const
+{
+    if (empty())
+       return "[empty]";
+    String s("[");
+    return s + min + "," + max +"]";
+}
index 950945ca873216dd4b0c4e75b3a6c7a6222304bc..6f9fa63f672b6856ca6179a597a63de575b5fbc4 100644 (file)
@@ -8,6 +8,7 @@
 #define INTERVAL_HH
 
 #include <assert.h> 
+#include "fproto.hh"
 #include "real.hh"
 
 
@@ -29,15 +30,12 @@ struct Interval {
            return 0.0;
                
     }
-    void unite(Interval h) {
-       if (h.min<min)
-           min = h.min;
-       if (h.max>max)
-           max = h.max;
-    }
+    void unite(Interval h) ;
+    void intersect(Interval h);
+
     Real length() const;
     void set_empty() ;
-    bool empty() { return min > max; }
+    bool empty() const { return min > max; }
     Interval() {
        set_empty();
     }
@@ -50,9 +48,13 @@ struct Interval {
        max +=r;
        return *this;
     }
+
+    operator String() const;
 };
 
 
+Interval intersection(Interval, Interval const&);
+
 #endif // INTERVAL_HH