lilypond-0.0.1
[lilypond.git] / flower / link.inl
blobe76caab4f171f51dfd3c7a729c69f41e818d63b3
1 // link.inl -*-c++-*-
2 #ifndef LINK_INL
3 #define LINK_INL
4 #include <assert.h>
5 template<class T>
6 inline
7 void
8 Link<T>::OK() const
10     if (previous_) {
11         assert(previous_->next_ == this);
12     }
13     if (next_) {
14         assert(next_->previous_ == this);
15     }
18 template<class T>
19 inline
20 Link<T>::Link( const T& thing ) : 
21     thing_( thing )
23     previous_ = next_ = 0;
26 template<class T>
27 inline
28 Link<T>::Link( Link<T>* previous, Link<T>* next, const T& thing ) : 
29     thing_( thing )
31     previous_ = previous;
32     next_ = next;
35 template<class T>
36 inline
37 Link<T>*
38 Link<T>::next()
40     return next_;
43 template<class T>
44 inline
45 Link<T>*
46 Link<T>::previous()
48     return previous_;
51 template<class T>
52 inline
53 void
54 Link<T>::add( const T& thing )
56     
57     Link<T>* l = new Link<T>( this, next_, thing );
58     if ( next_ )
59         next_->previous_ = l;
60     next_ = l;
63 template<class T>
64 inline void
65 Link<T>::insert( const T& thing )
67     //    Link<T>* l = new Link<T>( next_, this, thing );
68                                 // bugfix hwn 16/9/96
69     Link<T>* l = new Link<T>( previous_, this, thing );
70     if ( previous_ )
71         previous_->next_ = l;
72     previous_ = l;
76     don't forget to adjust #l#'s top_ and bottom_.
77     */
78 template<class T>
79 inline void
80 Link<T>::remove(List<T> &l)
82     if ( previous_ ) 
83         previous_->next_ = next_;
84     else 
85         l.top_ = next_;
87     if ( next_ )
88         next_->previous_ = previous_;
89     else
90         l.bottom_ = previous_;
93 template<class T>
94 inline
96 Link<T>::thing()
98     return thing_;
100 #endif