]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/include/interval.tcc
Imported sources
[lilypond.git] / flower / include / interval.tcc
index c78b476a91a4cc361845ca0ec801e5acd95431b6..79e7c548e61ca374162e7069a09527ac729a24f3 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the Flower Library
 
-  (c) 1996, 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
@@ -60,16 +60,31 @@ Interval_t<T>::set_empty ()
   elem (RIGHT) = (T) -infinity ();
 }
 
+template<class T>
+void
+Interval_t<T>::set_full ()
+{
+  elem (LEFT) = (T) -infinity ();
+  elem (RIGHT) = (T) infinity ();
+}
+
 template<class T>
 T
 Interval_t<T>::length () const 
 {
-  if (elem (RIGHT) < elem (LEFT)) 
+  if (elem (RIGHT) <= elem (LEFT)) 
     return 0;
   else 
     return elem (RIGHT)-elem (LEFT);
 }
 
+template<class T>
+T
+Interval_t<T>::delta () const 
+{
+  return elem (RIGHT) - elem (LEFT);
+}
+
 /**
   smallest Interval which includes *this and #h#
  */
@@ -112,18 +127,18 @@ intersect (Interval_t<T> x, Interval_t<T> const &y)
 
 template<class T>
 String
-Interval_t<T>::str () const
+Interval_t<T>::to_string () const
 {
-  if (empty_b ())
+  if (is_empty ())
     return "[empty]";
   String s ("[");
  
-  return s + T_to_str (elem (LEFT)) + String ("," ) + T_to_str (elem (RIGHT) ) + String ("]" );
+  return s + T_to_string (elem (LEFT)) + String ("," ) + T_to_string (elem (RIGHT) ) + String ("]" );
 }
 
 template<class T>
 bool
-Interval_t<T>::elem_b (T r)
+Interval_t<T>::contains (T r)
 {
   return r >= elem (LEFT) && r <= elem (RIGHT);
 }