LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1996--2019 Han-Wen Nienhuys | 4 Copyright (C) 1996--2019 Han-Wen Nienhuys |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 /* A T interval. This represents the closed interval [left,right]. | 29 /* A T interval. This represents the closed interval [left,right]. |
30 No invariants. T must be a totally ordered ring (with division, anyway ..) | 30 No invariants. T must be a totally ordered ring (with division, anyway ..) |
31 At instantiation, the function infinity () has to be defined explicitly. */ | 31 At instantiation, the function infinity () has to be defined explicitly. */ |
32 template<class T> | 32 template<class T> |
33 struct Interval_t : public Drul_array<T> | 33 struct Interval_t : public Drul_array<T> |
34 { | 34 { |
35 using Drul_array<T>::at; | 35 using Drul_array<T>::at; |
36 | 36 |
37 static T infinity (); | 37 static T infinity (); |
38 static string T_to_string (T arg); | |
39 T center () const; | 38 T center () const; |
40 void translate (T t) | 39 void translate (T t) |
41 { | 40 { |
42 at (LEFT) += t; | 41 at (LEFT) += t; |
43 at (RIGHT) += t; | 42 at (RIGHT) += t; |
44 } | 43 } |
45 void widen (T t) | 44 void widen (T t) |
46 { | 45 { |
47 at (LEFT) -= t; | 46 at (LEFT) -= t; |
48 at (RIGHT) += t; | 47 at (RIGHT) += t; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 assert (!is_empty ()); | 225 assert (!is_empty ()); |
227 return (at (LEFT) + at (RIGHT)) / T (2); | 226 return (at (LEFT) + at (RIGHT)) / T (2); |
228 } | 227 } |
229 | 228 |
230 typedef Interval_t<Real> Interval; | 229 typedef Interval_t<Real> Interval; |
231 typedef Interval_t<int> Slice; // weird name | 230 typedef Interval_t<int> Slice; // weird name |
232 | 231 |
233 | 232 |
234 #endif // INTERVAL_HH | 233 #endif // INTERVAL_HH |
235 | 234 |
LEFT | RIGHT |