lilypond-0.0.32
[lilypond.git] / flower / cursor.inl
blob54d3703e60732ddc3d9c7bd1653f658c558a78f1
1  // cursor.inl -*-c++-*-
2 #ifndef CURSOR_INL
3 #define CURSOR_INL
4 #include <assert.h>
7 template<class T>
8 inline
9 Cursor<T>::Cursor( const List<T>& list, Link<T>* pointer ) : 
10     list_((List<T>&) list )
12     if ( list.size() )
13         pointer_ = pointer ? pointer : list.top_;
14     else
15         pointer_ = pointer;
18 template<class T>
19 inline
20 Cursor<T>::Cursor( const Cursor<T>& cursor ) :
21     list_( cursor.list_ )
23     pointer_ = cursor.pointer_;
26 template<class T>
27 inline T&
28 Cursor<T>::thing()
30     assert( pointer_ );
31     return pointer_->thing();
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;
43 template<class T>
44 inline void
45 Cursor<T>::add( const T& th )
47     list_.add( th, *this );
50 template<class T>
51 inline void
52 Cursor<T>::insert( const T& th )
54     list_.insert( th, *this );
57 template<class T>
58 inline  List<T>&
59 Cursor<T>::list() const
61     return list_;
64 template<class T>
65 inline Link<T>*
66 Cursor<T>::pointer()
68     return pointer_;
71 template<class T>
72 inline bool
73 Cursor<T>::backward()
75     return ( pointer_ != 0 );
78 template<class T>
79 inline bool
80 Cursor<T>::forward()
82     return ( pointer_ != 0 );
85 template<class T>
86 inline bool
87 Cursor<T>::ok()
89     return ( pointer_ != 0 );
93 template<class T>
94 inline Cursor<T> 
95 Cursor<T>::operator ++( int )    
97     Cursor<T> r (*this);
98     assert( pointer_ );
99     pointer_ = pointer_->next();
100     return r;
103 template<class T>
104 inline Cursor<T>
105 Cursor<T>::operator --( int )
107     Cursor<T> r (*this);
108     assert( pointer_ );
109     pointer_ = pointer_->previous();
110     return r;
113 #endif