]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/cursor.icc
release: 0.0.46.jcn1
[lilypond.git] / flower / include / cursor.icc
1  // cursor.icc -*-c++-*-
2 #ifndef CURSOR_INL
3 #define CURSOR_INL
4 #include <assert.h>
5
6
7 template<class T>
8 inline
9 Cursor<T>::Cursor( const List<T>& list, Link<T>* pointer ) : 
10     list_((List<T>&) list )
11 {
12     if ( list.size() )
13         pointer_ = pointer ? pointer : list.top_;
14     else
15         pointer_ = pointer;
16 }
17
18 template<class T>
19 inline
20 Cursor<T>::Cursor( const Cursor<T>& cursor ) :
21     list_( cursor.list_ )
22 {
23     pointer_ = cursor.pointer_;
24 }
25
26 template<class T>
27 inline T&
28 Cursor<T>::thing()
29 {
30     assert( pointer_ );
31     return pointer_->thing();
32 }
33
34 template<class T>
35 Cursor<T>
36 Cursor<T>::operator =( const Cursor<T>& c )
37 {   
38     assert( &list_ == &c.list_ );
39     pointer_ = c.pointer_;
40     return *this;
41 }
42
43 template<class T>
44 inline void
45 Cursor<T>::add( const T& th )
46 {
47     list_.add( th, *this );
48 }
49
50 template<class T>
51 inline void
52 Cursor<T>::insert( const T& th )
53 {
54     list_.insert( th, *this );
55 }
56
57 template<class T>
58 inline  List<T>&
59 Cursor<T>::list() const
60 {
61     return list_;
62 }
63
64 template<class T>
65 inline Link<T>*
66 Cursor<T>::pointer()
67 {
68     return pointer_;
69 }
70
71 template<class T>
72 inline bool
73 Cursor<T>::backward()
74 {
75     return ( pointer_ != 0 );
76 }
77
78 template<class T>
79 inline bool
80 Cursor<T>::forward()
81 {
82     return ( pointer_ != 0 );
83 }
84
85 template<class T>
86 inline bool
87 Cursor<T>::ok()
88 {
89     return ( pointer_ != 0 );
90 }
91
92
93 template<class T>
94 inline Cursor<T> 
95 Cursor<T>::operator ++( int )    
96 {
97     Cursor<T> r (*this);
98     assert( pointer_ );
99     pointer_ = pointer_->next();
100     return r;
101 }
102
103 template<class T>
104 inline Cursor<T>
105 Cursor<T>::operator --( int )
106 {
107     Cursor<T> r (*this);
108     assert( pointer_ );
109     pointer_ = pointer_->previous();
110     return r;
111 }
112
113 #endif