From: fred Date: Fri, 20 Dec 1996 17:12:21 +0000 (+0000) Subject: flower-1.0.16 X-Git-Tag: release/1.5.59~6538 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a3d55b2ef25142c8e97e3ee6ced902f145b88053;p=lilypond.git flower-1.0.16 --- diff --git a/flower/TODO b/flower/TODO index 9d4ade3bcd..6ce4b741d2 100644 --- a/flower/TODO +++ b/flower/TODO @@ -1,3 +1,6 @@ + + * PointerVec ? + * PCursor -> Pointer_cursor / PointerCursor ? * efficient copy cons for List @@ -12,9 +15,6 @@ * use template handle in handle.hh for strings. - * Restricted cursor/list: make sublist from a list, and use rcursor -as if list is as big as the sublist. - * move towards gnu or STL? parsestream.h diff --git a/flower/interval.cc b/flower/interval.cc index 6fac1f55dc..f176c7486f 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -17,20 +17,24 @@ Interval::length() const { assert(max >= min); return max-min; } + void Interval::unite(Interval h) { + compare(h, *this ); if (h.minmax) max = h.max; } + void Interval::intersect(Interval h) { min = MAX(h.min, min); max = MIN(h.max, max); } + Interval intersection(Interval a, Interval const&b) { @@ -38,6 +42,7 @@ intersection(Interval a, Interval const&b) return a; } + int Interval::compare(const Interval&a,Interval const&b) { @@ -62,8 +67,8 @@ intersect(Interval x, Interval const &y) return x; } - -Interval::operator String() const +String +Interval::str() const { if (empty()) return "[empty]"; diff --git a/flower/interval.hh b/flower/interval.hh index a7a269153b..5331c1d125 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -16,6 +16,9 @@ struct Interval { Real min, max; + /****************/ + + Real center() { return (min + max) /2;} void translate(Real t) { min += t; max += t; @@ -31,6 +34,10 @@ struct Interval { } void unite(Interval h) ; + /** + PRE + *this and h are comparable + */ void intersect(Interval h); Real length() const; @@ -49,13 +56,17 @@ struct Interval { return *this; } bool elt_q(Real r); - operator String() const; + String str() const; /// partial ordering static compare(const Interval&,Interval const&); + /** + inclusion ordering. Crash if not comparable. + */ }; /** - this represents the closed interval [min,max] + this represents the closed interval [min,max]. + No invariants */ Interval intersection(Interval, Interval const&); @@ -64,6 +75,19 @@ Interval intersection(Interval, Interval const&); instantiate_compare(Interval&, Interval::compare); + +inline +Interval operator +(double a,Interval i ) +{ + i += a; + return i; +} + +inline +Interval operator +(Interval i,double a ){ + return a+i; +} + #endif // INTERVAL_HH