]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/cursor.cc
release: 0.0.3
[lilypond.git] / flower / cursor.cc
index 10e90de91912761ed88539142a8c3a22e892fa0b..2a9f885689e57bdcfb3601bfd61603ba44abfc60 100644 (file)
@@ -1,10 +1,7 @@
-// cursor.cc
 #ifndef CURSOR_CC
 #define CURSOR_CC
 
 #include "cursor.hh"
-//#define inline
-//#include "cursor.inl"
 #include <assert.h>
 
 template<class T>
@@ -72,4 +69,27 @@ Cursor<T>::operator -( int i ) const
     return r;
 }
 
+template<class T>
+int
+Cursor<T>::operator-(Cursor<T> c) const
+{
+    assert(c.list == list);
+    int dif = 0;
+    Cursor<T> upward(c);
+    while (upward.ok() && upward.pointer_ != pointer_) {
+       upward++;
+       dif++;
+    }
+    
+    if (upward.ok())
+       return dif;
+    dif =0;
+    while (c.ok()&& c.pointer_ != pointer_) {
+       dif --;
+       c--;
+    }
+    assert(c.ok());
+    return dif;
+}
+
 #endif