]> git.donarmstrong.com Git - lilypond.git/blob - flower/cursor.cc
release: 0.0.1
[lilypond.git] / flower / cursor.cc
1 // cursor.cc
2 #ifndef CURSOR_CC
3 #define CURSOR_CC
4
5 #include "cursor.hh"
6 //#define inline
7 //#include "cursor.inl"
8 #include <assert.h>
9
10 template<class T>
11 Cursor<T> 
12 Cursor<T>::operator ++( int )    
13 {
14     Cursor<T> r = *this;
15     assert( pointer_ );
16     pointer_ = pointer_->next();
17     return r;
18 }
19 template<class T>
20 Cursor<T> 
21 Cursor<T>::operator -=( int j )    
22 {
23     while (j--)
24         (*this)--;
25     return *this;
26 }
27 template<class T>
28 Cursor<T> 
29 Cursor<T>::operator +=( int j )    
30 {
31     while (j++)
32         (*this)++;
33     return *this;
34 }
35
36 template<class T>
37 Cursor<T>
38 Cursor<T>::operator --( int )
39 {
40     Cursor<T> r = *this;
41     assert( pointer_ );
42     pointer_ = pointer_->previous();
43     return r;
44 }
45
46 template<class T>
47 Cursor<T> 
48 Cursor<T>::operator +( int i ) const    
49 {
50     Cursor<T> r = *this;
51
52     if (i<0)
53         return r -(-i);
54
55     while (i--)
56         r++;
57
58     return r;
59 }
60
61 template<class T>
62 Cursor<T>
63 Cursor<T>::operator -( int i ) const
64 {
65     Cursor<T> r = *this;
66     if (i<0)
67         return r +(-i);
68
69     while (i--)
70         r--;
71     
72     return r;
73 }
74
75 #endif