OLD | NEW |
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--2020 Han-Wen Nienhuys | 4 Copyright (C) 1996--2020 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 16 matching lines...) Expand all Loading... |
27 #include "drul-array.hh" | 27 #include "drul-array.hh" |
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 template <typename T2> |
| 38 Interval_t (Interval_t<T2> const &src) : Interval_t (src[LEFT], src[RIGHT]) |
| 39 { |
| 40 } |
| 41 |
37 static T infinity (); | 42 static T infinity (); |
38 T center () const; | 43 T center () const; |
39 void translate (T t) | 44 void translate (T t) |
40 { | 45 { |
41 at (LEFT) += t; | 46 at (LEFT) += t; |
42 at (RIGHT) += t; | 47 at (RIGHT) += t; |
43 } | 48 } |
44 void widen (T t) | 49 void widen (T t) |
45 { | 50 { |
46 at (LEFT) -= t; | 51 at (LEFT) -= t; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 { | 229 { |
225 assert (!is_empty ()); | 230 assert (!is_empty ()); |
226 return (at (LEFT) + at (RIGHT)) / T (2); | 231 return (at (LEFT) + at (RIGHT)) / T (2); |
227 } | 232 } |
228 | 233 |
229 typedef Interval_t<Real> Interval; | 234 typedef Interval_t<Real> Interval; |
230 typedef Interval_t<int> Slice; // weird name | 235 typedef Interval_t<int> Slice; // weird name |
231 | 236 |
232 | 237 |
233 #endif // INTERVAL_HH | 238 #endif // INTERVAL_HH |
234 | |
OLD | NEW |