]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/interval.tcc
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / flower / include / interval.tcc
index 4e3323f74889bb6a2a15675294b5408f969c70cd..5cd938fd0853fc14d9a68e85c7e8b9d2c4b2807b 100644 (file)
@@ -1,31 +1,45 @@
 /*
-  interval.tcc -- implement Interval_t
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the Flower Library
+  Copyright (C) 1996--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
-  (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifndef INTERVAL_TCC
 #define INTERVAL_TCC
 
 #include <cassert>
-#include <cmath>
 
 #include "interval.hh"
-#include "string.hh"
+#include "std-string.hh"
+
+// MacOS 10.3 problems:
+// #include <cmath>
+using namespace std;
 
 template<class T>
 int
 _Interval__compare (const Interval_t<T> &a, Interval_t<T> const &b)
 {
-  if (a.elem (LEFT) == b.elem (LEFT) && a.elem (RIGHT) == b.elem (RIGHT))
+  if (a.at (LEFT) == b.at (LEFT) && a.at (RIGHT) == b.at (RIGHT))
     return 0;
 
-  if (a.elem (LEFT) <= b.elem (LEFT) && a.elem (RIGHT) >= b.elem (RIGHT))
+  if (a.at (LEFT) <= b.at (LEFT) && a.at (RIGHT) >= b.at (RIGHT))
     return 1;
 
-  if (a.elem (LEFT) >= b.elem (LEFT) && a.elem (RIGHT) <= b.elem (RIGHT))
+  if (a.at (LEFT) >= b.at (LEFT) && a.at (RIGHT) <= b.at (RIGHT))
     return -1;
 
   return -2;
@@ -55,33 +69,33 @@ template<class T>
 void
 Interval_t<T>::set_empty ()
 {
-  elem_ref (LEFT) = (T) infinity ();
-  elem_ref (RIGHT) = (T) -infinity ();
+  at (LEFT) = (T) infinity ();
+  at (RIGHT) = (T) -infinity ();
 }
 
 template<class T>
 void
 Interval_t<T>::set_full ()
 {
-  elem_ref (LEFT) = (T) -infinity ();
-  elem_ref (RIGHT) = (T) infinity ();
+  at (LEFT) = (T) -infinity ();
+  at (RIGHT) = (T) infinity ();
 }
 
 template<class T>
 T
 Interval_t<T>::length () const
 {
-  if (elem (RIGHT) <= elem (LEFT))
+  if (at (RIGHT) <= at (LEFT))
     return 0;
   else
-    return elem (RIGHT) - elem (LEFT);
+    return at (RIGHT) - at (LEFT);
 }
 
 template<class T>
 T
 Interval_t<T>::delta () const
 {
-  return elem (RIGHT) - elem (LEFT);
+  return at (RIGHT) - at (LEFT);
 }
 
 /* smallest Interval which includes *this and #h#  */
@@ -89,35 +103,35 @@ template<class T>
 void
 Interval_t<T>::unite (Interval_t<T> h)
 {
-  elem_ref (LEFT) = min (h.elem (LEFT), elem (LEFT));
-  elem_ref (RIGHT) = max (h.elem (RIGHT), elem (RIGHT));
+  at (LEFT) = min (h.at (LEFT), at (LEFT));
+  at (RIGHT) = max (h.at (RIGHT), at (RIGHT));
 }
 
 template<class T>
 void
 Interval_t<T>::intersect (Interval_t<T> h)
 {
-  elem_ref (LEFT) = max (h.elem (LEFT), elem (LEFT));
-  elem_ref (RIGHT) = min (h.elem (RIGHT), elem (RIGHT));
+  at (LEFT) = max (h.at (LEFT), at (LEFT));
+  at (RIGHT) = min (h.at (RIGHT), at (RIGHT));
 }
 
 template<class T>
-String
+string
 Interval_t<T>::to_string () const
 {
   if (is_empty ())
     return "[empty]";
-  String s ("[");
+  string s ("[");
 
-  return (s + T_to_string (elem (LEFT)) + String (",")
-         + T_to_string (elem (RIGHT)) + String ("]"));
+  return (s + T_to_string (at (LEFT)) + string (",")
+         + T_to_string (at (RIGHT)) + string ("]"));
 }
 
 template<class T>
 bool
-Interval_t<T>::contains (T r)
+Interval_t<T>::contains (T r) const
 {
-  return r >= elem (LEFT) && r <= elem (RIGHT);
+  return r >= at (LEFT) && r <= at (RIGHT);
 }
 
 #define INTERVAL__INSTANTIATE(T) struct Interval_t<T>;                 \