From: fred Date: Fri, 6 Dec 1996 21:44:18 +0000 (+0000) Subject: flower-1.0.12 X-Git-Tag: release/1.5.59~6647 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7a25d4132b6f2682e8dd8d5d3a6ec4352c7770de;p=lilypond.git flower-1.0.12 --- diff --git a/flower/fproto.hh b/flower/fproto.hh index 672a992dc9..43452af7b8 100644 --- a/flower/fproto.hh +++ b/flower/fproto.hh @@ -29,6 +29,7 @@ struct Getopt_long ; struct Matrix ; struct StringData ; struct String_handle ; +struct String; struct virtual_smat ; struct Vector ; class Text_stream; diff --git a/flower/interval.cc b/flower/interval.cc index b307f4c634..6cc2a7916e 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -1,6 +1,8 @@ #include -#include "interval.hh" #include +#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.minmax) + 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 +"]"; +} diff --git a/flower/interval.hh b/flower/interval.hh index 950945ca87..6f9fa63f67 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -8,6 +8,7 @@ #define INTERVAL_HH #include +#include "fproto.hh" #include "real.hh" @@ -29,15 +30,12 @@ struct Interval { return 0.0; } - void unite(Interval h) { - if (h.minmax) - 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