lilypond-0.0.32
[lilypond.git] / flower / link.inl
blob3926d6bc2ae3db95737315ee414e283d7fd6c9c9
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 #ifndef NDEBUG
11     if (previous_) {
12         assert(previous_->next_ == this);
13     }
14     if (next_) {
15         assert(next_->previous_ == this);
16     }
17 #endif    
20 template<class T>
21 inline
22 Link<T>::Link( const T& thing ) : 
23     thing_( thing )
25     previous_ = next_ = 0;
28 template<class T>
29 inline
30 Link<T>::Link( Link<T>* previous, Link<T>* next, const T& thing ) : 
31     thing_( thing )
33     previous_ = previous;
34     next_ = next;
37 template<class T>
38 inline
39 Link<T>*
40 Link<T>::next()
42     return next_;
45 template<class T>
46 inline
47 Link<T>*
48 Link<T>::previous()
50     return previous_;
53 template<class T>
54 inline
55 void
56 Link<T>::add( const T& thing )
58     
59     Link<T>* l = new Link<T>( this, next_, thing );
60     if ( next_ )
61         next_->previous_ = l;
62     next_ = l;
65 template<class T>
66 inline void
67 Link<T>::insert( const T& thing )
69     //    Link<T>* l = new Link<T>( next_, this, thing );
70                                 // bugfix hwn 16/9/96
71     Link<T>* l = new Link<T>( previous_, this, thing );
72     if ( previous_ )
73         previous_->next_ = l;
74     previous_ = l;
78     don't forget to adjust #l#'s top_ and bottom_.
79     */
80 template<class T>
81 inline void
82 Link<T>::remove(List<T> &l)
84     if ( previous_ ) 
85         previous_->next_ = next_;
86     else 
87         l.top_ = next_;
89     if ( next_ )
90         next_->previous_ = previous_;
91     else
92         l.bottom_ = previous_;
95 template<class T>
96 inline
98 Link<T>::thing()
100     return thing_;
102 #endif