lilypond-0.0.1
[lilypond.git] / flower / cursor.cc
blob10e90de91912761ed88539142a8c3a22e892fa0b
1 // cursor.cc
2 #ifndef CURSOR_CC
3 #define CURSOR_CC
5 #include "cursor.hh"
6 //#define inline
7 //#include "cursor.inl"
8 #include <assert.h>
10 template<class T>
11 Cursor<T>
12 Cursor<T>::operator ++( int )
14 Cursor<T> r = *this;
15 assert( pointer_ );
16 pointer_ = pointer_->next();
17 return r;
19 template<class T>
20 Cursor<T>
21 Cursor<T>::operator -=( int j )
23 while (j--)
24 (*this)--;
25 return *this;
27 template<class T>
28 Cursor<T>
29 Cursor<T>::operator +=( int j )
31 while (j++)
32 (*this)++;
33 return *this;
36 template<class T>
37 Cursor<T>
38 Cursor<T>::operator --( int )
40 Cursor<T> r = *this;
41 assert( pointer_ );
42 pointer_ = pointer_->previous();
43 return r;
46 template<class T>
47 Cursor<T>
48 Cursor<T>::operator +( int i ) const
50 Cursor<T> r = *this;
52 if (i<0)
53 return r -(-i);
55 while (i--)
56 r++;
58 return r;
61 template<class T>
62 Cursor<T>
63 Cursor<T>::operator -( int i ) const
65 Cursor<T> r = *this;
66 if (i<0)
67 return r +(-i);
69 while (i--)
70 r--;
72 return r;
75 #endif